From: Guenter Roeck <linux@roeck-us.net>
To: Chu Lin <linchuyuan@google.com>
Cc: belgaied@google.com, jasonling@google.com, jdelvare@suse.com,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
zhongqil@google.com
Subject: Re: [PATCH v2] hwmon: adm1275: Make sure we are reading enough data for different chips
Date: Thu, 9 Jul 2020 07:05:53 -0700 [thread overview]
Message-ID: <20200709140553.GA62629@roeck-us.net> (raw)
In-Reply-To: <20200709040612.3977094-1-linchuyuan@google.com>
On Thu, Jul 09, 2020 at 04:06:12AM +0000, Chu Lin wrote:
> Issue:
> When PEC is enabled, binding adm1272 to the adm1275 would
> fail due to PEC error. See below:
> adm1275: probe of xxxx failed with error -74
>
> Diagnosis:
> Per the datasheet of adm1272, adm1278, adm1293 and amd1294,
> PMON_CONFIG (0xd4) is 16bits wide. On the other hand,
> PMON_CONFIG (0xd4) for adm1275 is 8bits wide. The driver should not
> assume everything is 8bits wide and read only 8bits from it.
>
> Solution:
> If it is adm1272, adm1278, adm1293 and adm1294, use i2c_read_word.
> Else, use i2c_read_byte
>
> Testing:
> Binding adm1272 to the driver.
> The change is only tested on adm1272.
>
> Signed-off-by: Chu Lin <linchuyuan@google.com>
Applied.
Thanks a lot for analyzing and fixing the problem.
Guenter
> ---
>
> ChangeLog v1 -> v2
> - Rename config_read_fn_ptr to config_read_fn
> - Move config_read_fn to the first line as it is the longest
> variable declaration
> - Include adm1293 and adm1294
> - Remove the inline comment as I think the purpose is obvious
>
>
> drivers/hwmon/pmbus/adm1275.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c
> index e25f541227da..19317575d1c6 100644
> --- a/drivers/hwmon/pmbus/adm1275.c
> +++ b/drivers/hwmon/pmbus/adm1275.c
> @@ -465,6 +465,7 @@ MODULE_DEVICE_TABLE(i2c, adm1275_id);
> static int adm1275_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> + s32 (*config_read_fn)(const struct i2c_client *client, u8 reg);
> u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1];
> int config, device_config;
> int ret;
> @@ -510,11 +511,16 @@ static int adm1275_probe(struct i2c_client *client,
> "Device mismatch: Configured %s, detected %s\n",
> id->name, mid->name);
>
> - config = i2c_smbus_read_byte_data(client, ADM1275_PMON_CONFIG);
> + if (mid->driver_data == adm1272 || mid->driver_data == adm1278 ||
> + mid->driver_data == adm1293 || mid->driver_data == adm1294)
> + config_read_fn = i2c_smbus_read_word_data;
> + else
> + config_read_fn = i2c_smbus_read_byte_data;
> + config = config_read_fn(client, ADM1275_PMON_CONFIG);
> if (config < 0)
> return config;
>
> - device_config = i2c_smbus_read_byte_data(client, ADM1275_DEVICE_CONFIG);
> + device_config = config_read_fn(client, ADM1275_DEVICE_CONFIG);
> if (device_config < 0)
> return device_config;
>
prev parent reply other threads:[~2020-07-09 14:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 4:06 [PATCH v2] hwmon: adm1275: Make sure we are reading enough data for different chips Chu Lin
2020-07-09 14:05 ` Guenter Roeck [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=20200709140553.GA62629@roeck-us.net \
--to=linux@roeck-us.net \
--cc=belgaied@google.com \
--cc=jasonling@google.com \
--cc=jdelvare@suse.com \
--cc=linchuyuan@google.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zhongqil@google.com \
/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;
as well as URLs for NNTP newsgroup(s).