Re: MAX6642 chip detection and other stuff

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

 



Hi Per,

On Wed, Jun 01, 2011 at 02:44:19AM -0400, Per Dalén wrote:
> Hi Guenter and Jean,
> 
> Sorry for the delay. Much stuff at work...
> Here's (Jean's ;) patch.
> 
> BR
> Per
> 
[ ... ]

> Improve the detection of MAX6642 by reading non exciting registers (0x04, 0x06 and 0xff). The value of those registers should be the same as the last valid resister read.

> Signed-off-by: Per Dalen <per.dalen@xxxxxxxxxxxx>
> ---
> diff --git a/drivers/hwmon/max6642.c b/drivers/hwmon/max6642.c
> index 0f9fc40..4fb0564 100644
> --- a/drivers/hwmon/max6642.c
> +++ b/drivers/hwmon/max6642.c
> @@ -136,6 +136,12 @@ static int max6642_detect(struct i2c_client *client,
>  	if (man_id != 0x4D)
>  		return -ENODEV;
>  
> +	/* sanity check */
> +	if (i2c_smbus_read_byte_data(client, 0x04) != 0x4D
> +	    || i2c_smbus_read_byte_data(client, 0x06) != 0x4D
> +	    || i2c_smbus_read_byte_data(client, 0xff) != 0x4D)
> +		return -ENODEV;
> +
>  	/*
>  	 * We read the config and status register, the 4 lower bits in the
>  	 * config register should be zero and bit 5, 3, 1 and 0 should be

Looks good, only the second part of my suggested changes got lost.

        reg_config = i2c_smbus_read_byte_data(client, MAX6642_REG_R_CONFIG);
+       if ((reg_config & 0x0f) != 0x00)
+               return -ENODEV;
+
+       /* in between, another round of sanity checks */
+       if (i2c_smbus_read_byte_data(client, 0x04) != reg_config
+	    || i2c_smbus_read_byte_data(client, 0x06) != reg_config
+	    || i2c_smbus_read_byte_data(client, 0xff) != reg_config)
+               return -ENODEV;
+

Please add those, and we should be ready to go.

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors



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

  Powered by Linux