All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: linux-hwmon@vger.kernel.org
Cc: "Alexis Czezar Torreno" <alexisczezar.torreno@analog.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Guenter Roeck" <linux@roeck-us.net>
Subject: [PATCH 5/5] hwmon: (pmbus/ir36021) Use pmbus_read_smbus_i2c_block_data for block commands
Date: Mon,  3 Aug 2026 12:35:35 -0700	[thread overview]
Message-ID: <20260803193535.2286578-6-linux@roeck-us.net> (raw)
In-Reply-To: <20260803193535.2286578-1-linux@roeck-us.net>

The driver uses i2c_smbus_read_i2c_block_data() for PMBus block commands.
Use pmbus_read_smbus_i2c_block_data() instead to enable the driver to work
with I2C controllers which do not support i2c_smbus_read_i2c_block_data().

Drop the functionality check to get an explicit error message if the
required SMBus commands are not supported.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/pmbus/ir36021.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/hwmon/pmbus/ir36021.c b/drivers/hwmon/pmbus/ir36021.c
index 0dce4c3f666f..58d8c4aac0d1 100644
--- a/drivers/hwmon/pmbus/ir36021.c
+++ b/drivers/hwmon/pmbus/ir36021.c
@@ -31,21 +31,13 @@ static int ir36021_probe(struct i2c_client *client)
 	u8 buf[I2C_SMBUS_BLOCK_MAX];
 	int ret;
 
-	if (!i2c_check_functionality(client->adapter,
-				     I2C_FUNC_SMBUS_READ_BYTE_DATA
-				     | I2C_FUNC_SMBUS_READ_WORD_DATA
-				     | I2C_FUNC_SMBUS_READ_BLOCK_DATA))
-		return -ENODEV;
-
-	ret = i2c_smbus_read_i2c_block_data(client, PMBUS_MFR_MODEL, 2, buf);
-	if (ret < 0) {
-		dev_err(&client->dev, "Failed to read PMBUS_MFR_MODEL\n");
-		return ret;
-	}
-	if (ret != 2 || buf[0] != 0x01 || buf[1] != 0x2d) {
-		dev_err(&client->dev, "MFR_MODEL unrecognised\n");
-		return -ENODEV;
-	}
+	ret = pmbus_read_smbus_i2c_block_data(client, PMBUS_MFR_MODEL, buf);
+	if (ret < 0)
+		return dev_err_probe(&client->dev, ret,
+				     "Failed to read PMBUS_MFR_MODEL\n");
+	if (ret != 1 || buf[0] != 0x2d)
+		return dev_err_probe(&client->dev, -ENODEV,
+				     "MFR_MODEL unrecognised\n");
 
 	return pmbus_do_probe(client, &ir36021_info);
 }
-- 
2.45.2


  parent reply	other threads:[~2026-08-03 19:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 19:35 [PATCH 0/5] hwmon: (pmbus/core) Introduce and use pmbus_read_smbus_i2c_block_data() Guenter Roeck
2026-08-03 19:35 ` [PATCH 1/5] hwmon: (pmbus/core) Introduce pmbus_read_smbus_i2c_block_data() Guenter Roeck
2026-08-03 19:47   ` sashiko-bot
2026-08-04  8:45   ` Nuno Sá
2026-08-04 18:12     ` Guenter Roeck
2026-08-03 19:35 ` [PATCH 2/5] hwmon: (pmbus/adm1275) Use pmbus_read_smbus_i2c_block_data for block commands Guenter Roeck
2026-08-03 19:48   ` sashiko-bot
2026-08-03 19:35 ` [PATCH 3/5] hwmon: (pmbus/ltc2978) " Guenter Roeck
2026-08-03 19:50   ` sashiko-bot
2026-08-03 19:35 ` [PATCH 4/5] hwmon: (pmbus/max20830) " Guenter Roeck
2026-08-03 19:43   ` sashiko-bot
2026-08-03 19:35 ` Guenter Roeck [this message]
2026-08-03 19:42   ` [PATCH 5/5] hwmon: (pmbus/ir36021) " sashiko-bot
2026-08-04  8:50 ` [PATCH 0/5] hwmon: (pmbus/core) Introduce and use pmbus_read_smbus_i2c_block_data() 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=20260803193535.2286578-6-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=alexisczezar.torreno@analog.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=nuno.sa@analog.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 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.