diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2021-05-10 17:06:39 +0300 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2021-05-25 19:18:25 +0300 |
commit | 69230cfac3d02c1b8d78aa7bdb29a1710147d49b (patch) | |
tree | 942a8aa1913822a1c78ea7c9502f8af1c9f39eb1 /drivers/pwm/core.c | |
parent | 5447e7833629ee4208b7d41862ab0249d6b50077 (diff) | |
download | linux-69230cfac3d02c1b8d78aa7bdb29a1710147d49b.tar.xz |
pwm: Autodetect default value for of_pwm_n_cells from device tree
This allows to simplify all drivers that use three pwm-cells.
The only ugly side effect is that if a driver specified of_pwm_n_cells = 2
it suddenly supports device trees that use #pwm-cells = <3>. This however
isn't a bad thing because the driver doesn't need explicit support for
three cells as the core handles all the details. Also there is no such
in-tree driver.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/core.c')
-rw-r--r-- | drivers/pwm/core.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 821ee1959816..c165c5822703 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -158,8 +158,14 @@ static void of_pwmchip_add(struct pwm_chip *chip) return; if (!chip->of_xlate) { + u32 pwm_cells; + + if (of_property_read_u32(chip->dev->of_node, "#pwm-cells", + &pwm_cells)) + pwm_cells = 2; + chip->of_xlate = of_pwm_xlate_with_flags; - chip->of_pwm_n_cells = 2; + chip->of_pwm_n_cells = pwm_cells; } of_node_get(chip->dev->of_node); |