All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <guenter.roeck@ericsson.com>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] MAX6642 chip detection and other stuff
Date: Wed, 01 Jun 2011 15:38:09 +0000	[thread overview]
Message-ID: <20110601153809.GA2593@ericsson.com> (raw)
In-Reply-To: <20110528045113.GA8833@ericsson.com>

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@appeartv.com>
> ---
> 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@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  parent reply	other threads:[~2011-06-01 15:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-28  4:51 [lm-sensors] MAX6642 chip detection and other stuff Guenter Roeck
2011-05-28  8:36 ` Jean Delvare
2011-05-28 14:04 ` Guenter Roeck
2011-06-01  6:44 ` Per Dalén
2011-06-01  7:42 ` Per Dalén
2011-06-01  9:47 ` Jean Delvare
2011-06-01 15:38 ` Guenter Roeck [this message]
2011-06-01 15:43 ` Guenter Roeck
2011-06-04 17:29 ` Guenter Roeck

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=20110601153809.GA2593@ericsson.com \
    --to=guenter.roeck@ericsson.com \
    --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.