From: Guenter Roeck <linux@roeck-us.net>
To: "Mårten Lindahl" <marten.lindahl@axis.com>
Cc: Jean Delvare <jdelvare@suse.com>,
linux-hwmon@vger.kernel.org, kernel@axis.com
Subject: Re: [PATCH v4 1/4] hwmon: (pmbus) Introduce and use write_byte_data callback
Date: Sun, 1 May 2022 21:23:55 -0700 [thread overview]
Message-ID: <20220502042355.GA1717700@roeck-us.net> (raw)
In-Reply-To: <20220428144039.2464667-2-marten.lindahl@axis.com>
On Thu, Apr 28, 2022 at 04:40:36PM +0200, Mårten Lindahl wrote:
> Some of the pmbus core functions uses pmbus_write_byte_data, which does
> not support driver callbacks for chip specific write operations. This
> could potentially influence some specific regulator chips that for
> example need a time delay before each data access.
>
> Lets add support for driver callback with _pmbus_write_byte_data.
>
> Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/pmbus/pmbus.h | 2 ++
> drivers/hwmon/pmbus/pmbus_core.c | 24 +++++++++++++++++++++---
> 2 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
> index e74b6ef070f3..c031a9700ace 100644
> --- a/drivers/hwmon/pmbus/pmbus.h
> +++ b/drivers/hwmon/pmbus/pmbus.h
> @@ -438,6 +438,8 @@ struct pmbus_driver_info {
> int (*read_byte_data)(struct i2c_client *client, int page, int reg);
> int (*read_word_data)(struct i2c_client *client, int page, int phase,
> int reg);
> + int (*write_byte_data)(struct i2c_client *client, int page, int reg,
> + u8 byte);
> int (*write_word_data)(struct i2c_client *client, int page, int reg,
> u16 word);
> int (*write_byte)(struct i2c_client *client, int page, u8 value);
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index b2618b1d529e..98da2db3f831 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -276,6 +276,24 @@ static int _pmbus_write_word_data(struct i2c_client *client, int page, int reg,
> return pmbus_write_word_data(client, page, reg, word);
> }
>
> +/*
> + * _pmbus_write_byte_data() is similar to pmbus_write_byte_data(), but checks if
> + * a device specific mapping function exists and calls it if necessary.
> + */
> +static int _pmbus_write_byte_data(struct i2c_client *client, int page, int reg, u8 value)
> +{
> + struct pmbus_data *data = i2c_get_clientdata(client);
> + const struct pmbus_driver_info *info = data->info;
> + int status;
> +
> + if (info->write_byte_data) {
> + status = info->write_byte_data(client, page, reg, value);
> + if (status != -ENODATA)
> + return status;
> + }
> + return pmbus_write_byte_data(client, page, reg, value);
> +}
> +
> int pmbus_update_fan(struct i2c_client *client, int page, int id,
> u8 config, u8 mask, u16 command)
> {
> @@ -290,7 +308,7 @@ int pmbus_update_fan(struct i2c_client *client, int page, int id,
>
> to = (from & ~mask) | (config & mask);
> if (to != from) {
> - rv = pmbus_write_byte_data(client, page,
> + rv = _pmbus_write_byte_data(client, page,
> pmbus_fan_config_registers[id], to);
> if (rv < 0)
> return rv;
> @@ -397,7 +415,7 @@ int pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg,
> tmp = (rv & ~mask) | (value & mask);
>
> if (tmp != rv)
> - rv = pmbus_write_byte_data(client, page, reg, tmp);
> + rv = _pmbus_write_byte_data(client, page, reg, tmp);
>
> return rv;
> }
> @@ -912,7 +930,7 @@ static int pmbus_get_boolean(struct i2c_client *client, struct pmbus_boolean *b,
>
> regval = status & mask;
> if (regval) {
> - ret = pmbus_write_byte_data(client, page, reg, regval);
> + ret = _pmbus_write_byte_data(client, page, reg, regval);
> if (ret)
> goto unlock;
> }
next prev parent reply other threads:[~2022-05-02 4:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-28 14:40 [PATCH v4 0/4] hwmon: (pmbus/ltc2978) Add regulator ops Mårten Lindahl
2022-04-28 14:40 ` [PATCH v4 1/4] hwmon: (pmbus) Introduce and use write_byte_data callback Mårten Lindahl
2022-05-02 4:23 ` Guenter Roeck [this message]
2022-04-28 14:40 ` [PATCH v4 2/4] hwmon: (pmbus) Use _pmbus_read_byte_data with callback Mårten Lindahl
2022-05-02 4:24 ` Guenter Roeck
2022-04-28 14:40 ` [PATCH v4 3/4] hwmon: (pmbus/ltc2978) Add chip specific write_byte_data Mårten Lindahl
2022-05-02 4:24 ` Guenter Roeck
2022-04-28 14:40 ` [PATCH v4 4/4] hwmon: (pmbus) Add get_voltage/set_voltage ops Mårten Lindahl
2022-04-28 16:49 ` Guenter Roeck
2022-04-29 9:52 ` Marten Lindahl
2022-04-29 17:00 ` Guenter Roeck
2022-05-02 10:42 ` Marten Lindahl
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=20220502042355.GA1717700@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--cc=kernel@axis.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=marten.lindahl@axis.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