From: Guenter Roeck <guenter.roeck@ericsson.com>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] hwmon: (max1668) Add support for
Date: Sat, 11 Jun 2011 15:35:31 +0000 [thread overview]
Message-ID: <20110611153531.GA26275@ericsson.com> (raw)
In-Reply-To: <20110611112818.670e5db8@endymion.delvare>
Hi Jean,
On Sat, Jun 11, 2011 at 05:28:18AM -0400, Jean Delvare wrote:
> Hi Guenter,
>
> On Thu, 9 Jun 2011 18:14:07 -0700, Guenter Roeck wrote:
> > MAX1668 and compatibles have several external temperature sensors, but only
> > a single FAULT status bit. If a fault occurs, the temperature reported on
> > affected sensors is 127 degrees C. Use this knowledge to report faults on
> > individual external sensors.
> >
> > Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
> > ---
> > Tested with MAX1668 with one sensor disconnected. Resulting output is as follows.
> > Seems to be better than just reporting extra-high temperature.
>
> Looks overall good.
>
> Acked-by: Jean Delvare <khali@linux-fr.org>
>
> Minor comments below if you are interested.
>
I am, see below. Thanks a lot for the review!
> As a side note, it seems that
> http://git.kernel.org/?p=linux/kernel/git/groeck/staging.git;a=commit;h¯2dcfe730577d5399973a4df648190f5562b470
> doesn't properly credit David as being the original author of the
> commit.
>
One of those cases where "git am" didn't work and I had to apply the patch manually.
I'll fix it. One of those days I'll have to figure out how to apply such
patches without having to revert to "patch".
> >
> > root@groeck-desktop# sensors
> > max1668-i2c-5-18
> > Adapter: i2c-devantech-iss at bus 001 device 007
> > temp1: +23.0°C (low = -55.0°C, high = +127.0°C)
> > temp2: +25.0°C (low = -55.0°C, high = +127.0°C)
> > temp3: +25.0°C (low = -55.0°C, high = +127.0°C)
> > temp4: +25.0°C (low = -55.0°C, high = +127.0°C)
> > temp5: FAULT (low = -55.0°C, high = +127.0°C) ALARM(MAX)
> >
> > drivers/hwmon/max1668.c | 26 +++++++++++++++++++++++++-
> > 1 files changed, 25 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/hwmon/max1668.c b/drivers/hwmon/max1668.c
> > index ddefb64..af85d44 100644
> > --- a/drivers/hwmon/max1668.c
> > +++ b/drivers/hwmon/max1668.c
> > @@ -123,7 +123,7 @@ static struct max1668_data *max1668_update_device(struct device *dev)
> > goto abort;
> > }
> > data->alarms &= 0x00ff;
> > - data->alarms |= ((u8) (val & 0x60)) << 8;
> > + data->alarms |= ((u8) (val & 0x70)) << 8;
>
> The (u8) type cast doesn't seem needed. Same a few lines below for
> MAX1668_REG_STAT2.
>
Actually, turns out that
data->alarms = val << 8;
followed by
data->alarms |= val;
for MAX1668_REG_STAT2 is good enough.
> >
> > val = i2c_smbus_read_byte_data(client, MAX1668_REG_STAT2);
> > if (unlikely(val < 0)) {
> > @@ -189,6 +189,19 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
> > return sprintf(buf, "%u\n", (data->alarms >> index) & 0x1);
> > }
> >
> > +static ssize_t show_fault(struct device *dev,
> > + struct device_attribute *devattr, char *buf)
> > +{
> > + int index = to_sensor_dev_attr(devattr)->index;
> > + struct max1668_data *data = max1668_update_device(dev);
> > +
> > + if (IS_ERR(data))
> > + return PTR_ERR(data);
> > +
> > + return sprintf(buf, "%d\n",
>
> %u would probably make more sense, as this is used for alarms above.
> But I agree %d will work too.
>
Still more consistent. I changed it.
> > + (data->alarms & (1 << 12)) && data->temp[index] = 127);
> > +}
> > +
> > static ssize_t set_temp_max(struct device *dev,
> > struct device_attribute *devattr,
> > const char *buf, size_t count)
> > @@ -276,6 +289,11 @@ static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_alarm, NULL, 2);
> > static SENSOR_DEVICE_ATTR(temp5_min_alarm, S_IRUGO, show_alarm, NULL, 1);
> > static SENSOR_DEVICE_ATTR(temp5_max_alarm, S_IRUGO, show_alarm, NULL, 0);
> >
> > +static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_fault, NULL, 1);
> > +static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_fault, NULL, 2);
> > +static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_fault, NULL, 3);
> > +static SENSOR_DEVICE_ATTR(temp5_fault, S_IRUGO, show_fault, NULL, 4);
> > +
> > /* Attributes common to MAX1668, MAX1989 and MAX1805 */
> > static struct attribute *max1668_attribute_common[] = {
> > &sensor_dev_attr_temp1_max.dev_attr.attr,
> > @@ -294,6 +312,9 @@ static struct attribute *max1668_attribute_common[] = {
> > &sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
> > &sensor_dev_attr_temp3_max_alarm.dev_attr.attr,
> > &sensor_dev_attr_temp3_min_alarm.dev_attr.attr,
> > +
> > + &sensor_dev_attr_temp2_fault.dev_attr.attr,
> > + &sensor_dev_attr_temp3_fault.dev_attr.attr,
> > NULL
> > };
> >
> > @@ -310,6 +331,9 @@ static struct attribute *max1668_attribute_unique[] = {
> > &sensor_dev_attr_temp4_min_alarm.dev_attr.attr,
> > &sensor_dev_attr_temp5_max_alarm.dev_attr.attr,
> > &sensor_dev_attr_temp5_min_alarm.dev_attr.attr,
> > +
> > + &sensor_dev_attr_temp4_fault.dev_attr.attr,
> > + &sensor_dev_attr_temp5_fault.dev_attr.attr,
> > NULL
> > };
> >
>
>
> --
> Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next prev parent reply other threads:[~2011-06-11 15:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-11 9:28 [lm-sensors] [PATCH] hwmon: (max1668) Add support for Jean Delvare
2011-06-11 15:35 ` Guenter Roeck [this message]
2011-06-11 15:48 ` Jean Delvare
2011-06-12 0:52 ` Guenter Roeck
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=20110611153531.GA26275@ericsson.com \
--to=guenter.roeck@ericsson.com \
--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.