mirror of https://github.com/torvalds/linux.git
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>
This commit is contained in:
parent
75ca1e5875
commit
50f16073d1
|
|
@ -1704,12 +1704,15 @@ static int adt7475_pwm_properties_parse_reference_args(struct fwnode_handle *fwn
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (rargs.nargs != 4) {
|
if (rargs.nargs != 3 && rargs.nargs != 4) {
|
||||||
fwnode_handle_put(rargs.fwnode);
|
fwnode_handle_put(rargs.fwnode);
|
||||||
return -EINVAL;
|
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];
|
args[i] = rargs.args[i];
|
||||||
|
|
||||||
ret = _adt7475_pwm_properties_parse_args(args, cfg);
|
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;
|
int ret;
|
||||||
u32 args[4] = {};
|
u32 args[4] = {};
|
||||||
|
size_t n_vals = fwnode_property_count_u32(fwnode, "pwms");
|
||||||
|
|
||||||
ret = fwnode_property_read_u32_array(fwnode, "pwms", args, ARRAY_SIZE(args));
|
if (n_vals != 3 && n_vals != 4)
|
||||||
|
return -EOVERFLOW;
|
||||||
|
|
||||||
|
ret = fwnode_property_read_u32_array(fwnode, "pwms", args, n_vals);
|
||||||
if (ret)
|
if (ret)
|
||||||
return 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);
|
return _adt7475_pwm_properties_parse_args(args, cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue