Add callback reg2data() to allow device specific formatting for particular registers. Currently there is an assumption that 'limits' and 'history' registers are inherited conversion format from the relevant sensor class. But there are some devices, which for example, provides 'vout' register reading in 'vid' format, while 'limits' or 'history' registers for 'vout' are provided in linear format. Signed-off-by: Vadim Pasternak <vadimp@xxxxxxxxxxxx> --- drivers/hwmon/pmbus/pmbus.h | 1 + drivers/hwmon/pmbus/pmbus_core.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index 18e06fc6c53f..7acd75303c7f 100644 --- a/drivers/hwmon/pmbus/pmbus.h +++ b/drivers/hwmon/pmbus/pmbus.h @@ -427,6 +427,7 @@ struct pmbus_driver_info { 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); + int (*reg2data)(u16 reg, int data, long *val); /* * The identify function determines supported PMBus functionality. * This function is only necessary if a chip driver supports multiple diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 8d321bf7d15b..e1f88d362549 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -747,6 +747,10 @@ static long pmbus_reg2data(struct pmbus_data *data, struct pmbus_sensor *sensor) if (!sensor->convert) return sensor->data; + if (data->info->reg2data && + data->info->reg2data(sensor->reg, sensor->data, &val) != -ENODATA) + return val; + switch (data->info->format[sensor->class]) { case direct: val = pmbus_reg2data_direct(data, sensor); -- 2.11.0