* [PATCH v1 1/1] hwmon: (pmbus/tps25990) Don't check for specific errors when parsing properties
@ 2026-02-19 14:19 Andy Shevchenko
2026-04-12 14:24 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2026-02-19 14:19 UTC (permalink / raw)
To: Guenter Roeck, Andy Shevchenko, linux-hwmon, linux-kernel; +Cc: Jerome Brunet
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v1 1/1] hwmon: (pmbus/tps25990) Don't check for specific errors when parsing properties
2026-02-19 14:19 [PATCH v1 1/1] hwmon: (pmbus/tps25990) Don't check for specific errors when parsing properties Andy Shevchenko
@ 2026-04-12 14:24 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2026-04-12 14:24 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-hwmon, linux-kernel, Jerome Brunet
On Thu, Feb 19, 2026 at 03:19:36PM +0100, Andy Shevchenko wrote:
> 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>
Applied.
Thanks,
Guenter
> ---
> 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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-12 14:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-19 14:19 [PATCH v1 1/1] hwmon: (pmbus/tps25990) Don't check for specific errors when parsing properties Andy Shevchenko
2026-04-12 14:24 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®