All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] hwmon: (lm80) Convert to use devm_hwmon_device_register_with_groups
Date: Sun, 02 Feb 2014 21:59:28 +0000	[thread overview]
Message-ID: <52EEBFC0.5040004@roeck-us.net> (raw)
In-Reply-To: <1391363141-7157-1-git-send-email-linux@roeck-us.net>

On 02/02/2014 01:00 PM, Jean Delvare wrote:
> Hi Guenter,
>
> On Sun,  2 Feb 2014 09:45:41 -0800, Guenter Roeck wrote:
>> Simplify code, reduce code size, and attach hwmon attributes to
>> hwmon device.
>>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>>   drivers/hwmon/lm80.c |   64 ++++++++++++++++----------------------------------
>>   1 file changed, 20 insertions(+), 44 deletions(-)
>>
>> diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
>> index eba89aa..914d7e5 100644
>> --- a/drivers/hwmon/lm80.c
>> +++ b/drivers/hwmon/lm80.c
>> (...)
>> @@ -541,14 +536,14 @@ static int lm80_detect(struct i2c_client *client, struct i2c_board_info *info)
>>   static int lm80_probe(struct i2c_client *client,
>>   		      const struct i2c_device_id *id)
>>   {
>> +	struct device *hwmon_dev;
>>   	struct lm80_data *data;
>> -	int err;
>>
>>   	data = devm_kzalloc(&client->dev, sizeof(struct lm80_data), GFP_KERNEL);
>>   	if (!data)
>>   		return -ENOMEM;
>>
>> -	i2c_set_clientdata(client, data);
>> +	data->client = client;
>>   	mutex_init(&data->update_lock);
>>
>>   	/* Initialize the LM80 chip */
>> @@ -558,30 +553,11 @@ static int lm80_probe(struct i2c_client *client,
>>   	data->fan_min[0] = lm80_read_value(client, LM80_REG_FAN_MIN(1));
>>   	data->fan_min[1] = lm80_read_value(client, LM80_REG_FAN_MIN(2));
>>
>> -	/* Register sysfs hooks */
>> -	err = sysfs_create_group(&client->dev.kobj, &lm80_group);
>> -	if (err)
>> -		return err;
>> -
>> -	data->hwmon_dev = hwmon_device_register(&client->dev);
>> -	if (IS_ERR(data->hwmon_dev)) {
>> -		err = PTR_ERR(data->hwmon_dev);
>> -		goto error_remove;
>> -	}
>> -
>> -	return 0;
>> -
>> -error_remove:
>> -	sysfs_remove_group(&client->dev.kobj, &lm80_group);
>> -	return err;
>> -}
>> -
>> -static int lm80_remove(struct i2c_client *client)
>> -{
>> -	struct lm80_data *data = i2c_get_clientdata(client);
>> -
>> -	hwmon_device_unregister(data->hwmon_dev);
>> -	sysfs_remove_group(&client->dev.kobj, &lm80_group);
>> +	hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev,
>> +							   client->name, data,
>> +							   lm80_groups);
>> +	if (IS_ERR(hwmon_dev))
>> +		return PTR_ERR(hwmon_dev);
>>
>>   	return 0;
>
> Why not return PTR_ERR_OR_ZERO?
>
>>   }
>> @@ -614,8 +590,8 @@ static void lm80_init_client(struct i2c_client *client)
>>
>>   static struct lm80_data *lm80_update_device(struct device *dev)
>>   {
>> -	struct i2c_client *client = to_i2c_client(dev);
>> -	struct lm80_data *data = i2c_get_clientdata(client);
>> +	struct lm80_data *data = dev_get_drvdata(dev);
>> +	struct i2c_client *client = data->client;
>>   	int i;
>>   	int rv;
>>   	int prev_rv;
>
> You did not update the dev_dbg() call in this function as you just did
> in adm1021_update_device(). I believe this should be done consistently
> over all drivers. More generally, if we decide to use the hwmon device
> for run-time messages then this should be done in all functions of all
> (converted) hwmon drivers.
>

Hi Jean,

Makes sense. I'll do that in the next revision (and look through other drivers
to do the same there if needed).

Thanks,
Guenter


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

      parent reply	other threads:[~2014-02-02 21:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-02 17:45 [lm-sensors] [PATCH] hwmon: (lm80) Convert to use devm_hwmon_device_register_with_groups Guenter Roeck
2014-02-02 21:00 ` Jean Delvare
2014-02-02 21:59 ` Guenter Roeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52EEBFC0.5040004@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=lm-sensors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.