From: Jean Delvare <khali@linux-fr.org>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] hwmon/lm87: Add support for the Analog Devices
Date: Tue, 09 Oct 2007 16:03:33 +0000 [thread overview]
Message-ID: <20071009180333.381cecfe@hyperion.delvare> (raw)
In-Reply-To: <20071009152222.0e4a51a3@hyperion.delvare>
Hallo Uwe,
On Tue, 9 Oct 2007 16:55:11 +0200, Uwe Hermann wrote:
> Untested, and I'm not an lm-sensors or kernel expert anyway, but here are
> some comments:
>
> On Tue, Oct 09, 2007 at 03:22:22PM +0200, Jean Delvare wrote:
> > --- linux-2.6.23-rc9.orig/Documentation/hwmon/lm87 2007-10-09 08:42:48.000000000 +0200
> > +++ linux-2.6.23-rc9/Documentation/hwmon/lm87 2007-10-09 11:14:05.000000000 +0200
> > @@ -4,8 +4,12 @@ Kernel driver lm87
> > Supported chips:
> > * National Semiconductor LM87
> > Prefix: 'lm87'
> > - Addresses scanned: I2C 0x2c - 0x2f
> > + Addresses scanned: I2C 0x2c - 0x2e
>
> Is this intentional? Was the previous value incorrect?
Yes, this is intentional, the previous value wasn't in line with what
the driver actually does:
> /*
> * Addresses to scan
> * LM87 has three possible addresses: 0x2c, 0x2d and 0x2e.
> */
>
> static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
Admittedly, in theory this should go to a separate patch, but it didn't
seem to be worth the effort this time.
> > @@ -686,11 +692,18 @@ static int lm87_detect(struct i2c_adapte
> >
> > /* Now, we do the remaining detection. */
> > if (kind < 0) {
> > + u8 cid = lm87_read_value(new_client, LM87_REG_COMPANY_ID);
> > u8 rev = lm87_read_value(new_client, LM87_REG_REVISION);
> >
> > - if (rev < 0x01 || rev > 0x08
> > - || (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80)
> > - || lm87_read_value(new_client, LM87_REG_COMPANY_ID) != 0x02) {
> > + if (cid = 0x02 /* National Semiconductor */
> > + && (rev >= 0x01 && rev <= 0x08))
> > + kind = lm87;
> > + else if (cid = 0x41 /* Analog Devices */
>
> I don't know how this is handled in the rest of the code, but personally I'd
> make them #defines, e.g. like this:
Depends on the driver, some do it the way you propose (lm85, adm1026,
dme1737) but most drivers use register values directly as I'm doing
here.
> #define COMPANY_ID_NATSEMI 0x02
> #define COMPANY_ID_ANALOG_DEVICES 0x41
>
> (maybe even in some common header file which other drivers can use, too)
Not possible for Nat. Semi, as they smartly use different company IDs
depending on the device. It's 0x00 for the LM84, 0x02 for the LM87 and
0x01 for their other chips. The Analog Devices ID used here is the
standard one, however they used 0x23 for the ADM9240 for example (while
0x23 was the Genesys ID for their GL523SM). SMSC too has a standard ID
(0x55) but used a different one sometimes. So if you want to have such
definitions in a common header, you'll have to deal with exceptions.
> A lot more readable IMO, and you don't need any code comment anymore.
I'm seeing it the other way around: thanks to the comments, I don't
need the defines ;) I don't see much benefit in using defines in this
specific case.
Thanks for the review.
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
prev parent reply other threads:[~2007-10-09 16:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-09 13:22 [lm-sensors] hwmon/lm87: Add support for the Analog Devices ADM1024 Jean Delvare
2007-10-09 16:03 ` 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=20071009180333.381cecfe@hyperion.delvare \
--to=khali@linux-fr.org \
--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.