From patchwork Thu Jan 9 15:06:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 856011 Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53DED21CFEC; Thu, 9 Jan 2025 15:08:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435285; cv=none; b=DtL6wOX+6eJiNtUP9mk/D4hoc90ExRw5dtqv3q2yiiBgUs86K4U/WODxaj8pxEqI5vtCy84ouWj9pzYG3v1zsA2/L2O/rphlT7KDnF63W7wdMBSjB+XyGYIbflR5zU0B5FMXWPc750oUs40Noj14h6Kcm+PntQfkrkNG/ugeUso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435285; c=relaxed/simple; bh=rRetxo8v9LWZ8uozl4d/SR2xB+xG/A+f6yMZOFXQVnI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JPT+ERr0cOdWtsaKcwDdceqX9ueahD9Tbs4q1AzZ0KBwz9hRfm5sfrmGJPc1bdrPk+ngN7Ga5gG3GXr+AFMNtT9toIkheiuSbyQpvU8o34DYMoCi8CMV3Uo9H/Zd+b5SsJjGcGB/zOa2+5N/Jma3HMvEmCzQ95Wg04XXgOoTGI4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ntSwJ80r; arc=none smtp.client-ip=209.85.217.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ntSwJ80r" Received: by mail-vs1-f48.google.com with SMTP id ada2fe7eead31-4aff5b3845eso467667137.2; Thu, 09 Jan 2025 07:08:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736435282; x=1737040082; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X7/ilE4wKe17fP2dMeHsDJvp4dxl8L2B6sowIvQLZLk=; b=ntSwJ80rBR15JdnLWZblCWREltpzXYcM328rDvf5GetBu3taBfs61TEMbYm3BUeMB+ qBKo1n60tHcJENHFVaenCHituaGA+KCp7KJCnmjDXOS/E5OA3kOtZt7RM5R4bGwULyQS VRdz976WASSSlwN1wwNVCxA4qW0AlS5dthE/ZgZVa82puVt2yHqLPpXGRXYstSQG+Oam d5hjDX4RuDkVdKFhQ3Wg+x2Hl0jH4w/0KNEZKqnKHbvYCaZhetp2tl03/CJ+IbWsWA+G 7DMe/hgb+jsLLn2yheXgqM9iAQmMXv0//mzH2+zyi1j1pkVGm9B79hN4aI+RjZUnR/LY mmow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736435282; x=1737040082; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X7/ilE4wKe17fP2dMeHsDJvp4dxl8L2B6sowIvQLZLk=; b=nH3GPmr4bDh4WxsxKF+CD/rRtQ+tbIHI6pb60JZSB/Yh+80oIL8jRoUpZDt16RvxCO An5UrCnqUZM3uqwUIaGuJvBzNSRHEid4jR9ngIMG+oYn0bi4QMZn0OdDtmqbM3+k1vkO p6I95zyVCb0VdjU1Tw/4vIEkhur8eePwmT67WAxsUtIz18S9JKLjkUDKIrb5NbNDlbES nlzFNjR3aBOzkjaQXi/set6W7C5ESoRQR75BOb6k81nlA/MOmcHhs45n5TrZLurnvVY8 d5o63f9bbOhW0iym4R0Fm5Yiv2z7MnKNw7fYw3Jha18zLA7yXxdh9VZCcOMAGkzhLd67 Y+mQ== X-Forwarded-Encrypted: i=1; AJvYcCVAIPn+gkbRyJODVk9ZtIeC0HI9GB9SI+xafgBZXYLpOcmt7b9IBcGLe8Xe2YpQTA23nT2p2KHeNUzY@vger.kernel.org, AJvYcCWonTIeJaoMtzm7M1WXQy0WUzwWrFqWjP9gzJm22gUUOoEUoRUvzwdYYrKO0LWHSqBI2auk40Xh/LVskJYL@vger.kernel.org X-Gm-Message-State: AOJu0YwS0z57r+Xv2Ikuzh6Dy65VGVOnRSuOTLMzKoOlSJ45SLPnIBQZ LVgfxbCRZ6lgC9Gl7f1V4tOooYNf38zFGLQu8f/LtjjaOAPbV5kjke22bm/W X-Gm-Gg: ASbGncuxOehSki+IMbt918mOv6lH/9LuoYzDKGO1HUaJzSQCFpwVfWgjOQIeCunPTo5 p14WG5UNLa+OIOGkc6LUp2jILPSBdagVXN+dRCw9todyJjbm4Imf9Gr/TXUz058X3V6PYmvdPAq IokaSSFcRBjNNGfZaXjKfG9bEkoHm72RmKOS7s/3n0e2fhBtXPdlAbMnItWSrDDWjFcNiQLqqAy 08+V/Atm3pVlD4dB77eKy6Ldd/u+D80342iNcxoC/NEq+qN8oC+skNplLILZIfm X-Google-Smtp-Source: AGHT+IFguFKf1b92s0mVyF7N4sniR6KrG7JkdNcMGWyYMmpLnYoCmUSh5BO+i26XkRYHZZrb0D/tZg== X-Received: by 2002:a05:6102:5128:b0:4af:a98a:bd67 with SMTP id ada2fe7eead31-4b3d0f619f7mr6263797137.3.1736435281416; Thu, 09 Jan 2025 07:08:01 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4b608f4a5ddsm1019887137.11.2025.01.09.07.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 07:08:01 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , Joshua Grisham , "Derek J . Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , Kurt Borja , Maximilian Luz , "Lee, Chun-Yi" , Shyam Sundar S K , Corentin Chary , "Luke D. Jones" , Lyndon Sanche , Ike Panhc , Henrique de Moraes Holschuh , Mark Pearson , Colin Ian King , Alexis Belmonte , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH 02/18] ACPI: platform_profile: Add `choices` to platform_profile_ops Date: Thu, 9 Jan 2025 10:06:15 -0500 Message-ID: <20250109150731.110799-3-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109150731.110799-1-kuurtb@gmail.com> References: <20250109150731.110799-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a `choices` callback to platform_profile_ops, which lets drivers specify how to select available profiles. Signed-off-by: Kurt Borja --- drivers/acpi/platform_profile.c | 13 +++++++-- .../surface/surface_platform_profile.c | 16 ++++++---- drivers/platform/x86/acer-wmi.c | 24 ++++++++------- drivers/platform/x86/amd/pmf/sps.c | 15 ++++++---- drivers/platform/x86/asus-wmi.c | 16 ++++++---- drivers/platform/x86/dell/alienware-wmi.c | 24 +++++++++------ drivers/platform/x86/dell/dell-pc.c | 26 ++++++++++------- drivers/platform/x86/hp/hp-wmi.c | 29 +++++++++++++------ drivers/platform/x86/ideapad-laptop.c | 15 ++++++---- .../platform/x86/inspur_platform_profile.c | 14 ++++++--- drivers/platform/x86/thinkpad_acpi.c | 15 ++++++---- include/linux/platform_profile.h | 1 + 12 files changed, 137 insertions(+), 71 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 39a22e27acc5..9cb82173947c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -464,12 +464,21 @@ int platform_profile_register(struct platform_profile_handler *pprof) int err; /* Sanity check the profile handler */ - if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || - !pprof->ops->profile_set || !pprof->ops->profile_get) { + if (!pprof || !pprof->ops->profile_set || !pprof->ops->profile_get || + !pprof->ops->choices) { pr_err("platform_profile: handler is invalid\n"); return -EINVAL; } + err = pprof->ops->choices(pprof); + if (err < 0) + return err; + + if (bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST)) { + pr_err("platform_profile: no available profiles\n"); + return -EINVAL; + } + guard(mutex)(&profile_lock); /* create class interface for individual handler */ diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 2a9716372d56..b69fcc4c3858 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -201,9 +201,20 @@ static int ssam_platform_profile_set(struct platform_profile_handler *pprof, return tp; } +static int ssam_platform_profile_choices(struct platform_profile_handler *pprof) +{ + set_bit(PLATFORM_PROFILE_LOW_POWER, pprof->choices); + set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices); + set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, pprof->choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices); + + return 0; +} + static const struct platform_profile_ops ssam_platform_profile_ops = { .profile_get = ssam_platform_profile_get, .profile_set = ssam_platform_profile_set, + .choices = ssam_platform_profile_choices, }; static int surface_platform_profile_probe(struct ssam_device *sdev) @@ -223,11 +234,6 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->has_fan = device_property_read_bool(&sdev->dev, "has_fan"); - set_bit(PLATFORM_PROFILE_LOW_POWER, tpd->handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED, tpd->handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, tpd->handler.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, tpd->handler.choices); - return platform_profile_register(&tpd->handler); } diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index ac7b3ab8fd2a..1fa0cd69da8c 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1900,9 +1900,22 @@ acer_predator_v4_platform_profile_set(struct platform_profile_handler *pprof, return 0; } +static int +acer_predator_v4_platform_profile_choices(struct platform_profile_handler *pprof) +{ + set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices); + set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, pprof->choices); + set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices); + set_bit(PLATFORM_PROFILE_QUIET, pprof->choices); + set_bit(PLATFORM_PROFILE_LOW_POWER, pprof->choices); + + return 0; +} + static const struct platform_profile_ops acer_predator_v4_platform_profile_ops = { .profile_get = acer_predator_v4_platform_profile_get, .profile_set = acer_predator_v4_platform_profile_set, + .choices = acer_predator_v4_platform_profile_choices, }; static int acer_platform_profile_setup(struct platform_device *device) @@ -1915,17 +1928,6 @@ static int acer_platform_profile_setup(struct platform_device *device) platform_profile_handler.ops = &acer_predator_v4_platform_profile_ops; - set_bit(PLATFORM_PROFILE_PERFORMANCE, - platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, - platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED, - platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_QUIET, - platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_LOW_POWER, - platform_profile_handler.choices); - err = platform_profile_register(&platform_profile_handler); if (err) return err; diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 7c8391ac4dbb..37316bc3e071 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -387,9 +387,19 @@ static int amd_pmf_profile_set(struct platform_profile_handler *pprof, return 0; } +static int amd_pmf_profile_choices(struct platform_profile_handler *pprof) +{ + set_bit(PLATFORM_PROFILE_LOW_POWER, pprof->choices); + set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices); + + return 0; +} + static const struct platform_profile_ops amd_pmf_profile_ops = { .profile_get = amd_pmf_profile_get, .profile_set = amd_pmf_profile_set, + .choices = amd_pmf_profile_choices, }; int amd_pmf_init_sps(struct amd_pmf_dev *dev) @@ -414,11 +424,6 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) dev->pprof.dev = dev->dev; dev->pprof.ops = &amd_pmf_profile_ops; - /* Setup supported modes */ - set_bit(PLATFORM_PROFILE_LOW_POWER, dev->pprof.choices); - set_bit(PLATFORM_PROFILE_BALANCED, dev->pprof.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, dev->pprof.choices); - /* Create platform_profile structure and register */ err = platform_profile_register(&dev->pprof); if (err) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index ef4129d91656..3e94986078a6 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3852,9 +3852,19 @@ static int asus_wmi_platform_profile_set(struct platform_profile_handler *pprof, return throttle_thermal_policy_write(asus); } +static int asus_wmi_platform_profile_choices(struct platform_profile_handler *pprof) +{ + set_bit(PLATFORM_PROFILE_QUIET, pprof->choices); + set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices); + + return 0; +} + static const struct platform_profile_ops asus_wmi_platform_profile_ops = { .profile_get = asus_wmi_platform_profile_get, .profile_set = asus_wmi_platform_profile_set, + .choices = asus_wmi_platform_profile_choices, }; static int platform_profile_setup(struct asus_wmi *asus) @@ -3885,12 +3895,6 @@ static int platform_profile_setup(struct asus_wmi *asus) asus->platform_profile_handler.dev = dev; asus->platform_profile_handler.ops = &asus_wmi_platform_profile_ops; - set_bit(PLATFORM_PROFILE_QUIET, asus->platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED, - asus->platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, - asus->platform_profile_handler.choices); - err = platform_profile_register(&asus->platform_profile_handler); if (err == -EEXIST) { pr_warn("%s, a platform_profile handler is already registered\n", __func__); diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index c824414565b6..386b22e9c922 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1108,12 +1108,7 @@ static int thermal_profile_set(struct platform_profile_handler *pprof, return wmax_thermal_control(supported_thermal_profiles[profile]); } -static const struct platform_profile_ops awcc_platform_profile_ops = { - .profile_get = thermal_profile_get, - .profile_set = thermal_profile_set, -}; - -static int create_thermal_profile(struct platform_device *platform_device) +static int thermal_profile_choices(struct platform_profile_handler *pprof) { u32 out_data; u8 sys_desc[4]; @@ -1146,19 +1141,30 @@ static int create_thermal_profile(struct platform_device *platform_device) profile = wmax_mode_to_platform_profile[mode]; supported_thermal_profiles[profile] = out_data; - set_bit(profile, pp_handler.choices); + set_bit(profile, pprof->choices); } - if (bitmap_empty(pp_handler.choices, PLATFORM_PROFILE_LAST)) + if (bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST)) return -ENODEV; if (quirks->gmode) { supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] = WMAX_THERMAL_MODE_GMODE; - set_bit(PLATFORM_PROFILE_PERFORMANCE, pp_handler.choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices); } + return 0; +} + +static const struct platform_profile_ops awcc_platform_profile_ops = { + .profile_get = thermal_profile_get, + .profile_set = thermal_profile_set, + .choices = thermal_profile_choices, +}; + +static int create_thermal_profile(struct platform_device *platform_device) +{ pp_handler.name = "alienware-wmi"; pp_handler.dev = &platform_device->dev; pp_handler.ops = &awcc_platform_profile_ops; diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 1751b7235031..ba366c28d9a6 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -24,6 +24,7 @@ #include "dell-smbios.h" static struct platform_device *platform_device; +static int supported_modes; static const struct dmi_system_id dell_device_table[] __initconst = { { @@ -231,15 +232,29 @@ static int thermal_platform_profile_get(struct platform_profile_handler *pprof, return 0; } +static int thermal_platform_profile_choices(struct platform_profile_handler *pprof) +{ + if (supported_modes & DELL_QUIET) + set_bit(PLATFORM_PROFILE_QUIET, pprof->choices); + if (supported_modes & DELL_COOL_BOTTOM) + set_bit(PLATFORM_PROFILE_COOL, pprof->choices); + if (supported_modes & DELL_BALANCED) + set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices); + if (supported_modes & DELL_PERFORMANCE) + set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices); + + return 0; +} + static const struct platform_profile_ops dell_pc_platform_profile_ops = { .profile_get = thermal_platform_profile_get, .profile_set = thermal_platform_profile_set, + .choices = thermal_platform_profile_choices, }; static int thermal_init(void) { int ret; - int supported_modes; /* If thermal commands are not supported, exit without error */ if (!dell_smbios_class_is_supported(CLASS_INFO)) @@ -265,15 +280,6 @@ static int thermal_init(void) thermal_handler->dev = &platform_device->dev; thermal_handler->ops = &dell_pc_platform_profile_ops; - if (supported_modes & DELL_QUIET) - set_bit(PLATFORM_PROFILE_QUIET, thermal_handler->choices); - if (supported_modes & DELL_COOL_BOTTOM) - set_bit(PLATFORM_PROFILE_COOL, thermal_handler->choices); - if (supported_modes & DELL_BALANCED) - set_bit(PLATFORM_PROFILE_BALANCED, thermal_handler->choices); - if (supported_modes & DELL_PERFORMANCE) - set_bit(PLATFORM_PROFILE_PERFORMANCE, thermal_handler->choices); - /* Clean up if failed */ ret = platform_profile_register(thermal_handler); if (ret) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index c37e44f7606c..3c2d4549eb7f 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1488,6 +1488,23 @@ static int platform_profile_victus_set(struct platform_profile_handler *pprof, return 0; } +static int hp_wmi_platform_profile_choices(struct platform_profile_handler *pprof) +{ + if (is_omen_thermal_profile()) { + set_bit(PLATFORM_PROFILE_COOL, pprof->choices); + } else if (is_victus_thermal_profile()) { + set_bit(PLATFORM_PROFILE_QUIET, pprof->choices); + } else { + set_bit(PLATFORM_PROFILE_QUIET, pprof->choices); + set_bit(PLATFORM_PROFILE_COOL, pprof->choices); + } + + set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices); + + return 0; +} + static int omen_powersource_event(struct notifier_block *nb, unsigned long value, void *data) @@ -1568,16 +1585,19 @@ static inline void omen_unregister_powersource_event_handler(void) static const struct platform_profile_ops platform_profile_omen_ops = { .profile_get = platform_profile_omen_get, .profile_set = platform_profile_omen_set, + .choices = hp_wmi_platform_profile_choices, }; static const struct platform_profile_ops platform_profile_victus_ops = { .profile_get = platform_profile_victus_get, .profile_set = platform_profile_victus_set, + .choices = hp_wmi_platform_profile_choices, }; static const struct platform_profile_ops hp_wmi_platform_profile_ops = { .profile_get = hp_wmi_platform_profile_get, .profile_set = hp_wmi_platform_profile_set, + .choices = hp_wmi_platform_profile_choices, }; static int thermal_profile_setup(struct platform_device *device) @@ -1598,8 +1618,6 @@ static int thermal_profile_setup(struct platform_device *device) return err; platform_profile_handler.ops = &platform_profile_omen_ops; - - set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); } else if (is_victus_thermal_profile()) { err = platform_profile_victus_get_ec(&active_platform_profile); if (err < 0) @@ -1614,8 +1632,6 @@ static int thermal_profile_setup(struct platform_device *device) return err; platform_profile_handler.ops = &platform_profile_victus_ops; - - set_bit(PLATFORM_PROFILE_QUIET, platform_profile_handler.choices); } else { tp = thermal_profile_get(); @@ -1631,15 +1647,10 @@ static int thermal_profile_setup(struct platform_device *device) return err; platform_profile_handler.ops = &hp_wmi_platform_profile_ops; - - set_bit(PLATFORM_PROFILE_QUIET, platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); } platform_profile_handler.name = "hp-wmi"; platform_profile_handler.dev = &device->dev; - set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); err = platform_profile_register(&platform_profile_handler); if (err) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index b49ee94f9bee..f5ea03763a54 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1023,6 +1023,15 @@ static int dytc_profile_set(struct platform_profile_handler *pprof, return -EINTR; } +static int dytc_profile_choices(struct platform_profile_handler *pprof) +{ + set_bit(PLATFORM_PROFILE_LOW_POWER, pprof->choices); + set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices); + + return 0; +} + static void dytc_profile_refresh(struct ideapad_private *priv) { enum platform_profile_option profile; @@ -1066,6 +1075,7 @@ static const struct dmi_system_id ideapad_dytc_v4_allow_table[] = { static const struct platform_profile_ops dytc_profile_ops = { .profile_get = dytc_profile_get, .profile_set = dytc_profile_set, + .choices = dytc_profile_choices, }; static int ideapad_dytc_profile_init(struct ideapad_private *priv) @@ -1112,11 +1122,6 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) priv->dytc->priv = priv; priv->dytc->pprof.ops = &dytc_profile_ops; - /* Setup supported modes */ - set_bit(PLATFORM_PROFILE_LOW_POWER, priv->dytc->pprof.choices); - set_bit(PLATFORM_PROFILE_BALANCED, priv->dytc->pprof.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->dytc->pprof.choices); - /* Create platform_profile structure and register */ err = platform_profile_register(&priv->dytc->pprof); if (err) diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 38d4745f6be1..8fa9308d4686 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -166,9 +166,19 @@ static int inspur_platform_profile_get(struct platform_profile_handler *pprof, return 0; } +static int inspur_platform_profile_choices(struct platform_profile_handler *pprof) +{ + set_bit(PLATFORM_PROFILE_LOW_POWER, pprof->choices); + set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices); + + return 0; +} + static const struct platform_profile_ops inspur_platform_profile_ops = { .profile_get = inspur_platform_profile_get, .profile_set = inspur_platform_profile_set, + .choices = inspur_platform_profile_choices, }; static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) @@ -186,10 +196,6 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->handler.dev = &wdev->dev; priv->handler.ops = &inspur_platform_profile_ops; - set_bit(PLATFORM_PROFILE_LOW_POWER, priv->handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED, priv->handler.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->handler.choices); - return platform_profile_register(&priv->handler); } diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 04a292af2bfc..a35453c3c605 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10538,9 +10538,19 @@ static int dytc_profile_set(struct platform_profile_handler *pprof, return err; } +static int dytc_profile_choices(struct platform_profile_handler *pprof) +{ + set_bit(PLATFORM_PROFILE_LOW_POWER, pprof->choices); + set_bit(PLATFORM_PROFILE_BALANCED, pprof->choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, pprof->choices); + + return 0; +} + static const struct platform_profile_ops dytc_profile_ops = { .profile_get = dytc_profile_get, .profile_set = dytc_profile_set, + .choices = dytc_profile_choices, }; static struct platform_profile_handler dytc_profile = { @@ -10584,11 +10594,6 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) { int err, output; - /* Setup supported modes */ - set_bit(PLATFORM_PROFILE_LOW_POWER, dytc_profile.choices); - set_bit(PLATFORM_PROFILE_BALANCED, dytc_profile.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, dytc_profile.choices); - err = dytc_command(DYTC_CMD_QUERY, &output); if (err) return err; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index a9db95bc360d..972a62be60b2 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -34,6 +34,7 @@ struct platform_profile_ops { enum platform_profile_option *profile); int (*profile_set)(struct platform_profile_handler *pprof, enum platform_profile_option profile); + int (*choices)(struct platform_profile_handler *pprof); }; struct platform_profile_handler { From patchwork Thu Jan 9 15:06:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 856010 Received: from mail-vs1-f45.google.com (mail-vs1-f45.google.com [209.85.217.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50E2B21C19F; Thu, 9 Jan 2025 15:08:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435297; cv=none; b=PrsqqRQmvQcbNICmTGngTIgUKn1JGcuZGUhPNE5F6wtO6XFMYd+WNCYDSo8EP4mf4wriIp8bEW3ot99FwJ0kJuvy3dPiyB+pyx88NtG9d5zz0yHVLxEZsllSq7u/e3WAvpk/3A6so4J2fGuZJFAEEcdWzb0uf49MBp7zDUqlEjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435297; c=relaxed/simple; bh=kwXBt4b3+q4Y39p8H6JPM3rIsgMPMUcZC/17KDplxYo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iJzuzOYvkVAwSboVYtBX7sQMmuEX2RsYhSb7KumKZZCjpj6t38txuALCzL5Nbr14yWJiL6BWhJZ7774qcIMNn+6/5KqqgMJ6XVv2sxNIQIo3TMc3X27CjR+U/cd56GWl84kbIaZIj4Hmj63pye2D6ZY7yohdjTpnbS7rEcA+S+4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DzeJ/puM; arc=none smtp.client-ip=209.85.217.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DzeJ/puM" Received: by mail-vs1-f45.google.com with SMTP id ada2fe7eead31-4b2c0a7ef74so656216137.2; Thu, 09 Jan 2025 07:08:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736435294; x=1737040094; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DKirfVfr3JrJ4phvSlQyJq6q5S3I1b+zwqhd331cro8=; b=DzeJ/puMoUjUzSPzdIaS8G2A0kD+rLVwo5gJur3s1Bep2GseSczmjXFH8dibH8RBp7 +bBYILCEYVtbJj7rbtmrvxzdzxwvlvswRw2y/Nd9+EBkAalMALvf/rd9h1au8ydDg5Rf hxP7iK7r9Lleof+2/ztWcnJHKC4jb9brh4KtLvIgfDHrCXcJAtNRTZaaY6gOW7GBe1+e p3lk/juuswDhug0815zfbrAZNkfz1gcdYNfK6icGgQwbVjkfBuwY06ICfoG13xbei0gW RSmu1vb2gFq2+6HL7B+8FHABEsDS3AOp72YGvzWWERKeXbiQQXLAqckJivrlgOkPgzGt 1I9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736435294; x=1737040094; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DKirfVfr3JrJ4phvSlQyJq6q5S3I1b+zwqhd331cro8=; b=PBSIwtB2bXAnHtt9eNTwjZGKmhNsxyzkCDyqkqfN41veSCs1wco0rf4WuoX5zwL/60 sb/vRBe//4HT736x2WOQm5P8Z1RTrk9fTm0984/oxhBOg8flpKjmHAXJmTNlGNnU1WNn INBsQUE2UZj8t1qnQArpB7dM7xPaC4nDwsjw7SR+oxjI37tgdPBTgN01XSxTAr/Yg39W fWlomgIRUT41OD3GGp9fXF6Exzd6dtmb+lEGYeQpibQthhlSjyajJ5F4Jo3P5um6irM0 ZzdKrDcnUeVkO0IRYZcaCopdZWWCnt83X4ijbsspz3nHlldQxzanMWG98aZ9xsbc3LR6 Rbkg== X-Forwarded-Encrypted: i=1; AJvYcCWjKTQacazykICa9NO+gAfSo+uBvgnMHhE7RUuL2F9zhhq4f6vHagiopUUP+giC3xkT21hrDw49biks@vger.kernel.org, AJvYcCX6SxIxVbzW8mr9lx6ouvSwCMSbhTZ822JJQvI5T4BauCadhN8M1SieInR4EPFI4U96uyrJupaW6YokU+MO@vger.kernel.org X-Gm-Message-State: AOJu0Yx9m2Ab4H5wc4Vxceu+Jo5hmBQ1OGUCDwmYpZLWLRKy6Dnbg4O2 5t9MhR6Lq9LnrnnAkSo9v0Ro538UBOUbf7i0bB9NMh1rr9WRZM3FaWxpJjGf X-Gm-Gg: ASbGncuElhgvpBD3iW1zzv38d8K3LyGXirDV+Sbc9aMdU4z31dz5DlhUef+Y32CaI2w Fd4ZIeBXOxSkxX1LEukb6i7XizGCyJD1PrlpM0fZ/xZu+dBhdyOi9WCmSkbTG5Mz617GxctaFT/ 9yiXSI0fYvSVtppEnqjYyyXCV56wcEyy7NLmtPfbm3jeb30Hi/ik/KbX21wxRXHvp1Knfn1ZpFx PJRSRO6bwhfelaASP1CCs6ugXKjawHbfPtYrdw6A0F44nCzdUTkH4vT4NwC9T76 X-Google-Smtp-Source: AGHT+IFJxb1VK/f6PtdkYvY/B1TzEVKdzi4rM/myKllQrpU6mJlwSpnWhlKays2Qs1u0wNVapOwGNQ== X-Received: by 2002:a05:6102:6e88:b0:4b4:27dc:ffe3 with SMTP id ada2fe7eead31-4b427dd0152mr4719591137.0.1736435294021; Thu, 09 Jan 2025 07:08:14 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4b608f4a5ddsm1019887137.11.2025.01.09.07.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 07:08:13 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , Joshua Grisham , "Derek J . Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , Kurt Borja , Maximilian Luz , "Lee, Chun-Yi" , Shyam Sundar S K , Corentin Chary , "Luke D. Jones" , Lyndon Sanche , Ike Panhc , Henrique de Moraes Holschuh , Mark Pearson , Colin Ian King , Alexis Belmonte , Ai Chao , Gergo Koteles , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH 04/18] ACPI: platform_profile: Let drivers set drvdata to the class device Date: Thu, 9 Jan 2025 10:06:17 -0500 Message-ID: <20250109150731.110799-5-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109150731.110799-1-kuurtb@gmail.com> References: <20250109150731.110799-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add *drvdata to platform_profile_register() signature and assign it to the class device. Signed-off-by: Kurt Borja --- drivers/acpi/platform_profile.c | 7 ++++--- drivers/platform/surface/surface_platform_profile.c | 2 +- drivers/platform/x86/acer-wmi.c | 2 +- drivers/platform/x86/amd/pmf/sps.c | 2 +- drivers/platform/x86/asus-wmi.c | 2 +- drivers/platform/x86/dell/alienware-wmi.c | 2 +- drivers/platform/x86/dell/dell-pc.c | 2 +- drivers/platform/x86/hp/hp-wmi.c | 2 +- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/platform/x86/inspur_platform_profile.c | 2 +- drivers/platform/x86/thinkpad_acpi.c | 2 +- include/linux/platform_profile.h | 4 ++-- 12 files changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 3cbde8dfed0b..5a867b912964 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -461,7 +461,7 @@ int platform_profile_cycle(void) } EXPORT_SYMBOL_GPL(platform_profile_cycle); -int platform_profile_register(struct platform_profile_handler *pprof) +int platform_profile_register(struct platform_profile_handler *pprof, void *drvdata) { int err; @@ -490,6 +490,7 @@ int platform_profile_register(struct platform_profile_handler *pprof) pprof->class_dev.class = &platform_profile_class; pprof->class_dev.parent = pprof->dev; + dev_set_drvdata(&pprof->class_dev, drvdata); dev_set_name(&pprof->class_dev, "platform-profile-%d", pprof->minor); err = device_register(&pprof->class_dev); if (err) @@ -537,7 +538,7 @@ static void devm_platform_profile_release(struct device *dev, void *res) platform_profile_remove(*pprof); } -int devm_platform_profile_register(struct platform_profile_handler *pprof) +int devm_platform_profile_register(struct platform_profile_handler *pprof, void *drvdata) { struct platform_profile_handler **dr; int ret; @@ -546,7 +547,7 @@ int devm_platform_profile_register(struct platform_profile_handler *pprof) if (!dr) return -ENOMEM; - ret = platform_profile_register(pprof); + ret = platform_profile_register(pprof, drvdata); if (ret) { devres_free(dr); return ret; diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index b69fcc4c3858..00a1178e552f 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -234,7 +234,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->has_fan = device_property_read_bool(&sdev->dev, "has_fan"); - return platform_profile_register(&tpd->handler); + return platform_profile_register(&tpd->handler, NULL); } static void surface_platform_profile_remove(struct ssam_device *sdev) diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 1fa0cd69da8c..585d54d8d80c 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1928,7 +1928,7 @@ static int acer_platform_profile_setup(struct platform_device *device) platform_profile_handler.ops = &acer_predator_v4_platform_profile_ops; - err = platform_profile_register(&platform_profile_handler); + err = platform_profile_register(&platform_profile_handler, NULL); if (err) return err; diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 37316bc3e071..8e75ebd25e21 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -425,7 +425,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) dev->pprof.ops = &amd_pmf_profile_ops; /* Create platform_profile structure and register */ - err = platform_profile_register(&dev->pprof); + err = platform_profile_register(&dev->pprof, NULL); if (err) dev_err(dev->dev, "Failed to register SPS support, this is most likely an SBIOS bug: %d\n", err); diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 3e94986078a6..248490571e8c 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3895,7 +3895,7 @@ static int platform_profile_setup(struct asus_wmi *asus) asus->platform_profile_handler.dev = dev; asus->platform_profile_handler.ops = &asus_wmi_platform_profile_ops; - err = platform_profile_register(&asus->platform_profile_handler); + err = platform_profile_register(&asus->platform_profile_handler, NULL); if (err == -EEXIST) { pr_warn("%s, a platform_profile handler is already registered\n", __func__); return 0; diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index 386b22e9c922..a8961de004ab 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1169,7 +1169,7 @@ static int create_thermal_profile(struct platform_device *platform_device) pp_handler.dev = &platform_device->dev; pp_handler.ops = &awcc_platform_profile_ops; - return devm_platform_profile_register(&pp_handler); + return devm_platform_profile_register(&pp_handler, NULL); } static int __init alienware_wmi_init(void) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index ba366c28d9a6..1b6e60a63491 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -281,7 +281,7 @@ static int thermal_init(void) thermal_handler->ops = &dell_pc_platform_profile_ops; /* Clean up if failed */ - ret = platform_profile_register(thermal_handler); + ret = platform_profile_register(thermal_handler, NULL); if (ret) goto cleanup_thermal_handler; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 3c2d4549eb7f..2cf1da00d5f9 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1652,7 +1652,7 @@ static int thermal_profile_setup(struct platform_device *device) platform_profile_handler.name = "hp-wmi"; platform_profile_handler.dev = &device->dev; - err = platform_profile_register(&platform_profile_handler); + err = platform_profile_register(&platform_profile_handler, NULL); if (err) return err; diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index f5ea03763a54..43e4d9d8d595 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1123,7 +1123,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) priv->dytc->pprof.ops = &dytc_profile_ops; /* Create platform_profile structure and register */ - err = platform_profile_register(&priv->dytc->pprof); + err = platform_profile_register(&priv->dytc->pprof, NULL); if (err) goto pp_reg_failed; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 8fa9308d4686..43cb2a927fdf 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -196,7 +196,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->handler.dev = &wdev->dev; priv->handler.ops = &inspur_platform_profile_ops; - return platform_profile_register(&priv->handler); + return platform_profile_register(&priv->handler, NULL); } static void inspur_wmi_remove(struct wmi_device *wdev) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index a35453c3c605..a72790cc5e0e 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10649,7 +10649,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) dytc_profile.dev = &tpacpi_pdev->dev; /* Create platform_profile structure and register */ - err = platform_profile_register(&dytc_profile); + err = platform_profile_register(&dytc_profile, NULL); /* * If for some reason platform_profiles aren't enabled * don't quit terminally. diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index f549067539af..cadbd3168d84 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -47,9 +47,9 @@ struct platform_profile_handler { const struct platform_profile_ops *ops; }; -int platform_profile_register(struct platform_profile_handler *pprof); +int platform_profile_register(struct platform_profile_handler *pprof, void *drvdata); int platform_profile_remove(struct platform_profile_handler *pprof); -int devm_platform_profile_register(struct platform_profile_handler *pprof); +int devm_platform_profile_register(struct platform_profile_handler *pprof, void *drvdata); int platform_profile_cycle(void); void platform_profile_notify(struct platform_profile_handler *pprof); From patchwork Thu Jan 9 15:06:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 856009 Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27E32215162; Thu, 9 Jan 2025 15:08:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435309; cv=none; b=oB/LqKRm/qgjFMiWXwhwRy3UVxpSz9LJCeuH5+/CywoxMq63e281g8fONTDtFb8qPfT98oAuZ2faz9VcMntp187JdYVB1LnLnIXd4rQ9Gmpk3O0wKVoKAWzlgGNYz+q88dj1uhsFZLeRs9H3w4H/yPVk7e8Mq3X8Ailwg0c7uXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435309; c=relaxed/simple; bh=KZeV286NRfqGS4NBEqA1eDQujyluseICOjJBryAdLCM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nvq4dfoCVguR+2EV1UgiKvlAVxu72jCUXx/HfTxVK3Xt0LD1bm5tnTV3MA8r1YCxknwKdCNIxKGSNTliSXWGfJul7eqDelngnnWGe0CJ7QoyQc9nHUeKr0WIvJRgVSuCAJwxeSVh+jV9sFQJR7tA0QY/14gAbw+OIlIfD537zC4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TPWDT8MM; arc=none smtp.client-ip=209.85.217.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TPWDT8MM" Received: by mail-vs1-f48.google.com with SMTP id ada2fe7eead31-4b11a110e4eso286345137.1; Thu, 09 Jan 2025 07:08:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736435306; x=1737040106; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=p1tUf+9DK9tMnD8L1mOJiRs8Bs/JKwc9KQrYpSk0By0=; b=TPWDT8MMrTPWRj4Gq3hnLg9u+Z8moFwI6UG1gGvxnvzB+urLpMeSO8OrUyIX8tyFY7 7a5o+i2ZJ9urmtiHtDFa6SN+ykJGDpstfjjy2phBR+1tU5d8nlLWwEi45iKOjqbb7S/N jz0VHX53raLAX1RElvL11+yxafi6M9HODgRxJlf9h4CW7LtAHsnYdV4BTV8DMy+UDEpY 8ZJyrlSOd2ep17JFw7ImsM8Wx3OmURhsqZdbACjOG/gecrPfUNAVESCHn7Y35Ra4Dpxw WC7RHwBos7lsE5xUv7FyJYeDZq98v9nbDGSKKut1Vixe/5QqGbxOGzkQ38QBJePls8fo 1Ulw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736435306; x=1737040106; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p1tUf+9DK9tMnD8L1mOJiRs8Bs/JKwc9KQrYpSk0By0=; b=agK31khi8ImJyBBvcHcnPIL1kjaxnBq8nw5AsDOEyIlnica45WLAKENNx3P7k1ZZ/8 ul2Kq1Ns5pIGUueWh4+UYB5RDqevy8RryyNRiPOStxpRI6oP2qa9TNTHjAuh+Bc0KTFG QNnKFrPbaTxsA9rJ1MEskuefCDBOnMOpW+Rk+WMg57gOl4N/k+8yx9MD4X1cvDwa1HgA RehMQdBqDWHQ24sbPvs7tXDpdwKLOFFkU7FerR9h8sEmIE63tJKYNKXZSM5Moo3VCwQF rUaczrYG9ujfAbICuL58tWS09U6mmLib4HR4tR5khn+awPAe/TyfIm9b2umQQ8KJ5490 E1rw== X-Forwarded-Encrypted: i=1; AJvYcCVhrbouPr3NC/O0JNgiGVLzBHKyylo7k4jvSDkrulBe3jf9bpY2DyP4F1qeFUXzIu2eunUEjsWiDnhoseUY@vger.kernel.org, AJvYcCWFCcWtaTdNrc0Wn2f6rWLwsanVGeLqpWLeNbF3BQLSpbazXOzNrDbBA8Ag48vIyGKjlegyaROSJJP4@vger.kernel.org X-Gm-Message-State: AOJu0YxS+GL6wsgjLS0iqbau4V2gWpE3XnOAnSIMkSgGA9jtXK/NoG0H gBNT4d9JoQFTL73cbxSp8VGTsJuQ5LTsLwW8E3jrqH1VxLAmgL6dQvrvWvgV X-Gm-Gg: ASbGncs9leUMrrFHBxtRBibFxyNLAEs/XMHoiyd7X5DrYMX21RMEEx2Yhr799HKAPeo A72eFNd8PWGFWruJl62oYU+f2Sri/7DilawrP0+3hp2cbVhZOZGZypYVh47fdNrIRmaBLbEijsy 5wyXT75DSo2p5UGSt8cPTm51EWK7IaMVQ0Jp+0ZxydyNTmp1ww01mozBcEpVPknkla5Ub3dHP4W 5a5uRkgtbqpa1eDywjOoYyojTJDG6I6v51K/DVNIc+kCh3V6IbHhA0t6wIjHbr9 X-Google-Smtp-Source: AGHT+IFjJvB65qdIOtwWFZNJWYdGw8KSgBVvzhl03AdUSd1avMwi0YmqB1FWOP7JvW3yslCDCjL6kQ== X-Received: by 2002:a05:6102:292b:b0:4b2:7446:fc18 with SMTP id ada2fe7eead31-4b3d0fb67bemr6267582137.17.1736435305836; Thu, 09 Jan 2025 07:08:25 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4b608f4a5ddsm1019887137.11.2025.01.09.07.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 07:08:25 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , Joshua Grisham , "Derek J . Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , Kurt Borja , Maximilian Luz , "Lee, Chun-Yi" , Shyam Sundar S K , Corentin Chary , "Luke D. Jones" , Lyndon Sanche , Ike Panhc , Henrique de Moraes Holschuh , Colin Ian King , Alexis Belmonte , Ai Chao , Mark Pearson , Gergo Koteles , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH 06/18] platform/x86: acer-wmi: Use devm_platform_profile_register() Date: Thu, 9 Jan 2025 10:06:19 -0500 Message-ID: <20250109150731.110799-7-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109150731.110799-1-kuurtb@gmail.com> References: <20250109150731.110799-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace platform_profile_register() with it's device managed version. Signed-off-by: Kurt Borja --- drivers/platform/x86/acer-wmi.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 585d54d8d80c..70ec667e0cbf 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1928,7 +1928,7 @@ static int acer_platform_profile_setup(struct platform_device *device) platform_profile_handler.ops = &acer_predator_v4_platform_profile_ops; - err = platform_profile_register(&platform_profile_handler, NULL); + err = devm_platform_profile_register(&platform_profile_handler, NULL); if (err) return err; @@ -2575,8 +2575,6 @@ static int acer_platform_probe(struct platform_device *device) return 0; error_hwmon: - if (platform_profile_support) - platform_profile_remove(&platform_profile_handler); error_platform_profile: acer_rfkill_exit(); error_rfkill: @@ -2597,9 +2595,6 @@ static void acer_platform_remove(struct platform_device *device) acer_backlight_exit(); acer_rfkill_exit(); - - if (platform_profile_support) - platform_profile_remove(&platform_profile_handler); } #ifdef CONFIG_PM_SLEEP From patchwork Thu Jan 9 15:06:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 856008 Received: from mail-vs1-f44.google.com (mail-vs1-f44.google.com [209.85.217.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69EEB21D018; Thu, 9 Jan 2025 15:08:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435321; cv=none; b=cj2okFT7GON7qWWgGRaPfkYyxdufJbtnSJTb6MuRQnlfX5woklNDx/SN3g4HqtY7V93uhDAp9az/BhgFgBokjmqlKj9obHeEtm46vsFq1eS93tskz6ePzgayEDlytrgTRseWUtNetjHEN8ZEffQC6jypHgA+vxHEmrVLi73aMOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435321; c=relaxed/simple; bh=vywDhdcsdLuqHYO3u64jCjCA/7sqHd8JsTiWODBy3Mk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kkrz3Wd5tkBY8V7x89AjUY85iXF+cZWjcGRTypy5Z5v8muceGlPo9nmf2A9rJBTwV1PFNkdaWfZfkpYXVDMRvibkqOa1OFRCyF61VEWLRlFH6FY5NE/haOExuifEP2H9Ws/FmpNO3sf6OIwhUnvt/6FWMA6m2PM7eLdMhAs5CWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kNj0v02p; arc=none smtp.client-ip=209.85.217.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kNj0v02p" Received: by mail-vs1-f44.google.com with SMTP id ada2fe7eead31-4b11a110e4eso286404137.1; Thu, 09 Jan 2025 07:08:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736435318; x=1737040118; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RpRy3dAZpB7RhV9HHTV4GtpVfyLmWse41E4e4Kgh7V0=; b=kNj0v02pIJPEKlul3AdQGYspain+7OkzLlcD4F/Hl9wGaO/3eCvuGkb/5kxlWiJdlM 3jOic+sqpfKbh8fkrR9H9e61KLQhiqBXN5p1J+kaoG5472hHa7d3tNa+4IWvwT28kTgF 4q+nvTn1wityZQDRtXQUtzWaUV+yIjmffy5kqyzLP91pBy57hHchmWchvqbxBnazUsqG PqwO/oRQXHXohYVM5BMW1MVqRbmXNLLUmm7sN9HBV49s7W7Tg/nZnyvVxVGZcRg31kuD Ail09xav8OpkSA2JaCdqyohTznW8yryp7iS/73ZZ87M69NXQPdpYidxriyn31jwmdKo7 IjoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736435318; x=1737040118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RpRy3dAZpB7RhV9HHTV4GtpVfyLmWse41E4e4Kgh7V0=; b=Xr46NUjvaXgGJiuVhV89a5fQTzsOTN+K2Q388VdeNmv4KwrjE4ETSIIFIhC1ZZaY5X n+LqYsB36YgU/0UNE9cgcWrEUj0y7CKtAwYEOIZFDueQKhbndQ6v9hizW8KzuKlYg6/9 /gMU8/oO3G2MoGNUWUDl41tG1PQA3+Y/QQorzDGh/SHlxGPdkEgNOv4hzI1YDaCNJLaE Z475n6xaTDvHwQLB7raa8zZEPbLdsq3ScrT06uoQvdJ4CHwDNhkEOvU97Hc5q3BiDVfp CzAkBc7UPFYDiapourzwjAyDI+aKZW/BNuKgRFZbP7W4GBtB31NCvDRn8QnvxAQWYhAe 79Dw== X-Forwarded-Encrypted: i=1; AJvYcCUc/NBLe+bpxN5tINQ7Wcsn6feVheepEg0PnRbrHlKSG1l21V3FrPd+JHgEad2RyBJquUAb5Uhd3o+iTBZe@vger.kernel.org, AJvYcCVydZWN9hNrXnATsp4GkELauUvs4sQmLa03WYCdZ8WI85HWnY1Zq4Yz3LO5iPhwsXh627Jk+0A3ocWw@vger.kernel.org X-Gm-Message-State: AOJu0Ywj7B+mnQdN0OulU3lB49LsrIXQbVj9RgvGQJ2t3lwnypZMhcET Jmg9AO+KIiOW++aAtmMJ+9Pb4V5v+c+SlvlYcbL2vEFk6qLIzAgxM/4ypLCj X-Gm-Gg: ASbGncuG4CurNPCTWltHWK/6qkLJWXe/nzRYjPzz8E7oO7I6YiVr3z+bhQjSORjEn7H FDFvKcBZNeQhg8aoT5KEd5woANzy7MXkez42vMaaM9/47u27K7ljhWkJwbm3x4KtVA2Yjy0xyL0 /Nh9Do75bJ/z4t4U5mGsIjBzM9Komh6ZZWZUiGuMrK2aW8vyrbkZVCHgOT+DU2x47M5xG9AFUAr VmNlP4JClhm6GXARhPmxXSMuZqEFXvcAneaEyEPAHGkNr23XyF3bAAuRn6qDHH9 X-Google-Smtp-Source: AGHT+IGR/+CwNsQKCyZVv7L7iExfv3QE2DSqFOuBUmkY3DxOHBohtIkPAje8Sxp/ioTZav30tJeQOg== X-Received: by 2002:a05:6102:32c7:b0:4b2:5d10:2cc6 with SMTP id ada2fe7eead31-4b3d0ee5017mr5660651137.6.1736435317983; Thu, 09 Jan 2025 07:08:37 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4b608f4a5ddsm1019887137.11.2025.01.09.07.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 07:08:37 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , Joshua Grisham , "Derek J . Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , Kurt Borja , Maximilian Luz , "Lee, Chun-Yi" , Shyam Sundar S K , Corentin Chary , "Luke D. Jones" , Lyndon Sanche , Ike Panhc , Henrique de Moraes Holschuh , Mark Pearson , Colin Ian King , Alexis Belmonte , Ai Chao , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Gergo Koteles , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH 08/18] platform/x86: asus-wmi: Use devm_platform_profile_register() Date: Thu, 9 Jan 2025 10:06:21 -0500 Message-ID: <20250109150731.110799-9-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109150731.110799-1-kuurtb@gmail.com> References: <20250109150731.110799-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace platform_profile_register() with it's device managed version. While at it, pass asus_wmi to the class device as drvdata and replace uses of container_of() with dev_get_drvdata(). Signed-off-by: Kurt Borja --- drivers/platform/x86/asus-wmi.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 248490571e8c..5c7099dc6109 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3806,7 +3806,7 @@ static int asus_wmi_platform_profile_get(struct platform_profile_handler *pprof, struct asus_wmi *asus; int tp; - asus = container_of(pprof, struct asus_wmi, platform_profile_handler); + asus = dev_get_drvdata(&pprof->class_dev); tp = asus->throttle_thermal_policy_mode; switch (tp) { @@ -3832,7 +3832,7 @@ static int asus_wmi_platform_profile_set(struct platform_profile_handler *pprof, struct asus_wmi *asus; int tp; - asus = container_of(pprof, struct asus_wmi, platform_profile_handler); + asus = dev_get_drvdata(&pprof->class_dev); switch (profile) { case PLATFORM_PROFILE_PERFORMANCE: @@ -3895,12 +3895,12 @@ static int platform_profile_setup(struct asus_wmi *asus) asus->platform_profile_handler.dev = dev; asus->platform_profile_handler.ops = &asus_wmi_platform_profile_ops; - err = platform_profile_register(&asus->platform_profile_handler, NULL); + err = devm_platform_profile_register(&asus->platform_profile_handler, asus); if (err == -EEXIST) { pr_warn("%s, a platform_profile handler is already registered\n", __func__); return 0; } else if (err) { - pr_err("%s, failed at platform_profile_register: %d\n", __func__, err); + pr_err("%s, failed at devm_platform_profile_register: %d\n", __func__, err); return err; } @@ -4859,8 +4859,6 @@ static int asus_wmi_add(struct platform_device *pdev) fail_sysfs: fail_custom_fan_curve: fail_platform_profile_setup: - if (asus->platform_profile_support) - platform_profile_remove(&asus->platform_profile_handler); fail_fan_boost_mode: fail_platform: kfree(asus); @@ -4886,9 +4884,6 @@ static void asus_wmi_remove(struct platform_device *device) throttle_thermal_policy_set_default(asus); asus_wmi_battery_exit(asus); - if (asus->platform_profile_support) - platform_profile_remove(&asus->platform_profile_handler); - kfree(asus); } From patchwork Thu Jan 9 15:06:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 856007 Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C9672206AE; Thu, 9 Jan 2025 15:08:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435334; cv=none; b=vA3VrkVWg/hUe0PWlqdRRP8zwqtgd2QdwwNb493ePNVBZ/r3uGZv0u63BNqquTxk9D/ls6EWmaAthvrqMD4tHYFgIqqrKmQdDM40lEHxtMFpnxh/uKJWvBfGpEhpkxhgQ8Kv5hmOOYqBukh8WTGRuq+VCC0nxZ83BiaMtCiV6xs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435334; c=relaxed/simple; bh=+pQFibEAjx3fhuHAJNt/J0bsuHSnnAYKNMWP2WmQ4uo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O8ZthmI8UTAOKW4trUnlCX3chqifN/kHVVPiWHxzgHFmpOPGH2FjsSrsArHAXjOnzsp5KyeffyK8oFDNfhFf+u4uRymhetf/R9Lvq5ZIkfA/VA0HZjkvpbz1SBEyIh9dwwDWSROrVfh7HZpV/nuXSLOsfM9ZA02/2QpTxbosKr8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=g9LZ29SD; arc=none smtp.client-ip=209.85.217.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g9LZ29SD" Received: by mail-vs1-f48.google.com with SMTP id ada2fe7eead31-4afd56903b7so359944137.1; Thu, 09 Jan 2025 07:08:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736435331; x=1737040131; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vjDgxfYVgerBzLzfq9ijJVLGFXFEgkBOlqWQa/hqQF0=; b=g9LZ29SD5SiYsTCo7vvISWBXrLBVc7H6GMsfpiuPuwPY+zv+AjvG3ycc6rykUD+zIH sd/TG/qEkDi8wRWr2s9ftvL86OQvhQINzVHi1x46mIgz/aES0YRXjWRqW3nFCcFdRxiI U2SrMGBVyD0M9C+y2yX7o7RHzEBDf+kWr6+bcjO2YfwZzYob75aLyvWfGyaF5G1afGkM F0EaobzXc1BFaRU2o1+6gRFTrWr9Bx+ryAdkuBxfULpIbjJQ+36WyXR8NNBFqjsciHXi 1VEErVsot4KE1qn3npKmqpRzkXrD6rGw8c+EkNmFCfnPvRwiIReEofiSx0k5/rs29GHh 8+qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736435331; x=1737040131; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vjDgxfYVgerBzLzfq9ijJVLGFXFEgkBOlqWQa/hqQF0=; b=dm9yeZkEsvEGr+oRiE7V9W7Z6E2j3F9azpgBY3yotWNU1nZAD9VnnbtiF5SM4enx94 NxA7g7LhyyZt4gdz42youSz7PWQAV1FFlkFnPNEvzTYwuVYwYV3NiU3MS1W2wQFx1hV1 DJczCkIqkAyfRZVLHqNUKZsWl0CMCsQjmZq95un+QIB+wFuBDHPY9s3DOBwQm7s1YY0n yTIMaerec/hYtwbKqrAvWqXZ+LyC9sWbbYluknngLfqcceUBALwSVclH0AEH+TmcvlO+ yFRUJsYryT0j4TuBbsa+7h7MpogfggyWvGkEDd3MZWIbJXgcnKY+0n8gYFP+e7cY/qWg dHGQ== X-Forwarded-Encrypted: i=1; AJvYcCVN9Ktq0OrzksESUj4Omg75frsOLyTDVRgzOH6sE3UaytMyjTnO/a9v84fe35L/hH7jshlGmWrMBHMW@vger.kernel.org, AJvYcCWTF6R4UGfQ6jcBbTTvR3PpOKcqgpcOB4VlsWu9i9XTz1mkNskiTyavoy839Mckfj2ZUm2FGmmT2dfykSJV@vger.kernel.org X-Gm-Message-State: AOJu0Yw3zn40Qjrxl4cWiks9gxh6n0DGSXD7u0JU+jVVDsjV8M7GwBGe fmx0fVL+XRCys0VJqjUYeRvrsc87fGV6ac19BbCcV8buB0EHHrfIRfbgJQbS X-Gm-Gg: ASbGnctoFHBli4rL/st90A+C0jgIGc+7dBPS4mafzWByL05nQWRY7G0aNLtG5aBbLTM UOSJnUCsrYJTFPPJyBWPKAiaL3//A6O6yUD+jDPhcuw7pzJbLBJZ9ONK1JQlnJ+7s2JMTk52w+J S293BpVfuS+aE/S7u6NcNkc0JyDy2sbzGwjgBYzEzYkwYAZTFgfKxx0pYABxPfX4YNqiD85WDXH OYwHHSbvS/zJUIXNDoYumKYxREaASRSVGSJ+1kKDnYT3IgF1dIT2MxFr6s6fwRC X-Google-Smtp-Source: AGHT+IE3OpgIgY8w4vOlfqAoadsrw3xphaYjGr34L9DX9hWpRlW1LEhdiSl+3kVD1AlwTW6vgUuw+Q== X-Received: by 2002:a05:6102:50a5:b0:4b1:ed1:56ac with SMTP id ada2fe7eead31-4b3d0dd7df6mr6395494137.12.1736435330794; Thu, 09 Jan 2025 07:08:50 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4b608f4a5ddsm1019887137.11.2025.01.09.07.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 07:08:50 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , Joshua Grisham , "Derek J . Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , Kurt Borja , Maximilian Luz , "Lee, Chun-Yi" , Shyam Sundar S K , Corentin Chary , "Luke D. Jones" , Lyndon Sanche , Ike Panhc , Henrique de Moraes Holschuh , Colin Ian King , Alexis Belmonte , Mark Pearson , Ai Chao , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Gergo Koteles , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH 10/18] platform/x86: ideapad-laptop: Use devm_platform_profile_register() Date: Thu, 9 Jan 2025 10:06:23 -0500 Message-ID: <20250109150731.110799-11-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109150731.110799-1-kuurtb@gmail.com> References: <20250109150731.110799-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace platform_profile_register() with it's device managed version. While at it, pass ideapad_dytc_priv to the class device as drvdata and replace uses of container_of() with dev_get_drvdata(). Signed-off-by: Kurt Borja --- drivers/platform/x86/ideapad-laptop.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 43e4d9d8d595..d34d565172f5 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -936,7 +936,7 @@ static int convert_profile_to_dytc(enum platform_profile_option profile, int *pe static int dytc_profile_get(struct platform_profile_handler *pprof, enum platform_profile_option *profile) { - struct ideapad_dytc_priv *dytc = container_of(pprof, struct ideapad_dytc_priv, pprof); + struct ideapad_dytc_priv *dytc = dev_get_drvdata(&pprof->class_dev); *profile = dytc->current_profile; return 0; @@ -989,7 +989,7 @@ static int dytc_cql_command(struct ideapad_private *priv, unsigned long cmd, static int dytc_profile_set(struct platform_profile_handler *pprof, enum platform_profile_option profile) { - struct ideapad_dytc_priv *dytc = container_of(pprof, struct ideapad_dytc_priv, pprof); + struct ideapad_dytc_priv *dytc = dev_get_drvdata(&pprof->class_dev); struct ideapad_private *priv = dytc->priv; unsigned long output; int err; @@ -1123,7 +1123,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) priv->dytc->pprof.ops = &dytc_profile_ops; /* Create platform_profile structure and register */ - err = platform_profile_register(&priv->dytc->pprof, NULL); + err = devm_platform_profile_register(&priv->dytc->pprof, &priv->dytc); if (err) goto pp_reg_failed; @@ -1145,7 +1145,6 @@ static void ideapad_dytc_profile_exit(struct ideapad_private *priv) if (!priv->dytc) return; - platform_profile_remove(&priv->dytc->pprof); mutex_destroy(&priv->dytc->mutex); kfree(priv->dytc); From patchwork Thu Jan 9 15:06:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 856006 Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com [209.85.217.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10CF221CFFB; Thu, 9 Jan 2025 15:09:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435348; cv=none; b=jFzhdAPeoHbEN6DGNWvCShJP93eRYxd7c4KiZSJsbfcU5AR86fvnAHUc+v1GdLIAtgxSnQ+s3vfaw7U2+5xFRQIhITlsttYJQRDcOpQmdKYOIjkQJLvh7GNu6LjGusPiRTVA4XiSRlqU4EbB7m9doG6q3kzWTMIsvRVcUM6GQ14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435348; c=relaxed/simple; bh=qLNpxdQHmr4FUi3kZDQjLaRkVRppkBFUeext+V90VxM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tkm/sqmx9nxLy+MTtQztqod0elWuteCItEujREWT+wCNcYPJg8KfMAI52gsjzOt6HkiYYWYGhyJ0KPmI3cuTjqhY8kCIl51Bi2STWTywK48L6beG2jxDUGlD05MFFHNZ5zD21OPEItNvBYcNCdsBg5Qp55VdhCkHiYMwuWvyvck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aj7YboJF; arc=none smtp.client-ip=209.85.217.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aj7YboJF" Received: by mail-vs1-f47.google.com with SMTP id ada2fe7eead31-4afed12283eso781444137.1; Thu, 09 Jan 2025 07:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736435344; x=1737040144; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=re4+pG1FRpqOGyXJCRSQNyItv7j72+FDLGCOtmj2Lig=; b=aj7YboJFSTP5uhfB+vzM6kdlLnZhY0vmRgcKTyw0dSTrd402k+9skMr9qiJZn2hxQ4 08Jf9ZasqkSPfaEN7M7EH4Wt9UlJljx5l3fiQXs+m//K6vW8VaGEqlL2Ldrzbc3uU/jE 8pJQpMsUIaLLQ2MGx8fDm6cHYDHcXtAsArGw7CV2AnKc5j5gzrP3lnbGVpaM6VACY3av Zrvhd2nDvVCG9XHm9bKvMfy03LArWl24mOnh6gHVF5AtDkDUw5XMeTov9BO1VbatJaqo RfyytwtBL9ubMdLHeZzRz0EEZ0/v0FZC0zzBUvQfqbRagEUyC2S+zj2nQNTvtr0wI5F1 fLXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736435344; x=1737040144; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=re4+pG1FRpqOGyXJCRSQNyItv7j72+FDLGCOtmj2Lig=; b=Bx0okKaLsfACGrsrd/9dSTKKrpvWNcL1uV+prVfMRZNd9Tb8yRwqUGQf5OJ2o0FFFQ dIu5C+ae6ys7oHe9Bn/Cta7td6M5VLpXcoULo2xgaZRkxsZ/mAU5KQe7NFfNyKLgd0nQ SjeFrKFeFCzbP+VKeLxzsAgeMitOCuTRMcYXZPPv1lwrRsB8oq9XXIrhtwqj9gzPvMIb GV3XpVqlv6kt9QqfOdNtZqtbBpqgXB3vPGaSMljjQmC5BcXpopy0IGVuYikRluhQOQaJ 16NAegezHFITR+PkdWMFrQPaK8KW8hYJpKvWuP5fv3g+u48AWZ1CGxJhQ0QHdT0++Xe/ YEjA== X-Forwarded-Encrypted: i=1; AJvYcCUlUZ04O1kWaAVJI1QT2AFwkx7ed4NMYxAQk5HKAu6bCIT6p86djvAvdynb1sJVuBSTPdPUTFggCRxptwnF@vger.kernel.org, AJvYcCXSAEo7nsVS4pkO7GweDI4sV+9DdK1avQWmnVsG0QCmfu3s12Q7ig47CQ1uFkV4LGGEROXoYvXP9yF+@vger.kernel.org X-Gm-Message-State: AOJu0YxBytdwSdRFATJp6X+xvWFCHy8+z/QvEkwFnbOvwq4zrBDiQ64u N57NOn4flpUOsGxH9PXfEvwNjd5sinfWquLhhRrdl85owF6slp3trxkIcuOd X-Gm-Gg: ASbGncvQL5+0aKXGa+H4wd3gbvsNEJRaE3rlILqmSUm3YVrsK6/5OSDUB2pUfVHpajD ez7IOQlkDBXxGr9lIvoeJCIRuMMa62R1WYE8quffyKVDHxawLyQJXPtTnUhmDMe7cduMOccNkyg myUC88ppjane7P6Pfjit3k5qZeZoHXEn12aQJdeyKBD2OFfEskbNgT30AesUNQrINNKB9feUWuw vLKIapwWsRHTbqnl1Mn0upRt79YfrIFlLbBkSxkjZiU1RrN8rqBz2XTnJQMuUjh X-Google-Smtp-Source: AGHT+IEujRA0A36aLkuS6cpy6MKnOsgT8lfTISL9cm4bumoexauwj4sgzoivPoOWFQM+FXLk+rZ+Tg== X-Received: by 2002:a05:6102:440d:b0:4b1:1a11:9628 with SMTP id ada2fe7eead31-4b3d0eb96c5mr5449671137.24.1736435343867; Thu, 09 Jan 2025 07:09:03 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4b608f4a5ddsm1019887137.11.2025.01.09.07.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 07:09:03 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , Joshua Grisham , "Derek J . Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , Kurt Borja , Maximilian Luz , "Lee, Chun-Yi" , Shyam Sundar S K , Corentin Chary , "Luke D. Jones" , Lyndon Sanche , Ike Panhc , Henrique de Moraes Holschuh , Mark Pearson , Colin Ian King , Alexis Belmonte , Ai Chao , Gergo Koteles , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH 12/18] platform/x86: inspur_platform_profile: Use devm_platform_profile_register() Date: Thu, 9 Jan 2025 10:06:25 -0500 Message-ID: <20250109150731.110799-13-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109150731.110799-1-kuurtb@gmail.com> References: <20250109150731.110799-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace platform_profile_register() with it's device managed version. While at it, pass inspur_wmi_priv to the class device as drvdata and replace uses of container_of() with dev_get_drvdata(). Signed-off-by: Kurt Borja --- drivers/platform/x86/inspur_platform_profile.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 43cb2a927fdf..543e4bce1a57 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -87,8 +87,7 @@ static int inspur_wmi_perform_query(struct wmi_device *wdev, static int inspur_platform_profile_set(struct platform_profile_handler *pprof, enum platform_profile_option profile) { - struct inspur_wmi_priv *priv = container_of(pprof, struct inspur_wmi_priv, - handler); + struct inspur_wmi_priv *priv = dev_get_drvdata(&pprof->class_dev); u8 ret_code[4] = {0, 0, 0, 0}; int ret; @@ -135,8 +134,7 @@ static int inspur_platform_profile_set(struct platform_profile_handler *pprof, static int inspur_platform_profile_get(struct platform_profile_handler *pprof, enum platform_profile_option *profile) { - struct inspur_wmi_priv *priv = container_of(pprof, struct inspur_wmi_priv, - handler); + struct inspur_wmi_priv *priv = dev_get_drvdata(&pprof->class_dev); u8 ret_code[4] = {0, 0, 0, 0}; int ret; @@ -196,15 +194,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->handler.dev = &wdev->dev; priv->handler.ops = &inspur_platform_profile_ops; - return platform_profile_register(&priv->handler, NULL); -} - -static void inspur_wmi_remove(struct wmi_device *wdev) -{ - struct inspur_wmi_priv *priv; - - priv = dev_get_drvdata(&wdev->dev); - platform_profile_remove(&priv->handler); + return devm_platform_profile_register(&priv->handler, priv); } static const struct wmi_device_id inspur_wmi_id_table[] = { @@ -221,7 +211,6 @@ static struct wmi_driver inspur_wmi_driver = { }, .id_table = inspur_wmi_id_table, .probe = inspur_wmi_probe, - .remove = inspur_wmi_remove, .no_singleton = true, }; From patchwork Thu Jan 9 15:06:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 856005 Received: from mail-vs1-f43.google.com (mail-vs1-f43.google.com [209.85.217.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6FC921C9F1; Thu, 9 Jan 2025 15:09:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435361; cv=none; b=E+Eic/uh1H4gd9ThIblIG0wSbIo7swzTOKDM701f4YFhuIztYqhdxwp3ZT8RIWbdAVjJjzCDJ7W2Vtry6UF3Un0IF+pF6wGmANMX8ffI5wI60XHzZz+ITKmreUWoSeLbEeitlJKoV88eHbnUKbR4KFqMTvC1uuqVOLJK+WSL2Ow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435361; c=relaxed/simple; bh=3iJGuulPAYHJM2VGs5Cig15HMex4vup9V3Jh9EOnmSM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ub9ElN5WADa1FPEMGThqhcBiG7q4FjPyq2D4dK40kAO3tbqYISI4WPmAhdnUA6qCHEhLQycu2e008GD8HebtqlM5+99H2Oj5M0MVxUqswj6cFMHAgWtZg41l9620ViSAbz6toRtg6+QJA4RvnsimF5kjKF43nZXyue5rkMuqh7Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LX0AJALi; arc=none smtp.client-ip=209.85.217.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LX0AJALi" Received: by mail-vs1-f43.google.com with SMTP id ada2fe7eead31-4aff31b77e8so427660137.1; Thu, 09 Jan 2025 07:09:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736435357; x=1737040157; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=N0XNXY/JMeEK+RY7wfbv5qEFmZNkd0qCHPSEjoe+4/U=; b=LX0AJALiMEzIsYbT0Uc1o2SitTPhRJiSiqRFCrg2o9KVY4NreOO1Vqw6th9ambox9r VjYTkX13Xps/TV1z3aPhQBz5tYP++ztnxrv+T2rqSbCyxPFtc40FXuLOrgShHWup3aYo vE5b9izcM2hVW87HDoRiJRzis5ojwy9b8sEERhpPNHxdAnfI/2bpAi/sAd7DuWlCBriB MT/p3tYt9GtCBLdecFfWgG1fY9EXuS2dCY1Q1ThAMEjvreI4DqU++pF2CETtbzpOSJtv u65bchcUAiwE61BrRNJ0ld2a1czF6Y0YshvbJ/+niDVPLlQPaIgVntyjwbClRyPQ/avu t/VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736435357; x=1737040157; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N0XNXY/JMeEK+RY7wfbv5qEFmZNkd0qCHPSEjoe+4/U=; b=rAdKj/cXFbesTHUS1GTMIyCxxMmMAYERo3VxuhheNzq+xd2J2qoNb/6/DEmjGgxZT8 e33aRgaqsBOG1QD1En9fD4Hj8QFJODYFk5uPBhLhv4bdtbzqL5Rm8kjc0YJCwk0cNC4P 9OpDCkHDL6AIjxiIz5oyX+BYDfoGZ6F5+fakDtG0/8ahKv8CsRfsot4F6RamV29uNs1c dmYuG9LuZFNAWnx+2iRRc/hQPNNG6MqAj8wy6j9qbJ7hrwkbCPa9xgMPnCf9B5tPqhBM 9ypNJQ5ugmr88J2xqI/Y+Q88NVgRN56mVrMPbRx0t7wQsqvI+IxP2flX2Qv9rHNX+pmC xtqg== X-Forwarded-Encrypted: i=1; AJvYcCULwvZXkWvw8FPCPaQwNIFLyOfG9PHiobT2FSX4C0L0JaZItvdHHIN+J2qjWzIpfco5kJ5Uu3v6ZWSZ@vger.kernel.org, AJvYcCV2CSkkLiwXM1xXKDK8pSXs7XioJ+LBjuWKHB+j0b0n4MhZepadTJD2XIeqsaOi0U/PdD+1CTEun07135fv@vger.kernel.org X-Gm-Message-State: AOJu0YyhZykQRyLCDmX+wP5jKhy7BUf6ZoteaJy575mN2LIBubxEMVNy XuGq77fRaGvqk02nZD/8JsdpeOBg7mYQZ1NMIN2x5VTYfjFq/z1/ckhurG6W X-Gm-Gg: ASbGncvBRP43Ue9qfPr53O2chGEl4ow21o5sM3sWFw3380ZTUqwspaKKL6u31kbnL7x op/sxM45jE7D+sK03tOR171SME2ujKTZcd+rhdw0J5LeZpJEXrxYKHFOcIORkwNNMcoaea4uPlW sa02QQTGBGIya0qYDpwrx6J51d5P58rkgpi2b5E5ayQlwLK3KtBk54S8q7WdJAyWELxkjKyZRae C0NyNDq2neIc1hXUWxIF23os4Ea/6oi59i5mpgbq8UAv1S4Rqp3RTpAQuICKa7T X-Google-Smtp-Source: AGHT+IFgH3W/KdvqRrNrwfpOOUxIGtaWXK9uZdSbZkYvIWAKPZKw6IJ4yfSisxYpkg28GcoPU0ipZA== X-Received: by 2002:a05:6102:290e:b0:4b0:49ba:8278 with SMTP id ada2fe7eead31-4b3d0ff5da9mr6050866137.25.1736435357192; Thu, 09 Jan 2025 07:09:17 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4b608f4a5ddsm1019887137.11.2025.01.09.07.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 07:09:16 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , Joshua Grisham , "Derek J . Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , Kurt Borja , Maximilian Luz , "Lee, Chun-Yi" , Shyam Sundar S K , Corentin Chary , "Luke D. Jones" , Lyndon Sanche , Ike Panhc , Henrique de Moraes Holschuh , Mark Pearson , Colin Ian King , Alexis Belmonte , Ai Chao , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Gergo Koteles , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH 14/18] ACPI: platform_profile: Remove platform_profile_handler from exported symbols Date: Thu, 9 Jan 2025 10:06:27 -0500 Message-ID: <20250109150731.110799-15-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109150731.110799-1-kuurtb@gmail.com> References: <20250109150731.110799-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In order to protect the platform_profile_handler from API consumers, allocate it in platform_profile_register() and modify it's signature accordingly. Remove the platform_profile_handler from all consumer drivers and replace them with a pointer to the class device, which is now returned from platform_profile_register(). Replace *pprof with a pointer to the class device in the rest of exported symbols. Signed-off-by: Kurt Borja --- drivers/acpi/platform_profile.c | 93 ++++++++++++------- .../surface/surface_platform_profile.c | 11 +-- drivers/platform/x86/acer-wmi.c | 18 ++-- drivers/platform/x86/amd/pmf/pmf.h | 2 +- drivers/platform/x86/amd/pmf/sps.c | 15 +-- drivers/platform/x86/asus-wmi.c | 17 ++-- drivers/platform/x86/dell/alienware-wmi.c | 10 +- drivers/platform/x86/dell/dell-pc.c | 22 ++--- drivers/platform/x86/hp/hp-wmi.c | 19 ++-- drivers/platform/x86/ideapad-laptop.c | 14 +-- .../platform/x86/inspur_platform_profile.c | 9 +- drivers/platform/x86/thinkpad_acpi.c | 14 +-- include/linux/platform_profile.h | 12 ++- 13 files changed, 131 insertions(+), 125 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 5a867b912964..fdf79b81b62e 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -3,6 +3,7 @@ /* Platform profile sysfs interface */ #include +#include #include #include #include @@ -213,9 +214,17 @@ static struct attribute *profile_attrs[] = { }; ATTRIBUTE_GROUPS(profile); +static void pprof_device_release(struct device *dev) +{ + struct platform_profile_handler *pprof = to_pprof_handler(dev); + + kfree(pprof); +} + static const struct class platform_profile_class = { .name = "platform-profile", .dev_groups = profile_groups, + .dev_release = pprof_device_release, }; /** @@ -409,10 +418,10 @@ static const struct attribute_group platform_profile_group = { .is_visible = profile_class_is_visible, }; -void platform_profile_notify(struct platform_profile_handler *pprof) +void platform_profile_notify(struct device *dev) { scoped_cond_guard(mutex_intr, return, &profile_lock) { - _notify_class_profile(&pprof->class_dev, NULL); + _notify_class_profile(dev, NULL); } sysfs_notify(acpi_kobj, NULL, "platform_profile"); } @@ -461,40 +470,57 @@ int platform_profile_cycle(void) } EXPORT_SYMBOL_GPL(platform_profile_cycle); -int platform_profile_register(struct platform_profile_handler *pprof, void *drvdata) +struct device *platform_profile_register(struct device *dev, const char *name, + void *drvdata, + const struct platform_profile_ops *ops) { + struct device *ppdev; + int minor; int err; - /* Sanity check the profile handler */ - if (!pprof || !pprof->ops->profile_set || !pprof->ops->profile_get || - !pprof->ops->choices) { + /* Sanity check */ + if (!dev || !name || !ops || !ops->profile_get || + !ops->profile_set || !ops->choices) { pr_err("platform_profile: handler is invalid\n"); - return -EINVAL; + return ERR_PTR(-EINVAL); } - err = pprof->ops->choices(pprof); + struct platform_profile_handler *pprof __free(kfree) = kzalloc( + sizeof(*pprof), GFP_KERNEL); + if (!pprof) + return ERR_PTR(-ENOMEM); + + err = ops->choices(pprof); if (err < 0) - return err; + return ERR_PTR(err); if (bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST)) { pr_err("platform_profile: no available profiles\n"); - return -EINVAL; + return ERR_PTR(-EINVAL); } guard(mutex)(&profile_lock); /* create class interface for individual handler */ - pprof->minor = ida_alloc(&platform_profile_ida, GFP_KERNEL); - if (pprof->minor < 0) - return pprof->minor; + minor = ida_alloc(&platform_profile_ida, GFP_KERNEL); + if (minor < 0) + return ERR_PTR(minor); + pprof->name = name; + pprof->ops = ops; + pprof->minor = minor; pprof->class_dev.class = &platform_profile_class; - pprof->class_dev.parent = pprof->dev; + pprof->class_dev.parent = dev; dev_set_drvdata(&pprof->class_dev, drvdata); dev_set_name(&pprof->class_dev, "platform-profile-%d", pprof->minor); err = device_register(&pprof->class_dev); - if (err) + if (err) { + put_device(&no_free_ptr(pprof)->class_dev); goto cleanup_ida; + } + + /* After this point, device_unregister will free pprof on error */ + ppdev = &no_free_ptr(pprof)->class_dev; sysfs_notify(acpi_kobj, NULL, "platform_profile"); @@ -502,20 +528,21 @@ int platform_profile_register(struct platform_profile_handler *pprof, void *drvd if (err) goto cleanup_cur; - return 0; + return ppdev; cleanup_cur: - device_unregister(&pprof->class_dev); + device_unregister(ppdev); cleanup_ida: - ida_free(&platform_profile_ida, pprof->minor); + ida_free(&platform_profile_ida, minor); - return err; + return ERR_PTR(err); } EXPORT_SYMBOL_GPL(platform_profile_register); -int platform_profile_remove(struct platform_profile_handler *pprof) +int platform_profile_remove(struct device *dev) { + struct platform_profile_handler *pprof = to_pprof_handler(dev); int id; guard(mutex)(&profile_lock); @@ -533,30 +560,32 @@ EXPORT_SYMBOL_GPL(platform_profile_remove); static void devm_platform_profile_release(struct device *dev, void *res) { - struct platform_profile_handler **pprof = res; + struct device **ppdev = res; - platform_profile_remove(*pprof); + platform_profile_remove(*ppdev); } -int devm_platform_profile_register(struct platform_profile_handler *pprof, void *drvdata) +struct device *devm_platform_profile_register(struct device *dev, const char *name, + void *drvdata, + const struct platform_profile_ops *ops) { - struct platform_profile_handler **dr; - int ret; + struct device *ppdev; + struct device **dr; dr = devres_alloc(devm_platform_profile_release, sizeof(*dr), GFP_KERNEL); if (!dr) - return -ENOMEM; + return ERR_PTR(-ENOMEM); - ret = platform_profile_register(pprof, drvdata); - if (ret) { + ppdev = platform_profile_register(dev, name, drvdata, ops); + if (IS_ERR(dev)) { devres_free(dr); - return ret; + return ppdev; } - *dr = pprof; - devres_add(pprof->dev, dr); + *dr = ppdev; + devres_add(dev, dr); - return 0; + return ppdev; } EXPORT_SYMBOL_GPL(devm_platform_profile_register); diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index efb6653ed1d5..965940223892 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -40,7 +40,7 @@ struct ssam_tmp_profile_info { struct ssam_platform_profile_device { struct ssam_device *sdev; - struct platform_profile_handler handler; + struct device *ppdev; bool has_fan; }; @@ -228,13 +228,12 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->sdev = sdev; ssam_device_set_drvdata(sdev, tpd); - tpd->handler.name = "Surface Platform Profile"; - tpd->handler.dev = &sdev->dev; - tpd->handler.ops = &ssam_platform_profile_ops; - tpd->has_fan = device_property_read_bool(&sdev->dev, "has_fan"); - return devm_platform_profile_register(&tpd->handler, tpd); + tpd->ppdev = devm_platform_profile_register( + &sdev->dev, "Surface Platform Profile", tpd, &ssam_platform_profile_ops); + + return PTR_ERR_OR_ZERO(tpd->ppdev); } static const struct ssam_device_id ssam_platform_profile_match[] = { diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 70ec667e0cbf..2059b29dd36b 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -742,7 +742,7 @@ static const struct dmi_system_id non_acer_quirks[] __initconst = { {} }; -static struct platform_profile_handler platform_profile_handler; +static struct device *platform_profile_device; static bool platform_profile_support; /* @@ -1921,16 +1921,10 @@ static const struct platform_profile_ops acer_predator_v4_platform_profile_ops = static int acer_platform_profile_setup(struct platform_device *device) { if (quirks->predator_v4) { - int err; - - platform_profile_handler.name = "acer-wmi"; - platform_profile_handler.dev = &device->dev; - platform_profile_handler.ops = - &acer_predator_v4_platform_profile_ops; - - err = devm_platform_profile_register(&platform_profile_handler, NULL); - if (err) - return err; + platform_profile_device = devm_platform_profile_register( + &device->dev, "acer-wmi", NULL, &acer_predator_v4_platform_profile_ops); + if (IS_ERR(platform_profile_device)) + return PTR_ERR(platform_profile_device); platform_profile_support = true; @@ -2017,7 +2011,7 @@ static int acer_thermal_profile_change(void) if (tp != ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO_WMI) last_non_turbo_profile = tp; - platform_profile_notify(&platform_profile_handler); + platform_profile_notify(platform_profile_device); } return 0; diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 198bfe3306be..3806f9efaff8 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -338,7 +338,7 @@ struct amd_pmf_dev { struct mutex lock; /* protects the PMF interface */ u32 supported_func; enum platform_profile_option current_profile; - struct platform_profile_handler pprof; + struct device *ppdev; /* platform profile class device */ struct dentry *dbgfs_dir; int hb_interval; /* SBIOS heartbeat interval */ struct delayed_work heart_beat; diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 4f80a73eff9f..e8d2de9bb646 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -420,15 +420,16 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) amd_pmf_set_sps_power_limits(dev); } - dev->pprof.name = "amd-pmf"; - dev->pprof.dev = dev->dev; - dev->pprof.ops = &amd_pmf_profile_ops; - /* Create platform_profile structure and register */ - err = devm_platform_profile_register(&dev->pprof, dev); - if (err) + dev->ppdev = devm_platform_profile_register( + dev->dev, "amd-pmf", dev, &amd_pmf_profile_ops); + if (IS_ERR(dev->ppdev)) { + err = PTR_ERR(dev->ppdev); dev_err(dev->dev, "Failed to register SPS support, this is most likely an SBIOS bug: %d\n", err); - return err; + return err; + } + + return 0; } diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 5c7099dc6109..809ab0353b68 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -313,7 +313,7 @@ struct asus_wmi { bool mid_fan_curve_available; struct fan_curve_data custom_fan_curves[3]; - struct platform_profile_handler platform_profile_handler; + struct device *platform_profile_device; bool platform_profile_support; // The RSOC controls the maximum charging percentage. @@ -3789,7 +3789,7 @@ static ssize_t throttle_thermal_policy_store(struct device *dev, * Ensure that platform_profile updates userspace with the change to ensure * that platform_profile and throttle_thermal_policy_mode are in sync. */ - platform_profile_notify(&asus->platform_profile_handler); + platform_profile_notify(asus->platform_profile_device); return count; } @@ -3891,15 +3891,10 @@ static int platform_profile_setup(struct asus_wmi *asus) dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n"); - asus->platform_profile_handler.name = "asus-wmi"; - asus->platform_profile_handler.dev = dev; - asus->platform_profile_handler.ops = &asus_wmi_platform_profile_ops; - - err = devm_platform_profile_register(&asus->platform_profile_handler, asus); - if (err == -EEXIST) { - pr_warn("%s, a platform_profile handler is already registered\n", __func__); - return 0; - } else if (err) { + asus->platform_profile_device = devm_platform_profile_register( + dev, "asus-wmi", asus, &asus_wmi_platform_profile_ops); + if (IS_ERR(asus->platform_profile_device)) { + err = PTR_ERR(asus->platform_profile_device); pr_err("%s, failed at devm_platform_profile_register: %d\n", __func__, err); return err; } diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index a8961de004ab..1eaa746eb4f1 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -414,7 +414,6 @@ static struct platform_device *platform_device; static struct device_attribute *zone_dev_attrs; static struct attribute **zone_attrs; static struct platform_zone *zone_data; -static struct platform_profile_handler pp_handler; static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; static struct platform_driver platform_driver = { @@ -1165,11 +1164,12 @@ static const struct platform_profile_ops awcc_platform_profile_ops = { static int create_thermal_profile(struct platform_device *platform_device) { - pp_handler.name = "alienware-wmi"; - pp_handler.dev = &platform_device->dev; - pp_handler.ops = &awcc_platform_profile_ops; + struct device *ppdev; - return devm_platform_profile_register(&pp_handler, NULL); + ppdev = devm_platform_profile_register( + &platform_device->dev, "alienware-wmi", NULL, &awcc_platform_profile_ops); + + return PTR_ERR_OR_ZERO(ppdev); } static int __init alienware_wmi_init(void) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index dda6f13295e8..4ff80ed4f157 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -109,8 +109,6 @@ MODULE_DEVICE_TABLE(dmi, dell_device_table); #define DELL_ACC_SET_FIELD GENMASK(11, 8) #define DELL_THERMAL_SUPPORTED GENMASK(3, 0) -static struct platform_profile_handler *thermal_handler; - enum thermal_mode_bits { DELL_BALANCED = BIT(0), DELL_COOL_BOTTOM = BIT(1), @@ -254,6 +252,7 @@ static const struct platform_profile_ops dell_pc_platform_profile_ops = { static int thermal_init(void) { + struct device *ppdev; int ret; /* If thermal commands are not supported, exit without error */ @@ -271,26 +270,17 @@ static int thermal_init(void) if (IS_ERR(platform_device)) return PTR_ERR(platform_device); - thermal_handler = devm_kzalloc(&platform_device->dev, sizeof(*thermal_handler), GFP_KERNEL); - if (!thermal_handler) { - ret = -ENOMEM; - goto cleanup_platform_device; - } - thermal_handler->name = "dell-pc"; - thermal_handler->dev = &platform_device->dev; - thermal_handler->ops = &dell_pc_platform_profile_ops; - /* Clean up if failed */ - ret = devm_platform_profile_register(thermal_handler, NULL); - if (ret) + ppdev = devm_platform_profile_register( + &platform_device->dev, "dell-pc", NULL, &dell_pc_platform_profile_ops); + if (IS_ERR(ppdev)) { + ret = PTR_ERR(ppdev); goto cleanup_thermal_handler; + } return 0; cleanup_thermal_handler: - thermal_handler = NULL; - -cleanup_platform_device: platform_device_unregister(platform_device); return ret; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 8a620d36f926..1b9e176f8d6f 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -273,7 +273,7 @@ static DEFINE_MUTEX(active_platform_profile_lock); static struct input_dev *hp_wmi_input_dev; static struct input_dev *camera_shutter_input_dev; static struct platform_device *hp_wmi_platform_dev; -static struct platform_profile_handler platform_profile_handler; +static struct device *platform_profile_device; static struct notifier_block platform_power_source_nb; static enum platform_profile_option active_platform_profile; static bool platform_profile_support; @@ -1602,6 +1602,7 @@ static const struct platform_profile_ops hp_wmi_platform_profile_ops = { static int thermal_profile_setup(struct platform_device *device) { + const struct platform_profile_ops *ops; int err, tp; if (is_omen_thermal_profile()) { @@ -1617,7 +1618,7 @@ static int thermal_profile_setup(struct platform_device *device) if (err < 0) return err; - platform_profile_handler.ops = &platform_profile_omen_ops; + ops = &platform_profile_omen_ops; } else if (is_victus_thermal_profile()) { err = platform_profile_victus_get_ec(&active_platform_profile); if (err < 0) @@ -1631,7 +1632,7 @@ static int thermal_profile_setup(struct platform_device *device) if (err < 0) return err; - platform_profile_handler.ops = &platform_profile_victus_ops; + ops = &platform_profile_victus_ops; } else { tp = thermal_profile_get(); @@ -1646,15 +1647,13 @@ static int thermal_profile_setup(struct platform_device *device) if (err) return err; - platform_profile_handler.ops = &hp_wmi_platform_profile_ops; + ops = &hp_wmi_platform_profile_ops; } - platform_profile_handler.name = "hp-wmi"; - platform_profile_handler.dev = &device->dev; - - err = devm_platform_profile_register(&platform_profile_handler, NULL); - if (err) - return err; + platform_profile_device = devm_platform_profile_register( + &device->dev, "hp-wmi", NULL, ops); + if (IS_ERR(platform_profile_device)) + return PTR_ERR(platform_profile_device); platform_profile_support = true; diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index d34d565172f5..55aac0190624 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -142,7 +142,7 @@ enum { struct ideapad_dytc_priv { enum platform_profile_option current_profile; - struct platform_profile_handler pprof; + struct device *ppdev; /* platform profile device */ struct mutex mutex; /* protects the DYTC interface */ struct ideapad_private *priv; }; @@ -1050,7 +1050,7 @@ static void dytc_profile_refresh(struct ideapad_private *priv) if (profile != priv->dytc->current_profile) { priv->dytc->current_profile = profile; - platform_profile_notify(&priv->dytc->pprof); + platform_profile_notify(priv->dytc->ppdev); } } @@ -1117,15 +1117,15 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) mutex_init(&priv->dytc->mutex); - priv->dytc->pprof.name = "ideapad-laptop"; - priv->dytc->pprof.dev = &priv->platform_device->dev; priv->dytc->priv = priv; - priv->dytc->pprof.ops = &dytc_profile_ops; /* Create platform_profile structure and register */ - err = devm_platform_profile_register(&priv->dytc->pprof, &priv->dytc); - if (err) + priv->dytc->ppdev = devm_platform_profile_register( + &priv->platform_device->dev, "ideapad-laptop", &priv->dytc, &dytc_profile_ops); + if (IS_ERR(priv->dytc->ppdev)) { + err = PTR_ERR(priv->dytc->ppdev); goto pp_reg_failed; + } /* Ensure initial values are correct */ dytc_profile_refresh(priv); diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 543e4bce1a57..9e2f24de0207 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -32,7 +32,7 @@ enum inspur_tmp_profile { struct inspur_wmi_priv { struct wmi_device *wdev; - struct platform_profile_handler handler; + struct device *ppdev; }; static int inspur_wmi_perform_query(struct wmi_device *wdev, @@ -190,11 +190,10 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) priv->wdev = wdev; dev_set_drvdata(&wdev->dev, priv); - priv->handler.name = "inspur-wmi"; - priv->handler.dev = &wdev->dev; - priv->handler.ops = &inspur_platform_profile_ops; + priv->ppdev = devm_platform_profile_register( + &wdev->dev, "inspur-wmi", priv, &inspur_platform_profile_ops); - return devm_platform_profile_register(&priv->handler, priv); + return PTR_ERR_OR_ZERO(priv->ppdev); } static const struct wmi_device_id inspur_wmi_id_table[] = { diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index a0b8987bc328..964f842ef756 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -962,6 +962,7 @@ static const struct proc_ops dispatch_proc_ops = { static struct platform_device *tpacpi_pdev; static struct platform_device *tpacpi_sensors_pdev; static struct device *tpacpi_hwmon; +static struct device *tpacpi_pprof; static struct input_dev *tpacpi_inputdev; static struct mutex tpacpi_inputdev_send_mutex; static LIST_HEAD(tpacpi_all_drivers); @@ -10553,11 +10554,6 @@ static const struct platform_profile_ops dytc_profile_ops = { .choices = dytc_profile_choices, }; -static struct platform_profile_handler dytc_profile = { - .name = "thinkpad-acpi", - .ops = &dytc_profile_ops, -}; - static void dytc_profile_refresh(void) { enum platform_profile_option profile; @@ -10586,7 +10582,7 @@ static void dytc_profile_refresh(void) err = convert_dytc_to_profile(funcmode, perfmode, &profile); if (!err && profile != dytc_current_profile) { dytc_current_profile = profile; - platform_profile_notify(&dytc_profile); + platform_profile_notify(tpacpi_pprof); } } @@ -10647,14 +10643,14 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) dbg_printk(TPACPI_DBG_INIT, "DYTC version %d: thermal mode available\n", dytc_version); - dytc_profile.dev = &tpacpi_pdev->dev; /* Create platform_profile structure and register */ - err = devm_platform_profile_register(&dytc_profile, NULL); + tpacpi_pprof = devm_platform_profile_register( + &tpacpi_pdev->dev, "thinkpad-acpi", NULL, &dytc_profile_ops); /* * If for some reason platform_profiles aren't enabled * don't quit terminally. */ - if (err) + if (IS_ERR(tpacpi_pprof)) return -ENODEV; /* Ensure initial values are correct */ diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index cadbd3168d84..97ce9bd476ab 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -47,10 +47,14 @@ struct platform_profile_handler { const struct platform_profile_ops *ops; }; -int platform_profile_register(struct platform_profile_handler *pprof, void *drvdata); -int platform_profile_remove(struct platform_profile_handler *pprof); -int devm_platform_profile_register(struct platform_profile_handler *pprof, void *drvdata); +struct device *platform_profile_register(struct device *dev, const char *name, + void *drvdata, + const struct platform_profile_ops *ops); +int platform_profile_remove(struct device *dev); +struct device *devm_platform_profile_register(struct device *dev, const char *name, + void *drvdata, + const struct platform_profile_ops *ops); int platform_profile_cycle(void); -void platform_profile_notify(struct platform_profile_handler *pprof); +void platform_profile_notify(struct device *dev); #endif /*_PLATFORM_PROFILE_H_*/ From patchwork Thu Jan 9 15:06:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 856004 Received: from mail-vs1-f45.google.com (mail-vs1-f45.google.com [209.85.217.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E6DE223339; Thu, 9 Jan 2025 15:09:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435372; cv=none; b=THQ+pfdDx4aNtDSUAtm3VeU91s+Dl04rCWx1ggAAYluG5j3R3s7FZpqmV9mCWp1ASK1HDRvBfMQd7IOCqym22eB0bFRvB9e73t+xn9dDGD/Gy+yPTwYg0/Jfl5NVMHThp4+tTlCp7cHVdOpFqikiSGiPwzxtAPimhahW1GIsMzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435372; c=relaxed/simple; bh=hd4xcYLw3nB/xyzAEl3lcxHF1IrhA0+QO6bMSUHHYl8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o+/ieewXI4l0WLTV5DXK4yA4VO+0E71CAO5ikKxr4zZUA3WmYsJPvudp+NZgs5ekOejVtUknX9KNQv5qGNggKNAkyy5kOmx3p7NGtyQvICGCFoXUu8FXI5lsbPZN+5tkOuP61E81r/d44P3N/po2OI5OYeI5XMo3Lulic0G/LZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=j+FEqLfU; arc=none smtp.client-ip=209.85.217.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j+FEqLfU" Received: by mail-vs1-f45.google.com with SMTP id ada2fe7eead31-4afe2f6cecdso994542137.1; Thu, 09 Jan 2025 07:09:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736435370; x=1737040170; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LCPUh3IUWcLS4g8ZtG6u3bDbqVNKgPDzo14k9ivGOUE=; b=j+FEqLfUTEZp4dmfmJhkapPfU7FlhaAZul+uw5c3m1cI3/Gj1RmNaYveEfQ7lm4atj VolFj20yT0NMt9TK7fsIN0cPXtQQ2mUR4O9n8/e36pXZaDqc6lseimdg4yn1s3xyilmz 0NjYC+sTMpNmWQ7z2LPeaiNQQCSvsNU/3oxZoUQpt7WMFS3xztF2YHM1lgDPo32Js5gx BSeVyCa7maiVLUp3S0sQ/KQqInlVd3WKUc7YaQlONNfrTbYo5OG25rx8cZixwtkw1Czq nv7MnnpJhbigOXHLzzzl0om3rW/Gzh7lebkOapDtsNdaofwtgLcwqBcfFDaQRPHq9diI 5oGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736435370; x=1737040170; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LCPUh3IUWcLS4g8ZtG6u3bDbqVNKgPDzo14k9ivGOUE=; b=C3t5m2wXZ3+P7GZggRmmbiAbKltUsihDODkMgDuXyZqUmqmrRqd9Syq3RBleuVOT2G VJYsmf7feb7qiXHJ24AgDoL9zLSz3tWKoo0DiVThAGu1XVLhSKkcm4GPfssCUzcuQ0BT cxF97V3y23x566cGQGrqE0GLaCjLwYpzZpNYdaIJL3FIVhAYSW9oUS+liDQ620Sd18+3 1rUkhhTGM8qhTASo1CLp1lXP39JVBToV0CHEBFsdX69pPBz4blXH3L2K0AD+LacJ+8MY /AUsnofzBMaN9YpeAWVmUkUzVFLmarA9YxboN26X1tI7D+dtZ5/nFRuUeiEzxxu8OiZg /U6w== X-Forwarded-Encrypted: i=1; AJvYcCVuD7lT1pfmSJokG9814qc5aqN4Up8Q67S0ruMjig1r+TLz+iDhTXM1dB4DkuEzjzZ/oTWY4Vx8Vwje@vger.kernel.org, AJvYcCXaGA8ByuaGGLHN4j3aXZrG/+FPgNumDz/2IDtx0CW0L9UCG/cMoWAMgQTj2lFMjp3zx8JOlynAKo9Ko65S@vger.kernel.org X-Gm-Message-State: AOJu0YxswBSc43+/DUbx+IetGz7eY9J1WLhNQN5UEdxX9f3MZ4ic4xfI OMP8QjLZgpjYttDzW77zyvs7D7gzG8TeKsFY47qxtHfpCa2ELLIjr/G4SBOM X-Gm-Gg: ASbGncv94ZIEmb0b4Ezj8LyJIN5Q7SNIsiwN2hltdUCLwlKYFh2S3agY00zlAV0tzse teBUuVKEPaO/Qjw4rRx5Wly39IcqJ1qq4WHuVm4CinhHdwmlb6r0PXiSohN36JU/+n+BvaKZ/ni DOxHYzRDcoASYQzH++RFVF5mkCwSXkAFWbixPfUGbwGk/qh6eCUfYcFyCONscwqkJOzMD6rHVZP mTmAEcTqq7nl1voAymhuLpbJgdqN5CDYK6hichkfZZWYGdDvamtzGX88vH/JIz9 X-Google-Smtp-Source: AGHT+IElwwsp4NqbvFdkiIUnAd+c3k1JAKYhoPpPzIupjHSpN5n+crDibgLtTHnzuH71WFxJFnotuw== X-Received: by 2002:a05:6102:3c92:b0:4af:ed5a:b68d with SMTP id ada2fe7eead31-4b6092b35f5mr2035296137.6.1736435369783; Thu, 09 Jan 2025 07:09:29 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4b608f4a5ddsm1019887137.11.2025.01.09.07.09.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 07:09:28 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , Joshua Grisham , "Derek J . Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , Kurt Borja , Maximilian Luz , "Lee, Chun-Yi" , Shyam Sundar S K , Corentin Chary , "Luke D. Jones" , Lyndon Sanche , Ike Panhc , Henrique de Moraes Holschuh , Mark Pearson , Colin Ian King , Alexis Belmonte , Ai Chao , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Gergo Koteles , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH 16/18] ACPI: platform_profile: Move platform_profile_handler Date: Thu, 9 Jan 2025 10:06:29 -0500 Message-ID: <20250109150731.110799-17-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109150731.110799-1-kuurtb@gmail.com> References: <20250109150731.110799-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 platform_profile_handler is now an internal structure. Move it to platform_profile.c. Signed-off-by: Kurt Borja --- drivers/acpi/platform_profile.c | 9 +++++++++ include/linux/platform_profile.h | 11 ----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 8d034d928e32..c7a867bd01df 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -15,6 +15,15 @@ static DEFINE_MUTEX(profile_lock); +struct platform_profile_handler { + const char *name; + struct device *dev; + struct device class_dev; + int minor; + unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + const struct platform_profile_ops *ops; +}; + static const char * const profile_names[] = { [PLATFORM_PROFILE_LOW_POWER] = "low-power", [PLATFORM_PROFILE_COOL] = "cool", diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 0824a12b9998..2c99aff7cd19 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -28,23 +28,12 @@ enum platform_profile_option { PLATFORM_PROFILE_LAST, /*must always be last */ }; -struct platform_profile_handler; - struct platform_profile_ops { int (*profile_get)(struct device *dev, enum platform_profile_option *profile); int (*profile_set)(struct device *dev, enum platform_profile_option profile); int (*choices)(void *drvdata, unsigned long *choices); }; -struct platform_profile_handler { - const char *name; - struct device *dev; - struct device class_dev; - int minor; - unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; - const struct platform_profile_ops *ops; -}; - struct device *platform_profile_register(struct device *dev, const char *name, void *drvdata, const struct platform_profile_ops *ops); From patchwork Thu Jan 9 15:06:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Borja X-Patchwork-Id: 856003 Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com [209.85.217.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BCE0224888; Thu, 9 Jan 2025 15:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435387; cv=none; b=UDH1I9741LmR2GYlz8OGgoYqp5NzlUBidzVghmjSCv3ax3Bm/ZoDtieT5wUWIRgVJwmt64CW6yaPSPVpaGM1xrRiNjA5VCCyo2ZvsLiIljKUCL/aILBthZdlgwEKA0YbOKv7Cf90nbRQycUEkrOKHb2i3TYNdopQ7XZQIQibuLE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736435387; c=relaxed/simple; bh=ueES1CpHxkIOmIdddrXeMAV9rO12JLZzujSA/AYR5iA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uo94KCC1jqqPLNVMee30SkJ9Kj5Zscky/aarmPF4xXALOO88Bd9SCcdqKrdAxjkE4tI7xigTh31GS8tOck/U32BDSRnWiazIHAFS+ErPFVtxoAtaql2qv/6X1UHicmd7jvGEYD0NbuHVDABlgVI4PdMdSgU7+LlDvx0aLuZbyek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HUOWJ5zw; arc=none smtp.client-ip=209.85.217.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HUOWJ5zw" Received: by mail-vs1-f47.google.com with SMTP id ada2fe7eead31-4aff31b77e8so427887137.1; Thu, 09 Jan 2025 07:09:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736435384; x=1737040184; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tXWFMX8a8Q4Pv2GPHLPCd0mT4LshIMD7WrNQh2s1+XA=; b=HUOWJ5zwI6QVQBYyLBzSXQLAkG+H6cfWWZJV4G8+WvRDpoY1D2xMjqmqIG4vyE7eU/ W9yY61mMKeu8FdMW5moV4pMG38D3tf6qJ8uUqW1SL0j5M6DFF5Cn8SJZyqKlxHOigrUg p5IBWitrMDuCJKOxMCNWoCBsfoIa9pJR0LPtnpb9HEaTqsS8Az74qI/peQa17eKWjuKH 0FuZqcRTeSkpviF+r2oKD6KwoR8HkftzyxdWeOHxLu7yFp8grDtCO8wKLQJ5mOblrKw0 dEZZYAwWv0h7totJf3+mtVOToYC+a6dbr6zrAWr5vGSFSPc481mkCo23MTJA8inVuQZ8 Z6Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736435384; x=1737040184; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tXWFMX8a8Q4Pv2GPHLPCd0mT4LshIMD7WrNQh2s1+XA=; b=hl5BxvMDD6hSX2hDC3ldhM8NfzAzWxfOXAGtSCnz0r9/Ix+Ef/0HjWhkc1MXCsY8iU NWNdy3dy1vXRforO3JR45u1KzV/05OTl8M5qyTumECtMPlzP0Fwcy6TAaRtsIub4+GIY vhMmGHkzketHjYs4z/ww1f0EeEX2xhf0OEaifSFTndem9nKQoW7IkydJLLT6fd+Tm7D7 FlSdqPGmk/CltP8XISN33m7iAYTi+ccsr9Pw+D+yCqj021C77NcK7Ifqyu3eNOg5vVdQ PwHmpFuf88mkLKpiMqYtIrDVWGzBh2eyhrl4lOS04kfLrkBNknyhEOiDL8xHJEwPxFfb Of5w== X-Forwarded-Encrypted: i=1; AJvYcCV13LOjadxFlbyaBl/E5+23Xxee+d7cilUSf3VY4RwVMg5dltdh0EdCONbm9z+ZEmO1YE2F9A9vjeoPrgc2@vger.kernel.org, AJvYcCXk44Op/K9gMqhvZWgcJwUuTtF587360UXCDtkJ08P9Z/P/8HOniPBAnrG2f4RZsn+oiaUFyZcX2F2r@vger.kernel.org X-Gm-Message-State: AOJu0Yxr9lFese2+RGEw6+aULeaHfUpYVnIpW/3B8ARYJc8pecpZPTer UpzQSndGvRT9CnVNc0KfscTpBYTM/JdCAgj20NiDon2aPzE32x6Le/1V0VCc X-Gm-Gg: ASbGnctXeqvjGgWAq7n8Mqsk2ttdo9DUIR2a+pcZmAeEZbfUVveaE4qDpLSL3ZsnqXT xMiJRdsYztDlknhjReDlcsLe19iZQ2V4hZr4Kag/6GOCcr6cc74b0ATReaidJRjs0HbfsR4EVFJ svGu7JxSFBl+LRpTvo7hyR7AAGY3xG76ek/iJ6HKaYpnWkyF6D60RFGmAkaXnQSJt0bFFb3xKzh kPphfuEZVEtJGfCa8Z49dRWaOYSX8jXrtuduHmCPyGIaDh51sQnL1GX1EoYES95 X-Google-Smtp-Source: AGHT+IHTsiyxTdRhLAyXTzqH/vzYBKjh+K4a/SbVvKlT32OwOtIjQS0SYK32yrgF2TjbYCaJTMQ51w== X-Received: by 2002:a05:6102:cc6:b0:4b2:bc6a:2e8b with SMTP id ada2fe7eead31-4b3d0ef6127mr5990268137.3.1736435383993; Thu, 09 Jan 2025 07:09:43 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:1159:1ea9:11b1:7af9:1277]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4b608f4a5ddsm1019887137.11.2025.01.09.07.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 07:09:43 -0800 (PST) From: Kurt Borja To: platform-driver-x86@vger.kernel.org Cc: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Mario Limonciello" , "Armin Wolf" , Joshua Grisham , "Derek J . Clark" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "Hans de Goede" , Kurt Borja , Maximilian Luz , "Lee, Chun-Yi" , Shyam Sundar S K , Corentin Chary , "Luke D. Jones" , Lyndon Sanche , Ike Panhc , Henrique de Moraes Holschuh , Mark Pearson , Colin Ian King , Alexis Belmonte , Ai Chao , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Gergo Koteles , Dell.Client.Kernel@dell.com, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH 18/18] ACPI: platform_profile: Add documentation Date: Thu, 9 Jan 2025 10:06:31 -0500 Message-ID: <20250109150731.110799-19-kuurtb@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109150731.110799-1-kuurtb@gmail.com> References: <20250109150731.110799-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add kerneldoc and sysfs class documentation. Signed-off-by: Kurt Borja --- .../ABI/testing/sysfs-class-platform-profile | 44 +++++++++++++++++++ drivers/acpi/platform_profile.c | 33 ++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-platform-profile diff --git a/Documentation/ABI/testing/sysfs-class-platform-profile b/Documentation/ABI/testing/sysfs-class-platform-profile new file mode 100644 index 000000000000..59486dc4313f --- /dev/null +++ b/Documentation/ABI/testing/sysfs-class-platform-profile @@ -0,0 +1,44 @@ +What: /sys/class/platform-profile/platform-profile-X/name +Date: January 2025 +Description: Name of the class device given by the driver. + + RO + +What: /sys/class/platform-profile/platform-profile-X/choices +Date: January 2025 +Description: This file contains a space-separated list of profiles supported for this device. + + Drivers must use the following standard profile-names: + + ==================== ======================================== + low-power Low power consumption + cool Cooler operation + quiet Quieter operation + balanced Balance between low power consumption + and performance + balanced-performance Balance between performance and low + power consumption with a slight bias + towards performance + performance High performance operation + custom Driver defined custom profile + ==================== ======================================== + + RO + +What: /sys/class/platform-profile/platform-profile-X/profile +Date: January 2025 +Description: Reading this file gives the current selected profile for this + device. Writing this file with one of the strings from + platform_profile_choices changes the profile to the new value. + + This file can be monitored for changes by polling for POLLPRI, + POLLPRI will be signalled on any changes, independent of those + changes coming from a userspace write; or coming from another + source such as e.g. a hotkey triggered profile change handled + either directly by the embedded-controller or fully handled + inside the kernel. + + This file may also emit the string 'custom' to indicate + that the driver is using a driver defined custom profile. + + RW diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 8c79ecab8a6d..5d74675c5419 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -426,6 +426,10 @@ static const struct attribute_group platform_profile_group = { .is_visible = profile_class_is_visible, }; +/** + * platform_profile_notify - Notify class device and legacy sysfs interface + * @dev: The class device + */ void platform_profile_notify(struct device *dev) { scoped_cond_guard(mutex_intr, return, &profile_lock) { @@ -435,6 +439,11 @@ void platform_profile_notify(struct device *dev) } EXPORT_SYMBOL_GPL(platform_profile_notify); +/** + * platform_profile_cycle - Cycles profiles available on all registered class devices + * + * Return: 0 on success, -errno on failure + */ int platform_profile_cycle(void) { enum platform_profile_option next = PLATFORM_PROFILE_LAST; @@ -478,6 +487,15 @@ int platform_profile_cycle(void) } EXPORT_SYMBOL_GPL(platform_profile_cycle); +/** + * platform_profile_register - Creates and registers a platform profile class device + * @dev: Parent device + * @name: Name of the class device + * @drvdata: Driver data that will be attached to the class device + * @ops: Platform profile's mandatory operations + * + * Return: pointer to the new class device on success, ERR_PTR on failure + */ struct device *platform_profile_register(struct device *dev, const char *name, void *drvdata, const struct platform_profile_ops *ops) @@ -548,6 +566,12 @@ struct device *platform_profile_register(struct device *dev, const char *name, } EXPORT_SYMBOL_GPL(platform_profile_register); +/** + * platform_profile_remove - Unregisters a platform profile class device + * @dev: Class device + * + * Return: 0 + */ int platform_profile_remove(struct device *dev) { struct platform_profile_handler *pprof = to_pprof_handler(dev); @@ -573,6 +597,15 @@ static void devm_platform_profile_release(struct device *dev, void *res) platform_profile_remove(*ppdev); } +/** + * devm_platform_profile_register - Device managed version of platform_profile_register + * @dev: Parent device + * @name: Name of the class device + * @drvdata: Driver data that will be attached to the class device + * @ops: Platform profile's mandatory operations + * + * Return: pointer to the new class device on success, ERR_PTR on failure + */ struct device *devm_platform_profile_register(struct device *dev, const char *name, void *drvdata, const struct platform_profile_ops *ops)