hwmon/lm87: Add support for the Analog Devices ADM1024

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?


>      Datasheet: http://www.national.com/pf/LM/LM87.html
> +  * Analog Devices ADM1024
> +    Prefix: 'adm1024'
> +    Addresses scanned: I2C 0x2c - 0x2e
> +    Datasheet: http://www.analog.com/en/prod/0,2877,ADM1024,00.html
[...]
> @@ -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:

#define COMPANY_ID_NATSEMI		0x02
#define COMPANY_ID_ANALOG_DEVICES	0x41

(maybe even in some common header file which other drivers can use, too)

A lot more readable IMO, and you don't need any code comment anymore.


HTH, Uwe.
-- 
http://www.hermann-uwe.de  | http://www.holsham-traders.de
http://www.crazy-hacks.org | http://www.unmaintained-free-software.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20071009/70563826/attachment.bin 


[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux