From: Guenter Roeck <linux@roeck-us.net>
To: Adam Wujek <dev_public@wujek.eu>
Cc: Jean Delvare <jdelvare@suse.com>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] hwmon: (pmbus) add a function to check the presence of a block register
Date: Tue, 24 May 2022 06:32:41 -0700 [thread overview]
Message-ID: <e0bfc3c0-d15f-f19e-5355-03a76ffa71ee@roeck-us.net> (raw)
In-Reply-To: <20220524104307.272806-1-dev_public@wujek.eu>
On 5/24/22 03:43, Adam Wujek wrote:
> Other functions (like pmbus_check_byte_register) cannot be used to check
> the presence of a block register, because it will generate error when PEC
> is used.
>
> Signed-off-by: Adam Wujek <dev_public@wujek.eu>
> ---
> Notes:
> Changes in v2:
> - Use Phase 0xff when setting the page
>
> drivers/hwmon/pmbus/pmbus_core.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index acf78d0829d9..2ff66f133d95 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -421,6 +421,18 @@ static int _pmbus_read_byte_data(struct i2c_client *client, int page, int reg)
> return pmbus_read_byte_data(client, page, reg);
> }
>
> +static int pmbus_read_block_data(struct i2c_client *client, int page, u8 reg,
> + char *data_buf)
> +{
> + int rv;
> +
> + rv = pmbus_set_page(client, page, 0xff);
> + if (rv < 0)
> + return rv;
> +
> + return i2c_smbus_read_block_data(client, reg, data_buf);
> +}
> +
> static struct pmbus_sensor *pmbus_find_sensor(struct pmbus_data *data, int page,
> int reg)
> {
> @@ -558,6 +570,20 @@ bool pmbus_check_word_register(struct i2c_client *client, int page, int reg)
> }
> EXPORT_SYMBOL_NS_GPL(pmbus_check_word_register, PMBUS);
>
> +static bool pmbus_check_block_register(struct i2c_client *client, int page,
> + int reg)
> +{
> + int rv;
> + struct pmbus_data *data = i2c_get_clientdata(client);
> + char data_buf[I2C_SMBUS_BLOCK_MAX + 2] = { 0 };
Unnecessary initialization.
> +
> + rv = pmbus_read_block_data(client, page, reg, data_buf);
> + if (rv >= 0 && !(data->flags & PMBUS_SKIP_STATUS_CHECK))
> + rv = pmbus_check_status_cml(client);
How about PMBUS_READ_STATUS_AFTER_FAILED_CHECK ?
Thanks,
Guenter
> + pmbus_clear_fault_page(client, -1);
> + return rv >= 0;
> +}
> +
> const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client *client)
> {
> struct pmbus_data *data = i2c_get_clientdata(client);
> --
> 2.17.1
>
>
next prev parent reply other threads:[~2022-05-24 13:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-24 10:43 Adam Wujek
2022-05-24 10:44 ` [PATCH v2 2/2] hwmon: (pmbus) add MFR_* registers to debugfs Adam Wujek
2022-05-24 13:32 ` Guenter Roeck [this message]
2022-06-01 1:34 ` [PATCH v2 1/2] hwmon: (pmbus) add a function to check the presence of a block register wujek dev
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=e0bfc3c0-d15f-f19e-5355-03a76ffa71ee@roeck-us.net \
--to=linux@roeck-us.net \
--cc=dev_public@wujek.eu \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--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®