summaryrefslogtreecommitdiff
path: root/drivers/platform
diff options
context:
space:
mode:
authorKurt Borja <kuurtb@gmail.com>2025-01-16 03:27:17 +0300
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>2025-01-17 20:15:59 +0300
commit07f531b395db3cd1776ef0f7191abf4b077fcf21 (patch)
tree2356cbb64ef1bb5af2ca4f4bb3b79caf7d5ed251 /drivers/platform
parent31658c916fa692b7dfceaba6fc6320b81c05b9c2 (diff)
downloadlinux-07f531b395db3cd1776ef0f7191abf4b077fcf21.tar.xz
ACPI: platform_profile: Remove platform_profile_handler from exported symbols
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. Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Kurt Borja <kuurtb@gmail.com> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca> Link: https://lore.kernel.org/r/20250116002721.75592-16-kuurtb@gmail.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/surface/surface_platform_profile.c11
-rw-r--r--drivers/platform/x86/acer-wmi.c18
-rw-r--r--drivers/platform/x86/amd/pmf/pmf.h2
-rw-r--r--drivers/platform/x86/amd/pmf/sps.c17
-rw-r--r--drivers/platform/x86/asus-wmi.c15
-rw-r--r--drivers/platform/x86/dell/alienware-wmi.c10
-rw-r--r--drivers/platform/x86/dell/dell-pc.c21
-rw-r--r--drivers/platform/x86/hp/hp-wmi.c19
-rw-r--r--drivers/platform/x86/ideapad-laptop.c15
-rw-r--r--drivers/platform/x86/inspur_platform_profile.c9
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c14
11 files changed, 60 insertions, 91 deletions
diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
index bbdc873cb788..0e479e35e66e 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 d201ca0e01d6..ae2a7c93ab72 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -784,7 +784,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;
/*
@@ -2073,16 +2073,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;
@@ -2125,7 +2119,7 @@ static int acer_thermal_profile_change(void)
if (current_tp != acer_predator_v4_max_perf)
last_non_turbo_profile = current_tp;
- platform_profile_notify(&platform_profile_handler);
+ platform_profile_notify(platform_profile_device);
}
}
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index d99b3556205b..41b2b91b8fdc 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 7c7ed2b9de01..e6cf0b22dac3 100644
--- a/drivers/platform/x86/amd/pmf/sps.c
+++ b/drivers/platform/x86/amd/pmf/sps.c
@@ -404,8 +404,6 @@ static const struct platform_profile_ops amd_pmf_profile_ops = {
int amd_pmf_init_sps(struct amd_pmf_dev *dev)
{
- int err;
-
dev->current_profile = PLATFORM_PROFILE_BALANCED;
if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) {
@@ -420,15 +418,12 @@ 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_err(dev->dev, "Failed to register SPS support, this is most likely an SBIOS bug: %d\n",
- err);
+ dev->ppdev = devm_platform_profile_register(dev->dev, "amd-pmf", dev,
+ &amd_pmf_profile_ops);
+ if (IS_ERR(dev->ppdev))
+ dev_err(dev->dev, "Failed to register SPS support, this is most likely an SBIOS bug: %ld\n",
+ PTR_ERR(dev->ppdev));
- return err;
+ return PTR_ERR_OR_ZERO(dev->ppdev);
}
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 7aa837f74fd0..1032c0e84e3d 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 *ppdev;
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->ppdev);
return count;
}
@@ -3891,14 +3891,11 @@ 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) {
+ asus->ppdev = devm_platform_profile_register(dev, "asus-wmi", asus,
+ &asus_wmi_platform_profile_ops);
+ if (IS_ERR(asus->ppdev)) {
dev_err(dev, "Failed to register a platform_profile class device\n");
- return err;
+ return PTR_ERR(asus->ppdev);
}
asus->platform_profile_support = true;
diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
index e7209863e7dc..63cf016bc912 100644
--- a/drivers/platform/x86/dell/alienware-wmi.c
+++ b/drivers/platform/x86/dell/alienware-wmi.c
@@ -406,7 +406,6 @@ struct wmax_u32_args {
static struct platform_device *platform_device;
static struct color_platform colors[4];
-static struct platform_profile_handler pp_handler;
static enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST];
static u8 interface;
@@ -1135,11 +1134,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);
}
/*
diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
index 2759bb608b1a..483240bb36e7 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,25 +270,15 @@ 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;
+ 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_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)
- goto cleanup_thermal_handler;
return 0;
-cleanup_thermal_handler:
- thermal_handler = NULL;
-
cleanup_platform_device:
platform_device_unregister(platform_device);
diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
index 1304dfc65aab..435e3ef2e3e7 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 87c1e087770a..dfb5d4b8c046 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,16 @@ 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 e1631de6ad86..e02f5a55a6c5 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 c9226e8dc713..56c57cb45a76 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);
@@ -10554,11 +10555,6 @@ static const struct platform_profile_ops dytc_profile_ops = {
.profile_set = dytc_profile_set,
};
-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;
@@ -10587,7 +10583,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);
}
}
@@ -10648,14 +10644,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 */