Message ID | 20250109150731.110799-13-kuurtb@gmail.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers | show |
Series | Hide platform_profile_handler from consumers | expand |
On 1/9/2025 09:06, Kurt Borja wrote: > 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 <kuurtb@gmail.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> > --- > 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, > }; >
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, };
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 <kuurtb@gmail.com> --- drivers/platform/x86/inspur_platform_profile.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)