From: Guenter Roeck <linux@roeck-us.net>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH v3 4/9] hwmon: (it87) Introduce support for tempX_offset sysfs attribute
Date: Tue, 30 Oct 2012 17:05:59 +0000 [thread overview]
Message-ID: <20121030170559.GD11394@roeck-us.net> (raw)
On Tue, Oct 30, 2012 at 05:42:56PM +0100, Jean Delvare wrote:
> Hi Guenter,
>
> On Mon, 29 Oct 2012 17:45:44 -0700, Guenter Roeck wrote:
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > ---
> > v3: s/S_IRUGOWU/S_IRUGO | S_IWUSR/
> > Limit support for new attributes to IT8716F and higher
> > Clarify code to select target register in set_temp().
> > Only clear valid flag only when writing into offset registers,
>
> Duplicate word "only".
>
> > not for any other temperature limit set operations.
> > v2: The macro to calculate IT87_REG_TEMP_OFFSET was broken. Use array instead.
> > When writing the temperature offset attribute, set the flag to enable it.
> > Add documentation describing the new attributes.
> >
> > Documentation/hwmon/it87 | 9 +++++++
> > drivers/hwmon/it87.c | 67 ++++++++++++++++++++++++++++++++++++++++++----
> > 2 files changed, 71 insertions(+), 5 deletions(-)
> > (...)
> > --- a/drivers/hwmon/it87.c
> > +++ b/drivers/hwmon/it87.c
> > (...)
> > @@ -312,6 +314,15 @@ static inline int has_newer_autopwm(const struct it87_data *data)
> > || data->type = it8728;
> > }
> >
> > +static inline int has_temp_offset(const struct it87_data *data)
> > +{
> > + return data->type = it8716
> > + || data->type = it8721
> > + || data->type = it8728
> > + || data->type = it8782
> > + || data->type = it8783;
>
> What about it8718 and it8720?
>
I'll add those.
> > +}
> > +
> > static int adc_lsb(const struct it87_data *data, int nr)
> > {
> > int lsb = has_12mv_adc(data) ? 12 : 16;
> > @@ -546,16 +557,37 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *attr,
> > int index = sattr->index;
> > struct it87_data *data = dev_get_drvdata(dev);
> > long val;
> > + u8 reg;
> >
> > if (kstrtol(buf, 10, &val) < 0)
> > return -EINVAL;
> >
> > + switch (index) {
> > + case 1:
> > + reg = IT87_REG_TEMP_LOW(nr);
> > + break;
> > + case 2:
> > + reg = IT87_REG_TEMP_HIGH(nr);
> > + break;
> > + case 3:
> > + reg = IT87_REG_TEMP_OFFSET[nr];
> > + break;
> > + default:
> > + WARN_ONCE(true, "Driver implementation error\n");
> > + return -EINVAL;
> > + }
>
> Or just use default for either case and be done with it. It's not
> like the warning will ever be printed, and that's what the original
> code was doing anyway.
>
ok
> > +
> > mutex_lock(&data->update_lock);
> > data->temp[nr][index] = TEMP_TO_REG(val);
> > - it87_write_value(data,
> > - index = 1 ? IT87_REG_TEMP_LOW(nr)
> > - : IT87_REG_TEMP_HIGH(nr),
> > - data->temp[nr][index]);
> > + if (index = 3) {
> > + u8 regval = it87_read_value(data, IT87_REG_BEEP_ENABLE);
> > + if (!(regval & 0x80)) {
> > + regval |= 0x80;
> > + it87_write_value(data, IT87_REG_BEEP_ENABLE, regval);
> > + }
> > + data->valid = 0;
> > + }
>
> This could be moved to the switch above, assuming earlier locking,
> saving a test.
>
ok
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
reply other threads:[~2012-10-30 17:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20121030170559.GD11394@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.