From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Guenter Roeck <linux@roeck-us.net>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Jerome Brunet <jbrunet@baylibre.com>
Subject: [PATCH v1 1/1] hwmon: (pmbus/tps25990) Don't check for specific errors when parsing properties
Date: Thu, 19 Feb 2026 15:19:36 +0100 [thread overview]
Message-ID: <20260219141936.2259945-1-andriy.shevchenko@linux.intel.com> (raw)
Instead of checking for the specific error codes (that can be considered
a layering violation to some extent) check for the property existence first
and then either parse it, or apply a default value.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/hwmon/pmbus/tps25990.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/hwmon/pmbus/tps25990.c b/drivers/hwmon/pmbus/tps25990.c
index c13edd7e1abf..05c6288ecafc 100644
--- a/drivers/hwmon/pmbus/tps25990.c
+++ b/drivers/hwmon/pmbus/tps25990.c
@@ -402,12 +402,18 @@ static int tps25990_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct pmbus_driver_info *info;
- u32 rimon = TPS25990_DEFAULT_RIMON;
+ const char *propname;
+ u32 rimon;
int ret;
- ret = device_property_read_u32(dev, "ti,rimon-micro-ohms", &rimon);
- if (ret < 0 && ret != -EINVAL)
- return dev_err_probe(dev, ret, "failed to get rimon\n");
+ propname = "ti,rimon-micro-ohms";
+ if (device_property_present(dev, propname)) {
+ ret = device_property_read_u32(dev, propname, &rimon);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to get %s\n", propname);
+ } else {
+ rimon = TPS25990_DEFAULT_RIMON;
+ }
info = devm_kmemdup(dev, &tps25990_base_info, sizeof(*info), GFP_KERNEL);
if (!info)
--
2.50.1
next reply other threads:[~2026-02-19 14:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 14:19 Andy Shevchenko [this message]
2026-04-12 14:24 ` [PATCH v1 1/1] hwmon: (pmbus/tps25990) Don't check for specific errors when parsing properties Guenter Roeck
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=20260219141936.2259945-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=jbrunet@baylibre.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.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