Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

pwm: Add upgrade path to #pwm-cells = <3> for users of of_pwm_single_xlate()

The PWM chip on PXA only has a single output. Back when the device tree
binding was defined it was considered a good idea to not pass the PWM
line index as is done for all other PWM types as it would be always zero
anyhow and so doesn't add any value.

However for consistency reasons it is nice when all PWMs use the same
binding. For that reason let of_pwm_single_xlate() (i.e. the function
that implements the PXA behaviour) behave in the same way as
of_pwm_xlate_with_flags() for 3 (or more) parameters. With that in
place, the pxa-pwm binding can be updated to #pwm-cells = <3> without
breaking old device trees that stick to #pwm-cells = <1>.

Reviewed-by: Herve Codina <herve.codina@bootlin.com>
Tested-by: Duje Mihanović <duje.mihanovic@skole.hr>
Reviewed-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/b33a84d3f073880e94fc303cd32ebe095eb5ce46.1738842938.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>

authored by

Uwe Kleine-König and committed by
Uwe Kleine-König
895fe453 e320a240

+16
+16
drivers/pwm/core.c
··· 1000 1000 } 1001 1001 EXPORT_SYMBOL_GPL(of_pwm_xlate_with_flags); 1002 1002 1003 + /* 1004 + * This callback is used for PXA PWM chips that only have a single PWM line. 1005 + * For such chips you could argue that passing the line number (i.e. the first 1006 + * parameter in the common case) is useless as it's always zero. So compared to 1007 + * the default xlate function of_pwm_xlate_with_flags() the first parameter is 1008 + * the default period and the second are flags. 1009 + * 1010 + * Note that if #pwm-cells = <3>, the semantic is the same as for 1011 + * of_pwm_xlate_with_flags() to allow converting the affected driver to 1012 + * #pwm-cells = <3> without breaking the legacy binding. 1013 + * 1014 + * Don't use for new drivers. 1015 + */ 1003 1016 struct pwm_device * 1004 1017 of_pwm_single_xlate(struct pwm_chip *chip, const struct of_phandle_args *args) 1005 1018 { 1006 1019 struct pwm_device *pwm; 1020 + 1021 + if (args->args_count >= 3) 1022 + return of_pwm_xlate_with_flags(chip, args); 1007 1023 1008 1024 pwm = pwm_request_from_chip(chip, 0, NULL); 1009 1025 if (IS_ERR(pwm))