mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-31 06:09:56 +00:00
ACPI: platform_profile: Let drivers set drvdata to the class device
Add *drvdata to platform_profile_register() signature and assign it to the class device. While at it, pass specific driver state as drvdata to replace uses of container_of() with dev_get_drvdata(). 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-3-kuurtb@gmail.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
parent
d960f14800
commit
249c576f0f
@ -460,7 +460,7 @@ int platform_profile_cycle(void)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(platform_profile_cycle);
|
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;
|
int err;
|
||||||
|
|
||||||
@ -480,6 +480,7 @@ int platform_profile_register(struct platform_profile_handler *pprof)
|
|||||||
|
|
||||||
pprof->class_dev.class = &platform_profile_class;
|
pprof->class_dev.class = &platform_profile_class;
|
||||||
pprof->class_dev.parent = pprof->dev;
|
pprof->class_dev.parent = pprof->dev;
|
||||||
|
dev_set_drvdata(&pprof->class_dev, drvdata);
|
||||||
dev_set_name(&pprof->class_dev, "platform-profile-%d", pprof->minor);
|
dev_set_name(&pprof->class_dev, "platform-profile-%d", pprof->minor);
|
||||||
err = device_register(&pprof->class_dev);
|
err = device_register(&pprof->class_dev);
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -529,7 +530,7 @@ static void devm_platform_profile_release(struct device *dev, void *res)
|
|||||||
platform_profile_remove(*pprof);
|
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;
|
struct platform_profile_handler **dr;
|
||||||
int ret;
|
int ret;
|
||||||
@ -538,7 +539,7 @@ int devm_platform_profile_register(struct platform_profile_handler *pprof)
|
|||||||
if (!dr)
|
if (!dr)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
ret = platform_profile_register(pprof);
|
ret = platform_profile_register(pprof, drvdata);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
devres_free(dr);
|
devres_free(dr);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -161,7 +161,7 @@ static int ssam_platform_profile_get(struct platform_profile_handler *pprof,
|
|||||||
enum ssam_tmp_profile tp;
|
enum ssam_tmp_profile tp;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
tpd = container_of(pprof, struct ssam_platform_profile_device, handler);
|
tpd = dev_get_drvdata(&pprof->class_dev);
|
||||||
|
|
||||||
status = ssam_tmp_profile_get(tpd->sdev, &tp);
|
status = ssam_tmp_profile_get(tpd->sdev, &tp);
|
||||||
if (status)
|
if (status)
|
||||||
@ -181,7 +181,7 @@ static int ssam_platform_profile_set(struct platform_profile_handler *pprof,
|
|||||||
struct ssam_platform_profile_device *tpd;
|
struct ssam_platform_profile_device *tpd;
|
||||||
int tp;
|
int tp;
|
||||||
|
|
||||||
tpd = container_of(pprof, struct ssam_platform_profile_device, handler);
|
tpd = dev_get_drvdata(&pprof->class_dev);
|
||||||
|
|
||||||
tp = convert_profile_to_ssam_tmp(tpd->sdev, profile);
|
tp = convert_profile_to_ssam_tmp(tpd->sdev, profile);
|
||||||
if (tp < 0)
|
if (tp < 0)
|
||||||
@ -224,7 +224,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
|
|||||||
set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, tpd->handler.choices);
|
set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, tpd->handler.choices);
|
||||||
set_bit(PLATFORM_PROFILE_PERFORMANCE, tpd->handler.choices);
|
set_bit(PLATFORM_PROFILE_PERFORMANCE, tpd->handler.choices);
|
||||||
|
|
||||||
return platform_profile_register(&tpd->handler);
|
return platform_profile_register(&tpd->handler, tpd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void surface_platform_profile_remove(struct ssam_device *sdev)
|
static void surface_platform_profile_remove(struct ssam_device *sdev)
|
||||||
|
@ -2073,7 +2073,7 @@ static int acer_platform_profile_setup(struct platform_device *device)
|
|||||||
ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO;
|
ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = platform_profile_register(&platform_profile_handler);
|
err = platform_profile_register(&platform_profile_handler, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ bool is_pprof_balanced(struct amd_pmf_dev *pmf)
|
|||||||
static int amd_pmf_profile_get(struct platform_profile_handler *pprof,
|
static int amd_pmf_profile_get(struct platform_profile_handler *pprof,
|
||||||
enum platform_profile_option *profile)
|
enum platform_profile_option *profile)
|
||||||
{
|
{
|
||||||
struct amd_pmf_dev *pmf = container_of(pprof, struct amd_pmf_dev, pprof);
|
struct amd_pmf_dev *pmf = dev_get_drvdata(&pprof->class_dev);
|
||||||
|
|
||||||
*profile = pmf->current_profile;
|
*profile = pmf->current_profile;
|
||||||
return 0;
|
return 0;
|
||||||
@ -366,7 +366,7 @@ int amd_pmf_power_slider_update_event(struct amd_pmf_dev *dev)
|
|||||||
static int amd_pmf_profile_set(struct platform_profile_handler *pprof,
|
static int amd_pmf_profile_set(struct platform_profile_handler *pprof,
|
||||||
enum platform_profile_option profile)
|
enum platform_profile_option profile)
|
||||||
{
|
{
|
||||||
struct amd_pmf_dev *pmf = container_of(pprof, struct amd_pmf_dev, pprof);
|
struct amd_pmf_dev *pmf = dev_get_drvdata(&pprof->class_dev);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
pmf->current_profile = profile;
|
pmf->current_profile = profile;
|
||||||
@ -416,7 +416,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)
|
|||||||
set_bit(PLATFORM_PROFILE_PERFORMANCE, dev->pprof.choices);
|
set_bit(PLATFORM_PROFILE_PERFORMANCE, dev->pprof.choices);
|
||||||
|
|
||||||
/* Create platform_profile structure and register */
|
/* Create platform_profile structure and register */
|
||||||
err = platform_profile_register(&dev->pprof);
|
err = platform_profile_register(&dev->pprof, dev);
|
||||||
if (err)
|
if (err)
|
||||||
dev_err(dev->dev, "Failed to register SPS support, this is most likely an SBIOS bug: %d\n",
|
dev_err(dev->dev, "Failed to register SPS support, this is most likely an SBIOS bug: %d\n",
|
||||||
err);
|
err);
|
||||||
|
@ -3806,7 +3806,7 @@ static int asus_wmi_platform_profile_get(struct platform_profile_handler *pprof,
|
|||||||
struct asus_wmi *asus;
|
struct asus_wmi *asus;
|
||||||
int tp;
|
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;
|
tp = asus->throttle_thermal_policy_mode;
|
||||||
|
|
||||||
switch (tp) {
|
switch (tp) {
|
||||||
@ -3832,7 +3832,7 @@ static int asus_wmi_platform_profile_set(struct platform_profile_handler *pprof,
|
|||||||
struct asus_wmi *asus;
|
struct asus_wmi *asus;
|
||||||
int tp;
|
int tp;
|
||||||
|
|
||||||
asus = container_of(pprof, struct asus_wmi, platform_profile_handler);
|
asus = dev_get_drvdata(&pprof->class_dev);
|
||||||
|
|
||||||
switch (profile) {
|
switch (profile) {
|
||||||
case PLATFORM_PROFILE_PERFORMANCE:
|
case PLATFORM_PROFILE_PERFORMANCE:
|
||||||
@ -3887,7 +3887,7 @@ static int platform_profile_setup(struct asus_wmi *asus)
|
|||||||
set_bit(PLATFORM_PROFILE_PERFORMANCE,
|
set_bit(PLATFORM_PROFILE_PERFORMANCE,
|
||||||
asus->platform_profile_handler.choices);
|
asus->platform_profile_handler.choices);
|
||||||
|
|
||||||
err = platform_profile_register(&asus->platform_profile_handler);
|
err = platform_profile_register(&asus->platform_profile_handler, asus);
|
||||||
if (err == -EEXIST) {
|
if (err == -EEXIST) {
|
||||||
pr_warn("%s, a platform_profile handler is already registered\n", __func__);
|
pr_warn("%s, a platform_profile handler is already registered\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1129,7 +1129,7 @@ static int create_thermal_profile(struct platform_device *platform_device)
|
|||||||
pp_handler.name = "alienware-wmi";
|
pp_handler.name = "alienware-wmi";
|
||||||
pp_handler.dev = &platform_device->dev;
|
pp_handler.dev = &platform_device->dev;
|
||||||
|
|
||||||
return devm_platform_profile_register(&pp_handler);
|
return devm_platform_profile_register(&pp_handler, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -271,7 +271,7 @@ static int thermal_init(void)
|
|||||||
set_bit(PLATFORM_PROFILE_PERFORMANCE, thermal_handler->choices);
|
set_bit(PLATFORM_PROFILE_PERFORMANCE, thermal_handler->choices);
|
||||||
|
|
||||||
/* Clean up if failed */
|
/* Clean up if failed */
|
||||||
ret = platform_profile_register(thermal_handler);
|
ret = platform_profile_register(thermal_handler, NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto cleanup_thermal_handler;
|
goto cleanup_thermal_handler;
|
||||||
|
|
||||||
|
@ -1629,7 +1629,7 @@ static int thermal_profile_setup(struct platform_device *device)
|
|||||||
set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices);
|
set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices);
|
||||||
set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices);
|
set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices);
|
||||||
|
|
||||||
err = platform_profile_register(&platform_profile_handler);
|
err = platform_profile_register(&platform_profile_handler, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -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,
|
static int dytc_profile_get(struct platform_profile_handler *pprof,
|
||||||
enum platform_profile_option *profile)
|
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;
|
*profile = dytc->current_profile;
|
||||||
return 0;
|
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,
|
static int dytc_profile_set(struct platform_profile_handler *pprof,
|
||||||
enum platform_profile_option profile)
|
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;
|
struct ideapad_private *priv = dytc->priv;
|
||||||
unsigned long output;
|
unsigned long output;
|
||||||
int err;
|
int err;
|
||||||
@ -1114,7 +1114,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv)
|
|||||||
set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->dytc->pprof.choices);
|
set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->dytc->pprof.choices);
|
||||||
|
|
||||||
/* Create platform_profile structure and register */
|
/* Create platform_profile structure and register */
|
||||||
err = platform_profile_register(&priv->dytc->pprof);
|
err = platform_profile_register(&priv->dytc->pprof, &priv->dytc);
|
||||||
if (err)
|
if (err)
|
||||||
goto pp_reg_failed;
|
goto pp_reg_failed;
|
||||||
|
|
||||||
|
@ -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,
|
static int inspur_platform_profile_set(struct platform_profile_handler *pprof,
|
||||||
enum platform_profile_option profile)
|
enum platform_profile_option profile)
|
||||||
{
|
{
|
||||||
struct inspur_wmi_priv *priv = container_of(pprof, struct inspur_wmi_priv,
|
struct inspur_wmi_priv *priv = dev_get_drvdata(&pprof->class_dev);
|
||||||
handler);
|
|
||||||
u8 ret_code[4] = {0, 0, 0, 0};
|
u8 ret_code[4] = {0, 0, 0, 0};
|
||||||
int ret;
|
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,
|
static int inspur_platform_profile_get(struct platform_profile_handler *pprof,
|
||||||
enum platform_profile_option *profile)
|
enum platform_profile_option *profile)
|
||||||
{
|
{
|
||||||
struct inspur_wmi_priv *priv = container_of(pprof, struct inspur_wmi_priv,
|
struct inspur_wmi_priv *priv = dev_get_drvdata(&pprof->class_dev);
|
||||||
handler);
|
|
||||||
u8 ret_code[4] = {0, 0, 0, 0};
|
u8 ret_code[4] = {0, 0, 0, 0};
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -186,7 +184,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context)
|
|||||||
set_bit(PLATFORM_PROFILE_BALANCED, priv->handler.choices);
|
set_bit(PLATFORM_PROFILE_BALANCED, priv->handler.choices);
|
||||||
set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->handler.choices);
|
set_bit(PLATFORM_PROFILE_PERFORMANCE, priv->handler.choices);
|
||||||
|
|
||||||
return platform_profile_register(&priv->handler);
|
return platform_profile_register(&priv->handler, priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void inspur_wmi_remove(struct wmi_device *wdev)
|
static void inspur_wmi_remove(struct wmi_device *wdev)
|
||||||
|
@ -10641,7 +10641,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
|
|||||||
|
|
||||||
dytc_profile.dev = &tpacpi_pdev->dev;
|
dytc_profile.dev = &tpacpi_pdev->dev;
|
||||||
/* Create platform_profile structure and register */
|
/* 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
|
* If for some reason platform_profiles aren't enabled
|
||||||
* don't quit terminally.
|
* don't quit terminally.
|
||||||
|
@ -40,9 +40,9 @@ struct platform_profile_handler {
|
|||||||
enum platform_profile_option profile);
|
enum platform_profile_option profile);
|
||||||
};
|
};
|
||||||
|
|
||||||
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 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);
|
int platform_profile_cycle(void);
|
||||||
void platform_profile_notify(struct platform_profile_handler *pprof);
|
void platform_profile_notify(struct platform_profile_handler *pprof);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user