diff mbox series

[05/18] platform/surface: surface_platform_profile: Use devm_platform_profile_register()

Message ID 20250109150731.110799-6-kuurtb@gmail.com (mailing list archive)
State Changes Requested, archived
Headers show
Series Hide platform_profile_handler from consumers | expand

Commit Message

Kurt Borja Jan. 9, 2025, 3:06 p.m. UTC
Replace platform_profile_register() with it's device managed version.
While at it, pass ssam_platform_profile_device to the class device as
drvdata and replace uses of container_of() with dev_get_drvdata().

Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
 .../platform/surface/surface_platform_profile.c   | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

Comments

Mario Limonciello Jan. 9, 2025, 4:36 p.m. UTC | #1
On 1/9/2025 09:06, Kurt Borja wrote:
> Replace platform_profile_register() with it's device managed version.
> While at it, pass ssam_platform_profile_device 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>
> ---
>   .../platform/surface/surface_platform_profile.c   | 15 +++------------
>   1 file changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
> index 00a1178e552f..efb6653ed1d5 100644
> --- a/drivers/platform/surface/surface_platform_profile.c
> +++ b/drivers/platform/surface/surface_platform_profile.c
> @@ -161,7 +161,7 @@ static int ssam_platform_profile_get(struct platform_profile_handler *pprof,
>   	enum ssam_tmp_profile tp;
>   	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);
>   	if (status)
> @@ -181,7 +181,7 @@ static int ssam_platform_profile_set(struct platform_profile_handler *pprof,
>   	struct ssam_platform_profile_device *tpd;
>   	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);
>   	if (tp < 0)
> @@ -234,15 +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, NULL);
> -}
> -
> -static void surface_platform_profile_remove(struct ssam_device *sdev)
> -{
> -	struct ssam_platform_profile_device *tpd;
> -
> -	tpd = ssam_device_get_drvdata(sdev);
> -	platform_profile_remove(&tpd->handler);
> +	return devm_platform_profile_register(&tpd->handler, tpd);
>   }
>   
>   static const struct ssam_device_id ssam_platform_profile_match[] = {
> @@ -253,7 +245,6 @@ MODULE_DEVICE_TABLE(ssam, ssam_platform_profile_match);
>   
>   static struct ssam_device_driver surface_platform_profile = {
>   	.probe = surface_platform_profile_probe,
> -	.remove = surface_platform_profile_remove,
>   	.match_table = ssam_platform_profile_match,
>   	.driver = {
>   		.name = "surface_platform_profile",
diff mbox series

Patch

diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
index 00a1178e552f..efb6653ed1d5 100644
--- a/drivers/platform/surface/surface_platform_profile.c
+++ b/drivers/platform/surface/surface_platform_profile.c
@@ -161,7 +161,7 @@  static int ssam_platform_profile_get(struct platform_profile_handler *pprof,
 	enum ssam_tmp_profile tp;
 	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);
 	if (status)
@@ -181,7 +181,7 @@  static int ssam_platform_profile_set(struct platform_profile_handler *pprof,
 	struct ssam_platform_profile_device *tpd;
 	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);
 	if (tp < 0)
@@ -234,15 +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, NULL);
-}
-
-static void surface_platform_profile_remove(struct ssam_device *sdev)
-{
-	struct ssam_platform_profile_device *tpd;
-
-	tpd = ssam_device_get_drvdata(sdev);
-	platform_profile_remove(&tpd->handler);
+	return devm_platform_profile_register(&tpd->handler, tpd);
 }
 
 static const struct ssam_device_id ssam_platform_profile_match[] = {
@@ -253,7 +245,6 @@  MODULE_DEVICE_TABLE(ssam, ssam_platform_profile_match);
 
 static struct ssam_device_driver surface_platform_profile = {
 	.probe = surface_platform_profile_probe,
-	.remove = surface_platform_profile_remove,
 	.match_table = ssam_platform_profile_match,
 	.driver = {
 		.name = "surface_platform_profile",