On 1/9/2025 09:06, Kurt Borja wrote:
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 <kuurtb@xxxxxxxxx>
Reviewed-by: Mario Limonciello <mario.limonciello@xxxxxxx>
---
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);