summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorAdam Wujek <dev_public@wujek.eu>2022-06-01 01:33:03 +0000
committerGuenter Roeck <linux@roeck-us.net>2022-07-13 08:38:19 -0700
commit8a85007c8386ed8378ed3ee9f53e995e3c45fa1c (patch)
tree599153b78b95a2fe45aa44780b8a63961150c3dc /drivers/hwmon
parentbae26b801f98bc902ab4a43c96947f3a0ce4f3a0 (diff)
downloadlinux-8a85007c8386ed8378ed3ee9f53e995e3c45fa1c.tar.gz
linux-8a85007c8386ed8378ed3ee9f53e995e3c45fa1c.tar.bz2
linux-8a85007c8386ed8378ed3ee9f53e995e3c45fa1c.zip
hwmon: (pmbus) add a function to check the presence of a block register
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> Link: https://lore.kernel.org/r/20220601013232.801133-1-dev_public@wujek.eu Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/pmbus/pmbus_core.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index bb21f1e79289..156d22ad2ad0 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -441,6 +441,18 @@ int pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg,
}
EXPORT_SYMBOL_NS_GPL(pmbus_update_byte_data, PMBUS);
+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)
{
@@ -578,6 +590,22 @@ 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];
+
+ 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))
+ data->read_status(client, -1);
+ 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);