From: Jean Delvare <khali@linux-fr.org>
To: James Chapman <jchapman@katalix.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
LM Sensors <sensors@stimpy.netroedge.com>,
Greg KH <greg@kroah.com>
Subject: Re: [PATCH: 2.6.11-rc5] i2c chips: add adt7461 support to lm90 driver
Date: Thu, 3 Mar 2005 22:32:30 +0100 [thread overview]
Message-ID: <20050303223230.15e91bb3.khali@linux-fr.org> (raw)
In-Reply-To: <42274958.4050400@katalix.com>
Hi James,
> A revised adt7461 patch addressing all of Jean's comments is
> attached.
>
> This driver will detect the adt7461 chip only if boot firmware
> has left the chip in its default lm90-compatible mode.
I'm fine with the idea but not quite with your implementation:
> @@ -221,6 +229,8 @@
> struct i2c_client *client = to_i2c_client(dev); \
> struct lm90_data *data = i2c_get_clientdata(client); \
> long val = simple_strtol(buf, NULL, 10); \
> + if ((data->kind == adt7461) && ((val < 0) || (val > 127000))) \
> + return -EINVAL; \
> data->value = TEMP1_TO_REG(val); \
> i2c_smbus_write_byte_data(client, reg, data->value); \
> return count; \
> @@ -232,6 +242,8 @@
> struct i2c_client *client = to_i2c_client(dev); \
> struct lm90_data *data = i2c_get_clientdata(client); \
> long val = simple_strtol(buf, NULL, 10); \
> + if ((data->kind == adt7461) && ((val < 0) || (val > 127000))) \
> + return -EINVAL; \
> data->value = TEMP2_TO_REG(val); \
> i2c_smbus_write_byte_data(client, regh, data->value >> 8); \
> i2c_smbus_write_byte_data(client, regl, data->value & 0xff); \
This is inconsistent with the rest of the interface. For continuous
values, we do not return errors on out-of-range writes. Instead, we
force the value to whatever range boundary makes sense. See TEMP1_TO_REG
and TEMP2_TO_REG. So I would suggest that you implement
TEMP1_TO_REG_ADT7461 and TEMP2_TO_REG_ADT7461 the same way with
different boundaries, and call them.
> + if (address == 0x4c
> + && chip_id == 0x51 /* ADT7461 */
> + && (reg_config1 & 0x3F) == 0x00
That could be broaden to "& 0x1F" is I am not mistaken. We don't really
care about bit 5, do we? And maybe put a comment explaining that we
check for compatibility at this point (similar checks for the other
chips are only for unused bits, not for specific configuration).
Thanks,
--
Jean Delvare
prev parent reply other threads:[~2005-03-03 21:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-28 17:13 [PATCH: 2.6.11-rc5] i2c chips: add adt7461 support to lm90 driver James Chapman
2005-03-02 16:55 ` Greg KH
2005-03-02 19:37 ` Jean Delvare
2005-03-03 17:28 ` James Chapman
2005-03-03 21:32 ` Jean Delvare [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=20050303223230.15e91bb3.khali@linux-fr.org \
--to=khali@linux-fr.org \
--cc=greg@kroah.com \
--cc=jchapman@katalix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sensors@stimpy.netroedge.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox