From: Guenter Roeck <linux@roeck-us.net>
To: Rain Wang <Rain_Wang@Jabil.com>, Jean Delvare <jdelvare@suse.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] lm75: add lm75b detection
Date: Sun, 27 Oct 2019 16:03:39 -0700 [thread overview]
Message-ID: <7a2ddf42-8bbe-59e0-dae8-85b184ea0da0@roeck-us.net> (raw)
In-Reply-To: <20191026081049.GA16839@rainw-fedora28-jabil.corp.JABIL.ORG>
On 10/26/19 1:10 AM, Rain Wang wrote:
> The National Semiconductor LM75B is very similar as the
> LM75A, but it has no ID byte register 7, and unused registers
> return 0xff rather than the last read value like LM75A.
>
> Signed-off-by: Rain Wang <rain_wang@jabil.com>
I am quite hesitant to touch the detect function for this chip.
Each addition increases the risk for false positives. What is the
use case ?
Thanks,
Guenter
> ---
> drivers/hwmon/lm75.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
> index 5e6392294c03..a718f9eb4d72 100644
> --- a/drivers/hwmon/lm75.c
> +++ b/drivers/hwmon/lm75.c
> @@ -760,6 +760,7 @@ static int lm75_detect(struct i2c_client *new_client,
> int i;
> int conf, hyst, os;
> bool is_lm75a = 0;
> + bool is_lm75b = 0;
>
> if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
> I2C_FUNC_SMBUS_WORD_DATA))
> @@ -780,8 +781,12 @@ static int lm75_detect(struct i2c_client *new_client,
> * register 7, and unused registers return 0xff rather than the
> * last read value.
> *
> + * The National Semiconductor LM75B is very similar as the
> + * LM75A, but it has no ID byte register 7, and unused registers
> + * return 0xff rather than the last read value like LM75A.
> + *
> * Note that this function only detects the original National
> - * Semiconductor LM75 and the LM75A. Clones from other vendors
> + * Semiconductor LM75 and the LM75A/B. Clones from other vendors
> * aren't detected, on purpose, because they are typically never
> * found on PC hardware. They are found on embedded designs where
> * they can be instantiated explicitly so detection is not needed.
> @@ -806,6 +811,13 @@ static int lm75_detect(struct i2c_client *new_client,
> is_lm75a = 1;
> hyst = i2c_smbus_read_byte_data(new_client, 2);
> os = i2c_smbus_read_byte_data(new_client, 3);
> + } else if (i2c_smbus_read_byte_data(new_client, 4) == 0xff
> + && i2c_smbus_read_byte_data(new_client, 5) == 0xff
> + && i2c_smbus_read_byte_data(new_client, 6) == 0xff) {
> + /* LM75B detection */
> + is_lm75b = 1;
> + hyst = i2c_smbus_read_byte_data(new_client, 2);
> + os = i2c_smbus_read_byte_data(new_client, 3);
> } else { /* Traditional style LM75 detection */
> /* Unused addresses */
> hyst = i2c_smbus_read_byte_data(new_client, 2);
> @@ -839,7 +851,8 @@ static int lm75_detect(struct i2c_client *new_client,
> return -ENODEV;
> }
>
> - strlcpy(info->type, is_lm75a ? "lm75a" : "lm75", I2C_NAME_SIZE);
> + strlcpy(info->type, is_lm75a ?
> + "lm75a" : (is_lm75b ? "lm75b" : "lm75"), I2C_NAME_SIZE);
>
> return 0;
> }
>
next prev parent reply other threads:[~2019-10-27 23:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-26 8:10 Rain Wang
2019-10-27 23:03 ` Guenter Roeck [this message]
2019-10-28 9:46 ` Jean Delvare
2019-10-29 14:02 ` Guenter Roeck
2019-11-07 6:18 ` Rain Wang
2019-10-28 11:28 Rain Wang
2019-10-28 11:37 Rain Wang
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=7a2ddf42-8bbe-59e0-dae8-85b184ea0da0@roeck-us.net \
--to=linux@roeck-us.net \
--cc=Rain_Wang@Jabil.com \
--cc=jdelvare@suse.com \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®