All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: nuno.sa@analog.com, linux-hwmon@vger.kernel.org,
	 devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
	Mark Brown <broonie@kernel.org>,
	 Alan Tull <atull@opensource.altera.com>,
	Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	 Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH 3/5] hwmon: (pmbus/core) Add mapping function to pmbus_read_block_data()
Date: Thu, 30 Jul 2026 15:27:08 +0100	[thread overview]
Message-ID: <amtewh9lOgWz0-Nh@nsa> (raw)
In-Reply-To: <c3e143ed-af08-4a0f-a630-96a255df838d@roeck-us.net>

On Tue, Jul 28, 2026 at 02:05:53PM -0700, Guenter Roeck wrote:
> On 7/28/26 09:03, Nuno Sá via B4 Relay wrote:
> > From: Nuno Sá <nuno.sa@analog.com>
> > 
> > This is in preparation for adding support to a device which needs to
> > use it's own read_block implementation.
> > 
> 
> The chip-specific implementation calls i2c_smbus_read_i2c_block_data().
> I'll need to know if this is a chip limit or a controller limit.
> If it is a controller limit, a chip specific override would be
> inappropriate.

I'll reply from top of my head (did not looked at the driver again).
IIRC, the biggest reason we need the chip-specific implementation is because of
the RAIL selection logic (mainly when not in page mode).

- Nuno Sá

> 
> Guenter
> 
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> >   drivers/hwmon/pmbus/pmbus.h      |  3 +++
> >   drivers/hwmon/pmbus/pmbus_core.c | 24 ++++++++++++++++++++++--
> >   2 files changed, 25 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
> > index 3d5586c67f84..d697939ec892 100644
> > --- a/drivers/hwmon/pmbus/pmbus.h
> > +++ b/drivers/hwmon/pmbus/pmbus.h
> > @@ -459,6 +459,9 @@ 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);
> > +	/* size of data_buf is I2C_SMBUS_BLOCK_MAX + 2 */
> > +	int (*read_block_data)(struct i2c_client *client, int page, u8 reg,
> > +			       char *data_buf);
> >   	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,
> > diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> > index 7b58f7198574..ff4572c473b7 100644
> > --- a/drivers/hwmon/pmbus/pmbus_core.c
> > +++ b/drivers/hwmon/pmbus/pmbus_core.c
> > @@ -533,6 +533,26 @@ static int pmbus_read_block_data(struct i2c_client *client, int page, u8 reg,
> >   	return rv;
> >   }
> > +/*
> > + * _pmbus_read_block_data() is similar to pmbus_read_block_data(), but checks if
> > + * a device specific mapping function exists and calls it if necessary.
> > + */
> > +static int _pmbus_read_block_data(struct i2c_client *client, int page, u8 reg,
> > +				  char *data_buf)
> > +{
> > +	struct pmbus_data *data = i2c_get_clientdata(client);
> > +	const struct pmbus_driver_info *info = data->info;
> > +	int status;
> > +
> > +	if (info->read_block_data) {
> > +		status = info->read_block_data(client, page, reg, data_buf);
> > +		if (status != -ENODATA)
> > +			return status;
> > +	}
> > +
> > +	return pmbus_read_block_data(client, page, reg, data_buf);
> > +}
> > +
> >   static struct pmbus_sensor *pmbus_find_sensor(struct pmbus_data *data, int page,
> >   					      int reg)
> >   {
> > @@ -678,7 +698,7 @@ static bool __maybe_unused pmbus_check_block_register(struct i2c_client *client,
> >   	struct pmbus_data *data = i2c_get_clientdata(client);
> >   	char data_buf[I2C_SMBUS_BLOCK_MAX + 2];
> > -	rv = pmbus_read_block_data(client, page, reg, data_buf);
> > +	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);
> >   	if (rv < 0 && (data->flags & PMBUS_READ_STATUS_AFTER_FAILED_CHECK))
> > @@ -3564,7 +3584,7 @@ static ssize_t pmbus_debugfs_block_read(struct file *file, char __user *buf,
> >   	char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 };
> >   	scoped_guard(pmbus_lock, client) {
> > -		rc = pmbus_read_block_data(client, entry->page, entry->reg, data);
> > +		rc = _pmbus_read_block_data(client, entry->page, entry->reg, data);
> >   		if (rc < 0)
> >   			return rc;
> >   	}
> > 
> 

  reply	other threads:[~2026-07-30 14:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 16:03 [PATCH 0/5] hwmon: (pmbus) Add support for MAX20826 and similar devices Nuno Sá
2026-07-28 16:03 ` Nuno Sá via B4 Relay
2026-07-28 16:03 ` [PATCH 1/5] hwmon: (pmbus/core) fix regulator enable/disable Nuno Sá
2026-07-28 16:03   ` Nuno Sá via B4 Relay
2026-07-28 16:22   ` sashiko-bot
2026-07-28 16:58   ` Guenter Roeck
2026-07-28 16:03 ` [PATCH 2/5] hwmon: (pmbus/core) increase number of phases and add new mask Nuno Sá
2026-07-28 16:03   ` Nuno Sá via B4 Relay
2026-07-28 16:19   ` sashiko-bot
2026-07-28 16:03 ` [PATCH 3/5] hwmon: (pmbus/core) Add mapping function to pmbus_read_block_data() Nuno Sá
2026-07-28 16:03   ` Nuno Sá via B4 Relay
2026-07-28 16:27   ` sashiko-bot
2026-07-28 18:13     ` Guenter Roeck
2026-07-28 21:05   ` Guenter Roeck
2026-07-30 14:27     ` Nuno Sá [this message]
2026-07-30 14:47       ` Guenter Roeck
2026-07-30 15:19         ` Nuno Sá
2026-07-30 15:54           ` Guenter Roeck
2026-07-28 16:03 ` [PATCH 4/5] dt-bindings: hwmon/pmbus: Document MAX20826 and similar devices Nuno Sá
2026-07-28 16:03   ` Nuno Sá via B4 Relay
2026-07-28 16:17   ` sashiko-bot
2026-07-28 16:03 ` [PATCH 5/5] hwmon: (pmbus) add support for " Nuno Sá
2026-07-28 16:03   ` Nuno Sá via B4 Relay
2026-07-28 16:24   ` sashiko-bot
2026-07-28 22:12   ` Guenter Roeck
2026-07-29 12:18   ` Uwe Kleine-König
2026-07-30 11:08     ` Nuno Sá

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=amtewh9lOgWz0-Nh@nsa \
    --to=noname.nuno@gmail.com \
    --cc=atull@opensource.altera.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    --cc=skhan@linuxfoundation.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.