From: "Pradhan, Sanman" <sanman.pradhan@hpe.com>
To: "linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>
Cc: "linux@roeck-us.net" <linux@roeck-us.net>,
"wenswang@yeah.net" <wenswang@yeah.net>,
"chou.cosmo@gmail.com" <chou.cosmo@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Sanman Pradhan <psanman@juniper.net>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: [PATCH v2 1/5] hwmon: (pmbus) Use -ENODATA for unhandled registers in MPS drivers
Date: Mon, 23 Mar 2026 23:33:37 +0000 [thread overview]
Message-ID: <20260323233244.201294-2-sanman.pradhan@hpe.com> (raw)
In-Reply-To: <20260323233244.201294-1-sanman.pradhan@hpe.com>
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
next parent reply other threads:[~2026-03-23 23:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260323233244.201294-1-sanman.pradhan@hpe.com>
2026-03-23 23:33 ` Pradhan, Sanman [this message]
2026-03-23 23:33 ` [PATCH v2 2/5] hwmon: (pmbus) Fix return type truncation in MPS reg2data_linear11() Pradhan, Sanman
2026-03-23 23:33 ` [PATCH v2 3/5] hwmon: (pmbus/mp9945) Replace raw I2C calls with PMBus core API Pradhan, Sanman
2026-03-23 23:34 ` [PATCH v2 4/5] hwmon: (pmbus/mp29502) " Pradhan, Sanman
2026-03-23 23:34 ` [PATCH v2 5/5] hwmon: (pmbus/mp29502) Prevent division by zero from hardware register Pradhan, Sanman
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=20260323233244.201294-2-sanman.pradhan@hpe.com \
--to=sanman.pradhan@hpe.com \
--cc=chou.cosmo@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=psanman@juniper.net \
--cc=stable@vger.kernel.org \
--cc=wenswang@yeah.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox