diff mbox series

[v2,3/6] hwmon: (dell-smm-hwmon) Use devm_add_action_or_reset()

Message ID 20210528173716.10975-4-W_Armin@gmx.de (mailing list archive)
State Superseded
Headers show
Series Convert to new hwmon registration api | expand

Commit Message

Armin Wolf May 28, 2021, 5:37 p.m. UTC
From: Armin Wolf <W_Armin@gmx.de>

Use devm_add_action_or_reset() for calling i8k_exit_procfs()
so the remove() function in dell_smm_driver can be omitted.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/hwmon/dell-smm-hwmon.c | 28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

--
2.20.1

Comments

Pali Rohár May 28, 2021, 7:02 p.m. UTC | #1
On Friday 28 May 2021 19:37:13 W_Armin@gmx.de wrote:
> From: Armin Wolf <W_Armin@gmx.de>
> 
> Use devm_add_action_or_reset() for calling i8k_exit_procfs()
> so the remove() function in dell_smm_driver can be omitted.
> 
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>

Looks good!

Reviewed-by: Pali Rohár <pali@kernel.org>
Tested-by: Pali Rohár <pali@kernel.org>

> ---
>  drivers/hwmon/dell-smm-hwmon.c | 28 +++++++++-------------------
>  1 file changed, 9 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
> index deba8819164d..ed2c42badf1a 100644
> --- a/drivers/hwmon/dell-smm-hwmon.c
> +++ b/drivers/hwmon/dell-smm-hwmon.c
> @@ -605,24 +605,22 @@ static const struct proc_ops i8k_proc_ops = {
>  	.proc_ioctl	= i8k_ioctl,
>  };
> 
> -static void __init i8k_init_procfs(void)
> +static void i8k_exit_procfs(void *param)
>  {
> -	/* Register the proc entry */
> -	proc_create("i8k", 0, NULL, &i8k_proc_ops);
> +	remove_proc_entry("i8k", NULL);
>  }
> 
> -static void __exit i8k_exit_procfs(void)
> +static void __init i8k_init_procfs(struct device *dev)
>  {
> -	remove_proc_entry("i8k", NULL);
> +	/* Register the proc entry */
> +	proc_create("i8k", 0, NULL, &i8k_proc_ops);
> +
> +	devm_add_action_or_reset(dev, i8k_exit_procfs, NULL);
>  }
> 
>  #else
> 
> -static inline void __init i8k_init_procfs(void)
> -{
> -}
> -
> -static inline void __exit i8k_exit_procfs(void)
> +static void __init i8k_init_procfs(struct device *dev)
>  {
>  }
> 
> @@ -1287,14 +1285,7 @@ static int __init dell_smm_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
> 
> -	i8k_init_procfs();
> -
> -	return 0;
> -}
> -
> -static int dell_smm_remove(struct platform_device *pdev)
> -{
> -	i8k_exit_procfs();
> +	i8k_init_procfs(&pdev->dev);
> 
>  	return 0;
>  }
> @@ -1303,7 +1294,6 @@ static struct platform_driver dell_smm_driver = {
>  	.driver		= {
>  		.name	= KBUILD_MODNAME,
>  	},
> -	.remove		= dell_smm_remove,
>  };
> 
>  static struct platform_device *dell_smm_device;
> --
> 2.20.1
>
diff mbox series

Patch

diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index deba8819164d..ed2c42badf1a 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -605,24 +605,22 @@  static const struct proc_ops i8k_proc_ops = {
 	.proc_ioctl	= i8k_ioctl,
 };

-static void __init i8k_init_procfs(void)
+static void i8k_exit_procfs(void *param)
 {
-	/* Register the proc entry */
-	proc_create("i8k", 0, NULL, &i8k_proc_ops);
+	remove_proc_entry("i8k", NULL);
 }

-static void __exit i8k_exit_procfs(void)
+static void __init i8k_init_procfs(struct device *dev)
 {
-	remove_proc_entry("i8k", NULL);
+	/* Register the proc entry */
+	proc_create("i8k", 0, NULL, &i8k_proc_ops);
+
+	devm_add_action_or_reset(dev, i8k_exit_procfs, NULL);
 }

 #else

-static inline void __init i8k_init_procfs(void)
-{
-}
-
-static inline void __exit i8k_exit_procfs(void)
+static void __init i8k_init_procfs(struct device *dev)
 {
 }

@@ -1287,14 +1285,7 @@  static int __init dell_smm_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;

-	i8k_init_procfs();
-
-	return 0;
-}
-
-static int dell_smm_remove(struct platform_device *pdev)
-{
-	i8k_exit_procfs();
+	i8k_init_procfs(&pdev->dev);

 	return 0;
 }
@@ -1303,7 +1294,6 @@  static struct platform_driver dell_smm_driver = {
 	.driver		= {
 		.name	= KBUILD_MODNAME,
 	},
-	.remove		= dell_smm_remove,
 };

 static struct platform_device *dell_smm_device;