lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190903194501.GA32299@roeck-us.net>
Date:   Tue, 3 Sep 2019 12:45:02 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Wolfram Sang <wsa+renesas@...g-engineering.com>
Cc:     linux-i2c@...r.kernel.org, Jean Delvare <jdelvare@...e.com>,
        linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH RESEND 2/3] hwmon: w83792d: convert to use
 devm_i2c_new_dummy_device

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@...g-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
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ