From: Sanman Pradhan <psanman@juniper.net>
The read_word_data and write_word_data callbacks in mp2869, mp29502, and
mp2925 return -EINVAL for unhandled register addresses. In the PMBus core,
-ENODATA has a special meaning: it tells the core to fall through to the
standard PMBus register read/write path. Any other negative value (such
as -EINVAL) tells the core the register does not exist, causing valid
PMBus standard registers to be silently hidden.
Replace -EINVAL with -ENODATA in the default case of all affected
read_word_data and write_word_data callbacks so that standard PMBus
registers not handled by the driver are properly served by the core.
While at it, remove the explicit per-register -ENODATA cases in
mp2925_read_word_data() and the PMBUS_STATUS_WORD case in
mp29502_read_word_data() that are now redundant with the default.
Returning -ENODATA lets the PMBus core handle standard PMBus registers
through its normal fallback path. In mp2925 and mp29502, the existing
explicit -ENODATA cases are folded into the default case, preserving the
intended fallback behavior while simplifying the callback logic.
Fixes: a3a2923aaf7f ("hwmon: add MP2869,MP29608,MP29612 and MP29816 series driver")
Fixes: 90bad684e9ac ("hwmon: add MP29502 driver")
Fixes: a79472e30be4 ("hwmon: Add MP2925 and MP2929 driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sanman Pradhan <psanman@juniper.net>
---
v2:
- Folded explicit per-register -ENODATA cases into the default case
per feedback.
- Reworded the fallback rationale to describe the intended PMBus core
behavior more precisely.
---
drivers/hwmon/pmbus/mp2869.c | 4 ++--
drivers/hwmon/pmbus/mp2925.c | 21 ++-------------------
drivers/hwmon/pmbus/mp29502.c | 7 ++-----
3 files changed, 6 insertions(+), 26 deletions(-)
diff --git a/drivers/hwmon/pmbus/mp2869.c b/drivers/hwmon/pmbus/mp2869.c
index cc69a1e91dfe..4f8543801298 100644
--- a/drivers/hwmon/pmbus/mp2869.c
+++ b/drivers/hwmon/pmbus/mp2869.c
@@ -391,7 +391,7 @@ static int mp2869_read_word_data(struct i2c_client *client, int page, int phase,
ret = (ret & GENMASK(7, 0)) * MP2869_POUT_OP_GAIN;
break;
default:
- ret = -EINVAL;
+ ret = -ENODATA;
break;
}
@@ -536,7 +536,7 @@ static int mp2869_write_word_data(struct i2c_client *client, int page, int reg,
MP2869_POUT_OP_GAIN)));
break;
default:
- ret = -EINVAL;
+ ret = -ENODATA;
break;
}
diff --git a/drivers/hwmon/pmbus/mp2925.c b/drivers/hwmon/pmbus/mp2925.c
index ad094842cf2d..570e343fdf24 100644
--- a/drivers/hwmon/pmbus/mp2925.c
+++ b/drivers/hwmon/pmbus/mp2925.c
@@ -114,25 +114,8 @@ static int mp2925_read_word_data(struct i2c_client *client, int page, int phase,
ret = DIV_ROUND_CLOSEST((ret & GENMASK(11, 0)) * MP2925_VOUT_OVUV_UINT,
MP2925_VOUT_OVUV_DIV);
break;
- case PMBUS_STATUS_WORD:
- case PMBUS_READ_VIN:
- case PMBUS_READ_IOUT:
- case PMBUS_READ_POUT:
- case PMBUS_READ_PIN:
- case PMBUS_READ_IIN:
- case PMBUS_READ_TEMPERATURE_1:
- case PMBUS_VIN_OV_FAULT_LIMIT:
- case PMBUS_VIN_OV_WARN_LIMIT:
- case PMBUS_VIN_UV_WARN_LIMIT:
- case PMBUS_VIN_UV_FAULT_LIMIT:
- case PMBUS_IOUT_OC_FAULT_LIMIT:
- case PMBUS_IOUT_OC_WARN_LIMIT:
- case PMBUS_OT_FAULT_LIMIT:
- case PMBUS_OT_WARN_LIMIT:
- ret = -ENODATA;
- break;
default:
- ret = -EINVAL;
+ ret = -ENODATA;
break;
}
@@ -203,7 +186,7 @@ static int mp2925_write_word_data(struct i2c_client *client, int page, int reg,
ret)));
break;
default:
- ret = -EINVAL;
+ ret = -ENODATA;
break;
}
diff --git a/drivers/hwmon/pmbus/mp29502.c b/drivers/hwmon/pmbus/mp29502.c
index 7241373f1557..aad4c57a0a2c 100644
--- a/drivers/hwmon/pmbus/mp29502.c
+++ b/drivers/hwmon/pmbus/mp29502.c
@@ -293,9 +293,6 @@ static int mp29502_read_word_data(struct i2c_client *client, int page,
int ret;
switch (reg) {
- case PMBUS_STATUS_WORD:
- ret = -ENODATA;
- break;
case PMBUS_READ_VIN:
/*
* The MP29502 PMBUS_READ_VIN[10:0] is the vin value, the vin scale is
@@ -456,7 +453,7 @@ static int mp29502_read_word_data(struct i2c_client *client, int page,
ret = (ret & GENMASK(7, 0)) - MP29502_TEMP_LIMIT_OFFSET;
break;
default:
- ret = -EINVAL;
+ ret = -ENODATA;
break;
}
@@ -555,7 +552,7 @@ static int mp29502_write_word_data(struct i2c_client *client, int page, int reg,
word + MP29502_TEMP_LIMIT_OFFSET));
break;
default:
- ret = -EINVAL;
+ ret = -ENODATA;
break;
}
--
2.34.1