diff mbox

[v1,09/15] hwmon: (w83781d) Remove duplicate NULL check

Message ID 20171031142149.32512-9-andriy.shevchenko@linux.intel.com (mailing list archive)
State Accepted
Headers show

Commit Message

Andy Shevchenko Oct. 31, 2017, 2:21 p.m. UTC
Since i2c_unregister_device() became NULL-aware we may remove duplicate
NULL check.

Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hwmon/w83781d.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Jean Delvare Oct. 31, 2017, 6:03 p.m. UTC | #1
On Tue, 31 Oct 2017 16:21:43 +0200, Andy Shevchenko wrote:
> Since i2c_unregister_device() became NULL-aware we may remove duplicate
> NULL check.
> 
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: linux-hwmon@vger.kernel.org
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/hwmon/w83781d.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
> index 246fb2365126..2b0f182daa87 100644
> --- a/drivers/hwmon/w83781d.c
> +++ b/drivers/hwmon/w83781d.c
> @@ -1246,10 +1246,8 @@ w83781d_probe(struct i2c_client *client, const struct i2c_device_id *id)
>  
>   exit_remove_files:
>  	w83781d_remove_files(dev);
> -	if (data->lm75[0])
> -		i2c_unregister_device(data->lm75[0]);
> -	if (data->lm75[1])
> -		i2c_unregister_device(data->lm75[1]);
> +	i2c_unregister_device(data->lm75[0]);
> +	i2c_unregister_device(data->lm75[1]);
>  	return err;
>  }
>  
> @@ -1262,10 +1260,8 @@ w83781d_remove(struct i2c_client *client)
>  	hwmon_device_unregister(data->hwmon_dev);
>  	w83781d_remove_files(dev);
>  
> -	if (data->lm75[0])
> -		i2c_unregister_device(data->lm75[0]);
> -	if (data->lm75[1])
> -		i2c_unregister_device(data->lm75[1]);
> +	i2c_unregister_device(data->lm75[0]);
> +	i2c_unregister_device(data->lm75[1]);
>  
>  	return 0;
>  }

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Guenter Roeck Nov. 1, 2017, 1:19 p.m. UTC | #2
On 10/31/2017 07:21 AM, Andy Shevchenko wrote:
> Since i2c_unregister_device() became NULL-aware we may remove duplicate
> NULL check.
> 
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: linux-hwmon@vger.kernel.org
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

I'll keep the hwmon patches from this series on hold until the changes
to i2c_unregister_device make it into the tree. Ok with me if the patches
are merged through some other tree.

Guenter

> ---
>   drivers/hwmon/w83781d.c | 12 ++++--------
>   1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
> index 246fb2365126..2b0f182daa87 100644
> --- a/drivers/hwmon/w83781d.c
> +++ b/drivers/hwmon/w83781d.c
> @@ -1246,10 +1246,8 @@ w83781d_probe(struct i2c_client *client, const struct i2c_device_id *id)
>   
>    exit_remove_files:
>   	w83781d_remove_files(dev);
> -	if (data->lm75[0])
> -		i2c_unregister_device(data->lm75[0]);
> -	if (data->lm75[1])
> -		i2c_unregister_device(data->lm75[1]);
> +	i2c_unregister_device(data->lm75[0]);
> +	i2c_unregister_device(data->lm75[1]);
>   	return err;
>   }
>   
> @@ -1262,10 +1260,8 @@ w83781d_remove(struct i2c_client *client)
>   	hwmon_device_unregister(data->hwmon_dev);
>   	w83781d_remove_files(dev);
>   
> -	if (data->lm75[0])
> -		i2c_unregister_device(data->lm75[0]);
> -	if (data->lm75[1])
> -		i2c_unregister_device(data->lm75[1]);
> +	i2c_unregister_device(data->lm75[0]);
> +	i2c_unregister_device(data->lm75[1]);
>   
>   	return 0;
>   }
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andy Shevchenko Nov. 1, 2017, 1:26 p.m. UTC | #3
On Wed, 2017-11-01 at 06:19 -0700, Guenter Roeck wrote:
> On 10/31/2017 07:21 AM, Andy Shevchenko wrote:
> > Since i2c_unregister_device() became NULL-aware we may remove
> > duplicate
> > NULL check.
> > 
> > Cc: Jean Delvare <jdelvare@suse.com>
> > Cc: Guenter Roeck <linux@roeck-us.net>
> > Cc: linux-hwmon@vger.kernel.org
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> I'll keep the hwmon patches from this series on hold until the changes
> to i2c_unregister_device make it into the tree. Ok with me if the
> patches
> are merged through some other tree.

Wolfram, what do you think?

At least we have couple of options:
- apply i2c core patch now and wait until rc1
- apply everything through i2c tree
- ...

> 
> Guenter
> 
> > ---
> >   drivers/hwmon/w83781d.c | 12 ++++--------
> >   1 file changed, 4 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
> > index 246fb2365126..2b0f182daa87 100644
> > --- a/drivers/hwmon/w83781d.c
> > +++ b/drivers/hwmon/w83781d.c
> > @@ -1246,10 +1246,8 @@ w83781d_probe(struct i2c_client *client,
> > const struct i2c_device_id *id)
> >   
> >    exit_remove_files:
> >   	w83781d_remove_files(dev);
> > -	if (data->lm75[0])
> > -		i2c_unregister_device(data->lm75[0]);
> > -	if (data->lm75[1])
> > -		i2c_unregister_device(data->lm75[1]);
> > +	i2c_unregister_device(data->lm75[0]);
> > +	i2c_unregister_device(data->lm75[1]);
> >   	return err;
> >   }
> >   
> > @@ -1262,10 +1260,8 @@ w83781d_remove(struct i2c_client *client)
> >   	hwmon_device_unregister(data->hwmon_dev);
> >   	w83781d_remove_files(dev);
> >   
> > -	if (data->lm75[0])
> > -		i2c_unregister_device(data->lm75[0]);
> > -	if (data->lm75[1])
> > -		i2c_unregister_device(data->lm75[1]);
> > +	i2c_unregister_device(data->lm75[0]);
> > +	i2c_unregister_device(data->lm75[1]);
> >   
> >   	return 0;
> >   }
> > 
> 
>
Wolfram Sang Nov. 1, 2017, 11:07 p.m. UTC | #4
> > I'll keep the hwmon patches from this series on hold until the changes
> > to i2c_unregister_device make it into the tree. Ok with me if the
> > patches
> > are merged through some other tree.
> 
> Wolfram, what do you think?
> 
> At least we have couple of options:
> - apply i2c core patch now and wait until rc1
> - apply everything through i2c tree
> - ...

I just applied patches 1-3 to my for-4.15 branch. So, other subsystems
could pick it at rc1 time. If you are going to resend, you can add my

Acked-by: Wolfram Sang <wsa@the-dreams.de>

to all of the remaining patches.
Andy Shevchenko Nov. 2, 2017, 12:23 p.m. UTC | #5
On Thu, 2017-11-02 at 00:07 +0100, Wolfram Sang wrote:
> > > I'll keep the hwmon patches from this series on hold until the
> > > changes
> > > to i2c_unregister_device make it into the tree. Ok with me if the
> > > patches
> > > are merged through some other tree.
> > 
> > Wolfram, what do you think?
> > 
> > At least we have couple of options:
> > - apply i2c core patch now and wait until rc1
> > - apply everything through i2c tree
> > - ...
> 
> I just applied patches 1-3 to my for-4.15 branch. So, other subsystems
> could pick it at rc1 time. If you are going to resend, you can add my
> 
> Acked-by: Wolfram Sang <wsa@the-dreams.de>
> 
> to all of the remaining patches.

Noted, thanks!
diff mbox

Patch

diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index 246fb2365126..2b0f182daa87 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -1246,10 +1246,8 @@  w83781d_probe(struct i2c_client *client, const struct i2c_device_id *id)
 
  exit_remove_files:
 	w83781d_remove_files(dev);
-	if (data->lm75[0])
-		i2c_unregister_device(data->lm75[0]);
-	if (data->lm75[1])
-		i2c_unregister_device(data->lm75[1]);
+	i2c_unregister_device(data->lm75[0]);
+	i2c_unregister_device(data->lm75[1]);
 	return err;
 }
 
@@ -1262,10 +1260,8 @@  w83781d_remove(struct i2c_client *client)
 	hwmon_device_unregister(data->hwmon_dev);
 	w83781d_remove_files(dev);
 
-	if (data->lm75[0])
-		i2c_unregister_device(data->lm75[0]);
-	if (data->lm75[1])
-		i2c_unregister_device(data->lm75[1]);
+	i2c_unregister_device(data->lm75[0]);
+	i2c_unregister_device(data->lm75[1]);
 
 	return 0;
 }