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: Let the of_xlate callbacks accept references without period

With this extension of_pwm_xlate_with_flags() is suitable to replace the
custom xlate function of the pwm-clps711x driver.

While touching these very similar functions align their implementations.

Link: https://lore.kernel.org/r/127622315d07d9d419ae8e6373c7e5be7fab7a62.1704835845.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

+9 -11
+9 -11
drivers/pwm/core.c
··· 107 107 { 108 108 struct pwm_device *pwm; 109 109 110 - /* flags in the third cell are optional */ 111 - if (args->args_count < 2) 110 + /* period in the second cell and flags in the third cell are optional */ 111 + if (args->args_count < 1) 112 112 return ERR_PTR(-EINVAL); 113 113 114 114 if (args->args[0] >= chip->npwm) ··· 118 118 if (IS_ERR(pwm)) 119 119 return pwm; 120 120 121 - pwm->args.period = args->args[1]; 122 - pwm->args.polarity = PWM_POLARITY_NORMAL; 121 + if (args->args_count > 1) 122 + pwm->args.period = args->args[1]; 123 123 124 + pwm->args.polarity = PWM_POLARITY_NORMAL; 124 125 if (args->args_count > 2 && args->args[2] & PWM_POLARITY_INVERTED) 125 126 pwm->args.polarity = PWM_POLARITY_INVERSED; 126 127 ··· 134 133 { 135 134 struct pwm_device *pwm; 136 135 137 - /* validate that one cell is specified, optionally with flags */ 138 - if (args->args_count != 1 && args->args_count != 2) 139 - return ERR_PTR(-EINVAL); 140 - 141 136 pwm = pwm_request_from_chip(chip, 0, NULL); 142 137 if (IS_ERR(pwm)) 143 138 return pwm; 144 139 145 - pwm->args.period = args->args[0]; 146 - pwm->args.polarity = PWM_POLARITY_NORMAL; 140 + if (args->args_count > 1) 141 + pwm->args.period = args->args[0]; 147 142 148 - if (args->args_count == 2 && args->args[1] & PWM_POLARITY_INVERTED) 143 + pwm->args.polarity = PWM_POLARITY_NORMAL; 144 + if (args->args_count > 1 && args->args[1] & PWM_POLARITY_INVERTED) 149 145 pwm->args.polarity = PWM_POLARITY_INVERSED; 150 146 151 147 return pwm;