[lm-sensors] [PATCH 86/95] hwmon: (w83l785ts) Convert to use devm_ functions

Jean Delvare khali at linux-fr.org
Sun Jun 17 21:42:22 CEST 2012


Hi Guenter,

On Fri, 15 Jun 2012 08:24:07 -0700, Guenter Roeck wrote:
> Convert to use devm_ functions to reduce code size and simplify the code.
> 
> Also, in probe function, rename new_client variable to client, and introduce
> local variable dev to point to client->dev, to simplify the code further and
> improve readability.

Best done as two separate patches...

> Signed-off-by: Guenter Roeck <linux at roeck-us.net>
> ---
>  drivers/hwmon/w83l785ts.c |   30 +++++++++++-------------------
>  1 file changed, 11 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c
> index 5f14e38..35671f5 100644
> --- a/drivers/hwmon/w83l785ts.c
> +++ b/drivers/hwmon/w83l785ts.c
> @@ -176,19 +176,18 @@ static int w83l785ts_detect(struct i2c_client *client,
>  	return 0;
>  }
>  
> -static int w83l785ts_probe(struct i2c_client *new_client,
> +static int w83l785ts_probe(struct i2c_client *client,
>  			   const struct i2c_device_id *id)
>  {
>  	struct w83l785ts_data *data;
> +	struct device *dev = &client->dev;
>  	int err = 0;

Not related to your changes directly, but this initialization is not
needed.

>  (...)
> @@ -200,18 +199,16 @@ static int w83l785ts_probe(struct i2c_client *new_client,
>  	 * Nothing yet, assume it is already started.
>  	 */
>  
> -	err = device_create_file(&new_client->dev,
> -				 &sensor_dev_attr_temp1_input.dev_attr);
> +	err = device_create_file(dev, &sensor_dev_attr_temp1_input.dev_attr);
>  	if (err)
>  		goto exit_remove;

You might as well turn this into a straight return, as there is nothing
to remove at this point.

Acked-by: Jean Delvare <khali at linux-fr.org>

-- 
Jean Delvare




More information about the lm-sensors mailing list