[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230418220109.787907-1-chris.packham@alliedtelesis.co.nz>
Date: Wed, 19 Apr 2023 10:01:09 +1200
From: Chris Packham <chris.packham@...iedtelesis.co.nz>
To: jdelvare@...e.com, linux@...ck-us.net, manio@...boo.net
Cc: linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org,
Chris Packham <chris.packham@...iedtelesis.co.nz>
Subject: [PATCH] hwmon: (adt7475) Handle DT unaware platforms
Configuring the pwm polarity via the adi,pwm-active-state property is an
optional feature. On DT aware platforms of_property_read_u32_array()
returns -EINVAL when the property is absent this is checked for and the
driver probe continues without issue.
On DT unaware platfroms of_property_read_u32_array() returns -ENOSYS
which caused the driver probe to dev_warn(). Update the code to deal
with -ENOSYS so that the dev_warn() only occurs when there is a genuine
issue.
Fixes: 86da28eed4fb ("hwmon: (adt7475) Add support for inverting pwm output")
Reported-by: Mariusz Białończyk <manio@...boo.net>
Signed-off-by: Chris Packham <chris.packham@...iedtelesis.co.nz>
---
drivers/hwmon/adt7475.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
index 6e4c92b500b8..af906eee480e 100644
--- a/drivers/hwmon/adt7475.c
+++ b/drivers/hwmon/adt7475.c
@@ -1607,6 +1607,13 @@ static int adt7475_set_pwm_polarity(struct i2c_client *client)
ret = of_property_read_u32_array(client->dev.of_node,
"adi,pwm-active-state", states,
ARRAY_SIZE(states));
+ /*
+ * -EINVAL indicates that the property is absent, -ENOSYS indicates
+ * that the platform lacks DT awareness. Neither of these are errors
+ * for the optional pwm polarity support.
+ */
+ if (ret == -EINVAL || ret == -ENOSYS)
+ return 0;
if (ret)
return ret;
@@ -1741,7 +1748,7 @@ static int adt7475_probe(struct i2c_client *client)
adt7475_read_pwm(client, i);
ret = adt7475_set_pwm_polarity(client);
- if (ret && ret != -EINVAL)
+ if (ret)
dev_warn(&client->dev, "Error configuring pwm polarity\n");
/* Start monitoring */
--
2.40.0
Powered by blists - more mailing lists