aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>2025-06-19 21:37:45 +0200
committerGuenter Roeck <linux@roeck-us.net>2025-07-20 16:38:34 -0700
commit50f16073d175670f41f3f64ae64ab66a745fd58b (patch)
treebb87c8e0a849ac1d1f50193ec23fd5f6a8e2babb
parenthwmon: (pmbus/tps53679) Add support for TPS53685 (diff)
downloadwireguard-linux-50f16073d175670f41f3f64ae64ab66a745fd58b.tar.xz
wireguard-linux-50f16073d175670f41f3f64ae64ab66a745fd58b.zip
hwmon: (adt7475) Implement support for #pwm-cells = <3>
The adt7475 driver and binding are outliers requiring 4 pwm-cells. The typical value is 3, there are a few devices that use a lesser value for historical reasons, no other uses a value bigger than 3. Implement support for 3 cells to make the adt7475 binding match the usual PWM binding. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Link: https://lore.kernel.org/r/b5cc994cbe74095e39468fd694c721d7c879db78.1750361514.git.u.kleine-koenig@baylibre.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/adt7475.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
index 5f2541c11fe9..8cefa14e1633 100644
--- a/drivers/hwmon/adt7475.c
+++ b/drivers/hwmon/adt7475.c
@@ -1704,12 +1704,15 @@ static int adt7475_pwm_properties_parse_reference_args(struct fwnode_handle *fwn
if (ret)
return ret;
- if (rargs.nargs != 4) {
+ if (rargs.nargs != 3 && rargs.nargs != 4) {
fwnode_handle_put(rargs.fwnode);
return -EINVAL;
}
- for (i = 0; i < 4; i++)
+ /* Let duty_cycle default to period */
+ args[3] = rargs.args[1];
+
+ for (i = 0; i < rargs.nargs; i++)
args[i] = rargs.args[i];
ret = _adt7475_pwm_properties_parse_args(args, cfg);
@@ -1724,11 +1727,22 @@ static int adt7475_pwm_properties_parse_args(struct fwnode_handle *fwnode,
{
int ret;
u32 args[4] = {};
+ size_t n_vals = fwnode_property_count_u32(fwnode, "pwms");
+
+ if (n_vals != 3 && n_vals != 4)
+ return -EOVERFLOW;
- ret = fwnode_property_read_u32_array(fwnode, "pwms", args, ARRAY_SIZE(args));
+ ret = fwnode_property_read_u32_array(fwnode, "pwms", args, n_vals);
if (ret)
return ret;
+ /*
+ * If there are no item to define the duty_cycle, default it to the
+ * period.
+ */
+ if (n_vals == 3)
+ args[3] = args[1];
+
return _adt7475_pwm_properties_parse_args(args, cfg);
}