From: Guenter Roeck <linux@roeck-us.net>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH v2] hwmon: (ds620) Convert to devm_hwmon_device_register_with_groups
Date: Sat, 12 Jul 2014 08:29:52 +0000 [thread overview]
Message-ID: <53C0F200.4010200@roeck-us.net> (raw)
In-Reply-To: <1404871191.7760.1.camel@phoenix>
On 07/08/2014 06:59 PM, Axel Lin wrote:
> Use ATTRIBUTE_GROUPS macro and devm_hwmon_device_register_with_groups() to
> simplify the code a bit.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> drivers/hwmon/ds620.c | 58 +++++++++++++--------------------------------------
> 1 file changed, 15 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c
> index 0918b91..1bdb6246 100644
> --- a/drivers/hwmon/ds620.c
> +++ b/drivers/hwmon/ds620.c
> @@ -67,7 +67,7 @@ static const u8 DS620_REG_TEMP[3] = {
>
> /* Each client has this additional data */
> struct ds620_data {
> - struct device *hwmon_dev;
> + struct i2c_client *client;
> struct mutex update_lock;
> char valid; /* !=0 if following fields are valid */
> unsigned long last_updated; /* In jiffies */
> @@ -106,8 +106,8 @@ static void ds620_init_client(struct i2c_client *client)
>
> static struct ds620_data *ds620_update_client(struct device *dev)
> {
> - struct i2c_client *client = to_i2c_client(dev);
> - struct ds620_data *data = i2c_get_clientdata(client);
> + struct ds620_data *data = dev_get_drvdata(dev);
> + struct i2c_client *client = data->client;
> struct ds620_data *ret = data;
>
> mutex_lock(&data->update_lock);
> @@ -158,8 +158,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
> long val;
>
> struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
> - struct i2c_client *client = to_i2c_client(dev);
> - struct ds620_data *data = i2c_get_clientdata(client);
> + struct ds620_data *data = dev_get_drvdata(dev);
> + struct i2c_client *client = data->client;
>
> res = kstrtol(buf, 10, &val);
>
> @@ -181,7 +181,7 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
> {
> struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
> struct ds620_data *data = ds620_update_client(dev);
> - struct i2c_client *client = to_i2c_client(dev);
> + struct i2c_client *client = data->client;
Hi Axel,
turns out this has a problem: data can be an ERR_PTR, so the client assignment
must only happen after the ERR_PTR check.
Can you please send me an updated patch ?
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
prev parent reply other threads:[~2014-07-12 8:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-09 1:59 [lm-sensors] [PATCH v2] hwmon: (ds620) Convert to devm_hwmon_device_register_with_groups Axel Lin
2014-07-09 3:31 ` Guenter Roeck
2014-07-12 8:29 ` 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=53C0F200.4010200@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.