diff mbox series

[v1,04/10] hwmon: adt7x10: avoid storing hwinfo dev into private data

Message ID 20211221123944.2683245-4-demonsingur@gmail.com (mailing list archive)
State Changes Requested
Headers show
Series [v1,01/10] hwmon: adt7x10: store bus_dev in private data | expand

Commit Message

Cosmin Tanislav Dec. 21, 2021, 12:39 p.m. UTC
From: Cosmin Tanislav <cosmin.tanislav@analog.com>

Store it later in the code to reduce the number of references
to the private data structure, so it is easier to remove it
altogether.

Signed-off-by: Cosmin Tanislav <cosmin.tanislav@analog.com>
---
 drivers/hwmon/adt7x10.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Guenter Roeck Dec. 21, 2021, 3:16 p.m. UTC | #1
On 12/21/21 4:39 AM, Cosmin Tanislav wrote:
> From: Cosmin Tanislav <cosmin.tanislav@analog.com>
> 
> Store it later in the code to reduce the number of references
> to the private data structure, so it is easier to remove it
> altogether.
> 

This patch pretty pointless as it is only used in the remove function,
and that won't need it after the devm_ registration function is used.

Guenter

> Signed-off-by: Cosmin Tanislav <cosmin.tanislav@analog.com>
> ---
>   drivers/hwmon/adt7x10.c | 11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c
> index 48adc0344e88..25c1ab199658 100644
> --- a/drivers/hwmon/adt7x10.c
> +++ b/drivers/hwmon/adt7x10.c
> @@ -351,6 +351,7 @@ int adt7x10_probe(struct device *dev, const char *name, int irq,
>   		  const struct adt7x10_ops *ops)
>   {
>   	struct adt7x10_data *data;
> +	struct device *hdev;
>   	int ret;
>   
>   	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> @@ -395,9 +396,9 @@ int adt7x10_probe(struct device *dev, const char *name, int irq,
>   	if (ret)
>   		goto exit_restore;
>   
> -	data->hwmon_dev = hwmon_device_register(dev);
> -	if (IS_ERR(data->hwmon_dev)) {
> -		ret = PTR_ERR(data->hwmon_dev);
> +	hdev = hwmon_device_register(dev);
> +	if (IS_ERR(hdev)) {
> +		ret = PTR_ERR(hdev);
>   		goto exit_remove;
>   	}
>   
> @@ -411,10 +412,12 @@ int adt7x10_probe(struct device *dev, const char *name, int irq,
>   			goto exit_hwmon_device_unregister;
>   	}
>   
> +	data->hwmon_dev = hdev;
> +
>   	return 0;
>   
>   exit_hwmon_device_unregister:
> -	hwmon_device_unregister(data->hwmon_dev);
> +	hwmon_device_unregister(hdev);
>   exit_remove:
>   	sysfs_remove_group(&dev->kobj, &adt7x10_group);
>   exit_restore:
>
diff mbox series

Patch

diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c
index 48adc0344e88..25c1ab199658 100644
--- a/drivers/hwmon/adt7x10.c
+++ b/drivers/hwmon/adt7x10.c
@@ -351,6 +351,7 @@  int adt7x10_probe(struct device *dev, const char *name, int irq,
 		  const struct adt7x10_ops *ops)
 {
 	struct adt7x10_data *data;
+	struct device *hdev;
 	int ret;
 
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
@@ -395,9 +396,9 @@  int adt7x10_probe(struct device *dev, const char *name, int irq,
 	if (ret)
 		goto exit_restore;
 
-	data->hwmon_dev = hwmon_device_register(dev);
-	if (IS_ERR(data->hwmon_dev)) {
-		ret = PTR_ERR(data->hwmon_dev);
+	hdev = hwmon_device_register(dev);
+	if (IS_ERR(hdev)) {
+		ret = PTR_ERR(hdev);
 		goto exit_remove;
 	}
 
@@ -411,10 +412,12 @@  int adt7x10_probe(struct device *dev, const char *name, int irq,
 			goto exit_hwmon_device_unregister;
 	}
 
+	data->hwmon_dev = hdev;
+
 	return 0;
 
 exit_hwmon_device_unregister:
-	hwmon_device_unregister(data->hwmon_dev);
+	hwmon_device_unregister(hdev);
 exit_remove:
 	sysfs_remove_group(&dev->kobj, &adt7x10_group);
 exit_restore: