Linux-Hwmon Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH RESEND 0/3] hwmon: convert remaining drivers to i2c_new_dummy_device()
@ 2019-09-03 18:12 Wolfram Sang
  2019-09-03 18:12 ` [PATCH RESEND 1/3] hwmon: w83791d: convert to use devm_i2c_new_dummy_device Wolfram Sang
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Wolfram Sang @ 2019-09-03 18:12 UTC (permalink / raw)
  To: linux-i2c; +Cc: Wolfram Sang, linux-hwmon, linux-kernel

This series is part of a tree-wide movement to replace the I2C API call
'i2c_new_dummy' which returns NULL with its new counterpart returning an
ERRPTR.

This series fixes the remaining hwmon drivers which could not be
converted by my cocci script. So, I did it manually, yet all drivers
still follow the same pattern. Build tested by me and by buildbot. No
tests on HW have been performed, so testing is appreciated.

The branch is based on v5.3-rc2. A branch (with some more stuff included) can
be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/i2c/new_dummy


Wolfram Sang (3):
  hwmon: w83791d: convert to use devm_i2c_new_dummy_device
  hwmon: w83792d: convert to use devm_i2c_new_dummy_device
  hwmon: w83793d: convert to use devm_i2c_new_dummy_device

 drivers/hwmon/w83791d.c | 32 +++++++++-----------------------
 drivers/hwmon/w83792d.c | 32 +++++++++-----------------------
 drivers/hwmon/w83793.c  | 30 ++++++++----------------------
 3 files changed, 26 insertions(+), 68 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH RESEND 1/3] hwmon: w83791d: convert to use devm_i2c_new_dummy_device
  2019-09-03 18:12 [PATCH RESEND 0/3] hwmon: convert remaining drivers to i2c_new_dummy_device() Wolfram Sang
@ 2019-09-03 18:12 ` Wolfram Sang
  2019-09-03 19:44   ` Guenter Roeck
  2019-09-03 18:12 ` [PATCH RESEND 2/3] hwmon: w83792d: " Wolfram Sang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Wolfram Sang @ 2019-09-03 18:12 UTC (permalink / raw)
  To: linux-i2c
  Cc: Wolfram Sang, Marc Hulsman, Jean Delvare, Guenter Roeck,
	linux-hwmon, linux-kernel

And simplify the error handling.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/hwmon/w83791d.c | 32 +++++++++-----------------------
 1 file changed, 9 insertions(+), 23 deletions(-)

diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c
index 050ad4201691..aad8d4da5802 100644
--- a/drivers/hwmon/w83791d.c
+++ b/drivers/hwmon/w83791d.c
@@ -1260,7 +1260,7 @@ static int w83791d_detect_subclients(struct i2c_client *client)
 	struct i2c_adapter *adapter = client->adapter;
 	struct w83791d_data *data = i2c_get_clientdata(client);
 	int address = client->addr;
-	int i, id, err;
+	int i, id;
 	u8 val;
 
 	id = i2c_adapter_id(adapter);
@@ -1272,8 +1272,7 @@ static int w83791d_detect_subclients(struct i2c_client *client)
 					"invalid subclient "
 					"address %d; must be 0x48-0x4f\n",
 					force_subclients[i]);
-				err = -ENODEV;
-				goto error_sc_0;
+				return -ENODEV;
 			}
 		}
 		w83791d_write(client, W83791D_REG_I2C_SUBADDR,
@@ -1283,29 +1282,22 @@ static int w83791d_detect_subclients(struct i2c_client *client)
 
 	val = w83791d_read(client, W83791D_REG_I2C_SUBADDR);
 	if (!(val & 0x08))
-		data->lm75[0] = i2c_new_dummy(adapter, 0x48 + (val & 0x7));
+		data->lm75[0] = devm_i2c_new_dummy_device(&client->dev, adapter,
+							  0x48 + (val & 0x7));
 	if (!(val & 0x80)) {
-		if ((data->lm75[0] != NULL) &&
+		if (!IS_ERR(data->lm75[0]) &&
 				((val & 0x7) == ((val >> 4) & 0x7))) {
 			dev_err(&client->dev,
 				"duplicate addresses 0x%x, "
 				"use force_subclient\n",
 				data->lm75[0]->addr);
-			err = -ENODEV;
-			goto error_sc_1;
+			return -ENODEV;
 		}
-		data->lm75[1] = i2c_new_dummy(adapter,
-					      0x48 + ((val >> 4) & 0x7));
+		data->lm75[1] = devm_i2c_new_dummy_device(&client->dev, adapter,
+							  0x48 + ((val >> 4) & 0x7));
 	}
 
 	return 0;
-
-/* Undo inits in case of errors */
-
-error_sc_1:
-	i2c_unregister_device(data->lm75[0]);
-error_sc_0:
-	return err;
 }
 
 
@@ -1394,7 +1386,7 @@ static int w83791d_probe(struct i2c_client *client,
 	/* Register sysfs hooks */
 	err = sysfs_create_group(&client->dev.kobj, &w83791d_group);
 	if (err)
-		goto error3;
+		return err;
 
 	/* Check if pins of fan/pwm 4-5 are in use as GPIO */
 	has_fanpwm45 = w83791d_read(client, W83791D_REG_GPIO) & 0x10;
@@ -1419,9 +1411,6 @@ static int w83791d_probe(struct i2c_client *client,
 		sysfs_remove_group(&client->dev.kobj, &w83791d_group_fanpwm45);
 error4:
 	sysfs_remove_group(&client->dev.kobj, &w83791d_group);
-error3:
-	i2c_unregister_device(data->lm75[0]);
-	i2c_unregister_device(data->lm75[1]);
 	return err;
 }
 
@@ -1432,9 +1421,6 @@ static int w83791d_remove(struct i2c_client *client)
 	hwmon_device_unregister(data->hwmon_dev);
 	sysfs_remove_group(&client->dev.kobj, &w83791d_group);
 
-	i2c_unregister_device(data->lm75[0]);
-	i2c_unregister_device(data->lm75[1]);
-
 	return 0;
 }
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH RESEND 2/3] hwmon: w83792d: convert to use devm_i2c_new_dummy_device
  2019-09-03 18:12 [PATCH RESEND 0/3] hwmon: convert remaining drivers to i2c_new_dummy_device() Wolfram Sang
  2019-09-03 18:12 ` [PATCH RESEND 1/3] hwmon: w83791d: convert to use devm_i2c_new_dummy_device Wolfram Sang
@ 2019-09-03 18:12 ` " Wolfram Sang
  2019-09-03 19:45   ` Guenter Roeck
  2019-09-03 18:12 ` [PATCH RESEND 3/3] hwmon: w83793d: " Wolfram Sang
  2019-09-03 18:33 ` [PATCH RESEND 0/3] hwmon: convert remaining drivers to i2c_new_dummy_device() Guenter Roeck
  3 siblings, 1 reply; 9+ messages in thread
From: Wolfram Sang @ 2019-09-03 18:12 UTC (permalink / raw)
  To: linux-i2c
  Cc: Wolfram Sang, Jean Delvare, Guenter Roeck, linux-hwmon, linux-kernel

And simplify the error handling.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/hwmon/w83792d.c | 32 +++++++++-----------------------
 1 file changed, 9 insertions(+), 23 deletions(-)

diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index da8a6d62aa23..7fc8a1160c8f 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -924,7 +924,7 @@ store_sf2_level(struct device *dev, struct device_attribute *attr,
 static int
 w83792d_detect_subclients(struct i2c_client *new_client)
 {
-	int i, id, err;
+	int i, id;
 	int address = new_client->addr;
 	u8 val;
 	struct i2c_adapter *adapter = new_client->adapter;
@@ -938,8 +938,7 @@ w83792d_detect_subclients(struct i2c_client *new_client)
 				dev_err(&new_client->dev,
 					"invalid subclient address %d; must be 0x48-0x4f\n",
 					force_subclients[i]);
-				err = -ENODEV;
-				goto ERROR_SC_0;
+				return -ENODEV;
 			}
 		}
 		w83792d_write_value(new_client, W83792D_REG_I2C_SUBADDR,
@@ -949,28 +948,21 @@ w83792d_detect_subclients(struct i2c_client *new_client)
 
 	val = w83792d_read_value(new_client, W83792D_REG_I2C_SUBADDR);
 	if (!(val & 0x08))
-		data->lm75[0] = i2c_new_dummy(adapter, 0x48 + (val & 0x7));
+		data->lm75[0] = devm_i2c_new_dummy_device(&new_client->dev, adapter,
+							  0x48 + (val & 0x7));
 	if (!(val & 0x80)) {
-		if ((data->lm75[0] != NULL) &&
+		if (!IS_ERR(data->lm75[0]) &&
 			((val & 0x7) == ((val >> 4) & 0x7))) {
 			dev_err(&new_client->dev,
 				"duplicate addresses 0x%x, use force_subclient\n",
 				data->lm75[0]->addr);
-			err = -ENODEV;
-			goto ERROR_SC_1;
+			return -ENODEV;
 		}
-		data->lm75[1] = i2c_new_dummy(adapter,
-					      0x48 + ((val >> 4) & 0x7));
+		data->lm75[1] = devm_i2c_new_dummy_device(&new_client->dev, adapter,
+							  0x48 + ((val >> 4) & 0x7));
 	}
 
 	return 0;
-
-/* Undo inits in case of errors */
-
-ERROR_SC_1:
-	i2c_unregister_device(data->lm75[0]);
-ERROR_SC_0:
-	return err;
 }
 
 static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in, NULL, 0);
@@ -1396,7 +1388,7 @@ w83792d_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	/* Register sysfs hooks */
 	err = sysfs_create_group(&dev->kobj, &w83792d_group);
 	if (err)
-		goto exit_i2c_unregister;
+		return err;
 
 	/*
 	 * Read GPIO enable register to check if pins for fan 4,5 are used as
@@ -1441,9 +1433,6 @@ w83792d_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	sysfs_remove_group(&dev->kobj, &w83792d_group);
 	for (i = 0; i < ARRAY_SIZE(w83792d_group_fan); i++)
 		sysfs_remove_group(&dev->kobj, &w83792d_group_fan[i]);
-exit_i2c_unregister:
-	i2c_unregister_device(data->lm75[0]);
-	i2c_unregister_device(data->lm75[1]);
 	return err;
 }
 
@@ -1459,9 +1448,6 @@ w83792d_remove(struct i2c_client *client)
 		sysfs_remove_group(&client->dev.kobj,
 				   &w83792d_group_fan[i]);
 
-	i2c_unregister_device(data->lm75[0]);
-	i2c_unregister_device(data->lm75[1]);
-
 	return 0;
 }
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH RESEND 3/3] hwmon: w83793d: convert to use devm_i2c_new_dummy_device
  2019-09-03 18:12 [PATCH RESEND 0/3] hwmon: convert remaining drivers to i2c_new_dummy_device() Wolfram Sang
  2019-09-03 18:12 ` [PATCH RESEND 1/3] hwmon: w83791d: convert to use devm_i2c_new_dummy_device Wolfram Sang
  2019-09-03 18:12 ` [PATCH RESEND 2/3] hwmon: w83792d: " Wolfram Sang
@ 2019-09-03 18:12 ` " Wolfram Sang
  2019-09-03 19:46   ` Guenter Roeck
  2019-09-03 18:33 ` [PATCH RESEND 0/3] hwmon: convert remaining drivers to i2c_new_dummy_device() Guenter Roeck
  3 siblings, 1 reply; 9+ messages in thread
From: Wolfram Sang @ 2019-09-03 18:12 UTC (permalink / raw)
  To: linux-i2c
  Cc: Wolfram Sang, Rudolf Marek, Jean Delvare, Guenter Roeck,
	linux-hwmon, linux-kernel

And simplify the error handling.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/hwmon/w83793.c | 30 ++++++++----------------------
 1 file changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 46f5dfec8d0a..9df48b70c70c 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -1551,9 +1551,6 @@ static int w83793_remove(struct i2c_client *client)
 	for (i = 0; i < ARRAY_SIZE(w83793_temp); i++)
 		device_remove_file(dev, &w83793_temp[i].dev_attr);
 
-	i2c_unregister_device(data->lm75[0]);
-	i2c_unregister_device(data->lm75[1]);
-
 	/* Decrease data reference counter */
 	mutex_lock(&watchdog_data_mutex);
 	kref_put(&data->kref, w83793_release_resources);
@@ -1565,7 +1562,7 @@ static int w83793_remove(struct i2c_client *client)
 static int
 w83793_detect_subclients(struct i2c_client *client)
 {
-	int i, id, err;
+	int i, id;
 	int address = client->addr;
 	u8 tmp;
 	struct i2c_adapter *adapter = client->adapter;
@@ -1580,8 +1577,7 @@ w83793_detect_subclients(struct i2c_client *client)
 					"invalid subclient "
 					"address %d; must be 0x48-0x4f\n",
 					force_subclients[i]);
-				err = -EINVAL;
-				goto ERROR_SC_0;
+				return -EINVAL;
 			}
 		}
 		w83793_write_value(client, W83793_REG_I2C_SUBADDR,
@@ -1591,28 +1587,21 @@ w83793_detect_subclients(struct i2c_client *client)
 
 	tmp = w83793_read_value(client, W83793_REG_I2C_SUBADDR);
 	if (!(tmp & 0x08))
-		data->lm75[0] = i2c_new_dummy(adapter, 0x48 + (tmp & 0x7));
+		data->lm75[0] = devm_i2c_new_dummy_device(&client->dev, adapter,
+							  0x48 + (tmp & 0x7));
 	if (!(tmp & 0x80)) {
-		if ((data->lm75[0] != NULL)
+		if (!IS_ERR(data->lm75[0])
 		    && ((tmp & 0x7) == ((tmp >> 4) & 0x7))) {
 			dev_err(&client->dev,
 				"duplicate addresses 0x%x, "
 				"use force_subclients\n", data->lm75[0]->addr);
-			err = -ENODEV;
-			goto ERROR_SC_1;
+			return -ENODEV;
 		}
-		data->lm75[1] = i2c_new_dummy(adapter,
-					      0x48 + ((tmp >> 4) & 0x7));
+		data->lm75[1] = devm_i2c_new_dummy_device(&client->dev, adapter,
+							  0x48 + ((tmp >> 4) & 0x7));
 	}
 
 	return 0;
-
-	/* Undo inits in case of errors */
-
-ERROR_SC_1:
-	i2c_unregister_device(data->lm75[0]);
-ERROR_SC_0:
-	return err;
 }
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
@@ -1945,9 +1934,6 @@ static int w83793_probe(struct i2c_client *client,
 
 	for (i = 0; i < ARRAY_SIZE(w83793_temp); i++)
 		device_remove_file(dev, &w83793_temp[i].dev_attr);
-
-	i2c_unregister_device(data->lm75[0]);
-	i2c_unregister_device(data->lm75[1]);
 free_mem:
 	kfree(data);
 exit:
-- 
2.20.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RESEND 0/3] hwmon: convert remaining drivers to i2c_new_dummy_device()
  2019-09-03 18:12 [PATCH RESEND 0/3] hwmon: convert remaining drivers to i2c_new_dummy_device() Wolfram Sang
                   ` (2 preceding siblings ...)
  2019-09-03 18:12 ` [PATCH RESEND 3/3] hwmon: w83793d: " Wolfram Sang
@ 2019-09-03 18:33 ` Guenter Roeck
  2019-09-03 18:37   ` Wolfram Sang
  3 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2019-09-03 18:33 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, linux-hwmon, linux-kernel

On Tue, Sep 03, 2019 at 08:12:53PM +0200, Wolfram Sang wrote:
> This series is part of a tree-wide movement to replace the I2C API call
> 'i2c_new_dummy' which returns NULL with its new counterpart returning an
> ERRPTR.
> 
> This series fixes the remaining hwmon drivers which could not be
> converted by my cocci script. So, I did it manually, yet all drivers
> still follow the same pattern. Build tested by me and by buildbot. No
> tests on HW have been performed, so testing is appreciated.
> 
I still have the previous version (with RFT) in my queue.
Question is what to do with it; I have not seen any test feedback.
I tend to just apply the series and wait for fallout.
Any objections ?

Guenter

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RESEND 0/3] hwmon: convert remaining drivers to i2c_new_dummy_device()
  2019-09-03 18:33 ` [PATCH RESEND 0/3] hwmon: convert remaining drivers to i2c_new_dummy_device() Guenter Roeck
@ 2019-09-03 18:37   ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2019-09-03 18:37 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Wolfram Sang, linux-i2c, linux-hwmon, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 927 bytes --]

On Tue, Sep 03, 2019 at 11:33:40AM -0700, Guenter Roeck wrote:
> On Tue, Sep 03, 2019 at 08:12:53PM +0200, Wolfram Sang wrote:
> > This series is part of a tree-wide movement to replace the I2C API call
> > 'i2c_new_dummy' which returns NULL with its new counterpart returning an
> > ERRPTR.
> > 
> > This series fixes the remaining hwmon drivers which could not be
> > converted by my cocci script. So, I did it manually, yet all drivers
> > still follow the same pattern. Build tested by me and by buildbot. No
> > tests on HW have been performed, so testing is appreciated.
> > 
> I still have the previous version (with RFT) in my queue.
> Question is what to do with it; I have not seen any test feedback.
> I tend to just apply the series and wait for fallout.
> Any objections ?

For the sake of the API conversion, I would appreciate this much. Of
course, I'll be there if there is fallout. Thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RESEND 1/3] hwmon: w83791d: convert to use devm_i2c_new_dummy_device
  2019-09-03 18:12 ` [PATCH RESEND 1/3] hwmon: w83791d: convert to use devm_i2c_new_dummy_device Wolfram Sang
@ 2019-09-03 19:44   ` Guenter Roeck
  0 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2019-09-03 19:44 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c, Marc Hulsman, Jean Delvare, linux-hwmon, linux-kernel

On Tue, Sep 03, 2019 at 08:12:54PM +0200, Wolfram Sang wrote:
> And simplify the error handling.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  drivers/hwmon/w83791d.c | 32 +++++++++-----------------------
>  1 file changed, 9 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c
> index 050ad4201691..aad8d4da5802 100644
> --- a/drivers/hwmon/w83791d.c
> +++ b/drivers/hwmon/w83791d.c
> @@ -1260,7 +1260,7 @@ static int w83791d_detect_subclients(struct i2c_client *client)
>  	struct i2c_adapter *adapter = client->adapter;
>  	struct w83791d_data *data = i2c_get_clientdata(client);
>  	int address = client->addr;
> -	int i, id, err;
> +	int i, id;
>  	u8 val;
>  
>  	id = i2c_adapter_id(adapter);
> @@ -1272,8 +1272,7 @@ static int w83791d_detect_subclients(struct i2c_client *client)
>  					"invalid subclient "
>  					"address %d; must be 0x48-0x4f\n",
>  					force_subclients[i]);
> -				err = -ENODEV;
> -				goto error_sc_0;
> +				return -ENODEV;
>  			}
>  		}
>  		w83791d_write(client, W83791D_REG_I2C_SUBADDR,
> @@ -1283,29 +1282,22 @@ static int w83791d_detect_subclients(struct i2c_client *client)
>  
>  	val = w83791d_read(client, W83791D_REG_I2C_SUBADDR);
>  	if (!(val & 0x08))
> -		data->lm75[0] = i2c_new_dummy(adapter, 0x48 + (val & 0x7));
> +		data->lm75[0] = devm_i2c_new_dummy_device(&client->dev, adapter,
> +							  0x48 + (val & 0x7));
>  	if (!(val & 0x80)) {
> -		if ((data->lm75[0] != NULL) &&
> +		if (!IS_ERR(data->lm75[0]) &&
>  				((val & 0x7) == ((val >> 4) & 0x7))) {
>  			dev_err(&client->dev,
>  				"duplicate addresses 0x%x, "
>  				"use force_subclient\n",
>  				data->lm75[0]->addr);
> -			err = -ENODEV;
> -			goto error_sc_1;
> +			return -ENODEV;
>  		}
> -		data->lm75[1] = i2c_new_dummy(adapter,
> -					      0x48 + ((val >> 4) & 0x7));
> +		data->lm75[1] = devm_i2c_new_dummy_device(&client->dev, adapter,
> +							  0x48 + ((val >> 4) & 0x7));
>  	}
>  
>  	return 0;
> -
> -/* Undo inits in case of errors */
> -
> -error_sc_1:
> -	i2c_unregister_device(data->lm75[0]);
> -error_sc_0:
> -	return err;
>  }
>  
>  
> @@ -1394,7 +1386,7 @@ static int w83791d_probe(struct i2c_client *client,
>  	/* Register sysfs hooks */
>  	err = sysfs_create_group(&client->dev.kobj, &w83791d_group);
>  	if (err)
> -		goto error3;
> +		return err;
>  
>  	/* Check if pins of fan/pwm 4-5 are in use as GPIO */
>  	has_fanpwm45 = w83791d_read(client, W83791D_REG_GPIO) & 0x10;
> @@ -1419,9 +1411,6 @@ static int w83791d_probe(struct i2c_client *client,
>  		sysfs_remove_group(&client->dev.kobj, &w83791d_group_fanpwm45);
>  error4:
>  	sysfs_remove_group(&client->dev.kobj, &w83791d_group);
> -error3:
> -	i2c_unregister_device(data->lm75[0]);
> -	i2c_unregister_device(data->lm75[1]);
>  	return err;
>  }
>  
> @@ -1432,9 +1421,6 @@ static int w83791d_remove(struct i2c_client *client)
>  	hwmon_device_unregister(data->hwmon_dev);
>  	sysfs_remove_group(&client->dev.kobj, &w83791d_group);
>  
> -	i2c_unregister_device(data->lm75[0]);
> -	i2c_unregister_device(data->lm75[1]);
> -
>  	return 0;
>  }
>  

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RESEND 2/3] hwmon: w83792d: convert to use devm_i2c_new_dummy_device
  2019-09-03 18:12 ` [PATCH RESEND 2/3] hwmon: w83792d: " Wolfram Sang
@ 2019-09-03 19:45   ` Guenter Roeck
  0 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2019-09-03 19:45 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, Jean Delvare, linux-hwmon, linux-kernel

On Tue, Sep 03, 2019 at 08:12:55PM +0200, Wolfram Sang wrote:
> And simplify the error handling.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  drivers/hwmon/w83792d.c | 32 +++++++++-----------------------
>  1 file changed, 9 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
> index da8a6d62aa23..7fc8a1160c8f 100644
> --- a/drivers/hwmon/w83792d.c
> +++ b/drivers/hwmon/w83792d.c
> @@ -924,7 +924,7 @@ store_sf2_level(struct device *dev, struct device_attribute *attr,
>  static int
>  w83792d_detect_subclients(struct i2c_client *new_client)
>  {
> -	int i, id, err;
> +	int i, id;
>  	int address = new_client->addr;
>  	u8 val;
>  	struct i2c_adapter *adapter = new_client->adapter;
> @@ -938,8 +938,7 @@ w83792d_detect_subclients(struct i2c_client *new_client)
>  				dev_err(&new_client->dev,
>  					"invalid subclient address %d; must be 0x48-0x4f\n",
>  					force_subclients[i]);
> -				err = -ENODEV;
> -				goto ERROR_SC_0;
> +				return -ENODEV;
>  			}
>  		}
>  		w83792d_write_value(new_client, W83792D_REG_I2C_SUBADDR,
> @@ -949,28 +948,21 @@ w83792d_detect_subclients(struct i2c_client *new_client)
>  
>  	val = w83792d_read_value(new_client, W83792D_REG_I2C_SUBADDR);
>  	if (!(val & 0x08))
> -		data->lm75[0] = i2c_new_dummy(adapter, 0x48 + (val & 0x7));
> +		data->lm75[0] = devm_i2c_new_dummy_device(&new_client->dev, adapter,
> +							  0x48 + (val & 0x7));
>  	if (!(val & 0x80)) {
> -		if ((data->lm75[0] != NULL) &&
> +		if (!IS_ERR(data->lm75[0]) &&
>  			((val & 0x7) == ((val >> 4) & 0x7))) {
>  			dev_err(&new_client->dev,
>  				"duplicate addresses 0x%x, use force_subclient\n",
>  				data->lm75[0]->addr);
> -			err = -ENODEV;
> -			goto ERROR_SC_1;
> +			return -ENODEV;
>  		}
> -		data->lm75[1] = i2c_new_dummy(adapter,
> -					      0x48 + ((val >> 4) & 0x7));
> +		data->lm75[1] = devm_i2c_new_dummy_device(&new_client->dev, adapter,
> +							  0x48 + ((val >> 4) & 0x7));
>  	}
>  
>  	return 0;
> -
> -/* Undo inits in case of errors */
> -
> -ERROR_SC_1:
> -	i2c_unregister_device(data->lm75[0]);
> -ERROR_SC_0:
> -	return err;
>  }
>  
>  static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in, NULL, 0);
> @@ -1396,7 +1388,7 @@ w83792d_probe(struct i2c_client *client, const struct i2c_device_id *id)
>  	/* Register sysfs hooks */
>  	err = sysfs_create_group(&dev->kobj, &w83792d_group);
>  	if (err)
> -		goto exit_i2c_unregister;
> +		return err;
>  
>  	/*
>  	 * Read GPIO enable register to check if pins for fan 4,5 are used as
> @@ -1441,9 +1433,6 @@ w83792d_probe(struct i2c_client *client, const struct i2c_device_id *id)
>  	sysfs_remove_group(&dev->kobj, &w83792d_group);
>  	for (i = 0; i < ARRAY_SIZE(w83792d_group_fan); i++)
>  		sysfs_remove_group(&dev->kobj, &w83792d_group_fan[i]);
> -exit_i2c_unregister:
> -	i2c_unregister_device(data->lm75[0]);
> -	i2c_unregister_device(data->lm75[1]);
>  	return err;
>  }
>  
> @@ -1459,9 +1448,6 @@ w83792d_remove(struct i2c_client *client)
>  		sysfs_remove_group(&client->dev.kobj,
>  				   &w83792d_group_fan[i]);
>  
> -	i2c_unregister_device(data->lm75[0]);
> -	i2c_unregister_device(data->lm75[1]);
> -
>  	return 0;
>  }
>  
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH RESEND 3/3] hwmon: w83793d: convert to use devm_i2c_new_dummy_device
  2019-09-03 18:12 ` [PATCH RESEND 3/3] hwmon: w83793d: " Wolfram Sang
@ 2019-09-03 19:46   ` Guenter Roeck
  0 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2019-09-03 19:46 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-i2c, Rudolf Marek, Jean Delvare, linux-hwmon, linux-kernel

On Tue, Sep 03, 2019 at 08:12:56PM +0200, Wolfram Sang wrote:
> And simplify the error handling.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  drivers/hwmon/w83793.c | 30 ++++++++----------------------
>  1 file changed, 8 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
> index 46f5dfec8d0a..9df48b70c70c 100644
> --- a/drivers/hwmon/w83793.c
> +++ b/drivers/hwmon/w83793.c
> @@ -1551,9 +1551,6 @@ static int w83793_remove(struct i2c_client *client)
>  	for (i = 0; i < ARRAY_SIZE(w83793_temp); i++)
>  		device_remove_file(dev, &w83793_temp[i].dev_attr);
>  
> -	i2c_unregister_device(data->lm75[0]);
> -	i2c_unregister_device(data->lm75[1]);
> -
>  	/* Decrease data reference counter */
>  	mutex_lock(&watchdog_data_mutex);
>  	kref_put(&data->kref, w83793_release_resources);
> @@ -1565,7 +1562,7 @@ static int w83793_remove(struct i2c_client *client)
>  static int
>  w83793_detect_subclients(struct i2c_client *client)
>  {
> -	int i, id, err;
> +	int i, id;
>  	int address = client->addr;
>  	u8 tmp;
>  	struct i2c_adapter *adapter = client->adapter;
> @@ -1580,8 +1577,7 @@ w83793_detect_subclients(struct i2c_client *client)
>  					"invalid subclient "
>  					"address %d; must be 0x48-0x4f\n",
>  					force_subclients[i]);
> -				err = -EINVAL;
> -				goto ERROR_SC_0;
> +				return -EINVAL;
>  			}
>  		}
>  		w83793_write_value(client, W83793_REG_I2C_SUBADDR,
> @@ -1591,28 +1587,21 @@ w83793_detect_subclients(struct i2c_client *client)
>  
>  	tmp = w83793_read_value(client, W83793_REG_I2C_SUBADDR);
>  	if (!(tmp & 0x08))
> -		data->lm75[0] = i2c_new_dummy(adapter, 0x48 + (tmp & 0x7));
> +		data->lm75[0] = devm_i2c_new_dummy_device(&client->dev, adapter,
> +							  0x48 + (tmp & 0x7));
>  	if (!(tmp & 0x80)) {
> -		if ((data->lm75[0] != NULL)
> +		if (!IS_ERR(data->lm75[0])
>  		    && ((tmp & 0x7) == ((tmp >> 4) & 0x7))) {
>  			dev_err(&client->dev,
>  				"duplicate addresses 0x%x, "
>  				"use force_subclients\n", data->lm75[0]->addr);
> -			err = -ENODEV;
> -			goto ERROR_SC_1;
> +			return -ENODEV;
>  		}
> -		data->lm75[1] = i2c_new_dummy(adapter,
> -					      0x48 + ((tmp >> 4) & 0x7));
> +		data->lm75[1] = devm_i2c_new_dummy_device(&client->dev, adapter,
> +							  0x48 + ((tmp >> 4) & 0x7));
>  	}
>  
>  	return 0;
> -
> -	/* Undo inits in case of errors */
> -
> -ERROR_SC_1:
> -	i2c_unregister_device(data->lm75[0]);
> -ERROR_SC_0:
> -	return err;
>  }
>  
>  /* Return 0 if detection is successful, -ENODEV otherwise */
> @@ -1945,9 +1934,6 @@ static int w83793_probe(struct i2c_client *client,
>  
>  	for (i = 0; i < ARRAY_SIZE(w83793_temp); i++)
>  		device_remove_file(dev, &w83793_temp[i].dev_attr);
> -
> -	i2c_unregister_device(data->lm75[0]);
> -	i2c_unregister_device(data->lm75[1]);
>  free_mem:
>  	kfree(data);
>  exit:
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-03 18:12 [PATCH RESEND 0/3] hwmon: convert remaining drivers to i2c_new_dummy_device() Wolfram Sang
2019-09-03 18:12 ` [PATCH RESEND 1/3] hwmon: w83791d: convert to use devm_i2c_new_dummy_device Wolfram Sang
2019-09-03 19:44   ` Guenter Roeck
2019-09-03 18:12 ` [PATCH RESEND 2/3] hwmon: w83792d: " Wolfram Sang
2019-09-03 19:45   ` Guenter Roeck
2019-09-03 18:12 ` [PATCH RESEND 3/3] hwmon: w83793d: " Wolfram Sang
2019-09-03 19:46   ` Guenter Roeck
2019-09-03 18:33 ` [PATCH RESEND 0/3] hwmon: convert remaining drivers to i2c_new_dummy_device() Guenter Roeck
2019-09-03 18:37   ` Wolfram Sang

Linux-Hwmon Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-hwmon/0 linux-hwmon/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-hwmon linux-hwmon/ https://lore.kernel.org/linux-hwmon \
		linux-hwmon@vger.kernel.org linux-hwmon@archiver.kernel.org
	public-inbox-index linux-hwmon


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-hwmon


AGPL code for this site: git clone https://public-inbox.org/ public-inbox