Skip to content

Commit e373991

Browse files
ukleinekUwe Kleine-König
authored andcommitted
pwm: rzg2l-gpt: Accept requests for too high period length
The period setting is shared for each pair of PWM channels. So if the twin channel is in use, the period must not be changed. According to the usual practise to pick the next smaller possible period, accept a request for a period that is bigger than the unchangable value. Signed-off-by: Uwe Kleine-König <[email protected]> Tested-by: Biju Das <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent b6b5683 commit e373991

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/pwm/pwm-rzg2l-gpt.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,19 @@ static int rzg2l_gpt_config(struct pwm_chip *chip, struct pwm_device *pwm,
270270
* prescale and period can NOT be modified when there are multiple IOs
271271
* in use with different settings.
272272
*/
273-
if (rzg2l_gpt->channel_request_count[ch] > 1 && period_ticks != rzg2l_gpt->period_ticks[ch])
274-
return -EBUSY;
273+
if (rzg2l_gpt->channel_request_count[ch] > 1) {
274+
if (period_ticks < rzg2l_gpt->period_ticks[ch])
275+
return -EBUSY;
276+
else
277+
period_ticks = rzg2l_gpt->period_ticks[ch];
278+
}
275279

276280
prescale = rzg2l_gpt_calculate_prescale(rzg2l_gpt, period_ticks);
277281
pv = rzg2l_gpt_calculate_pv_or_dc(period_ticks, prescale);
278282

279283
duty_ticks = mul_u64_u64_div_u64(state->duty_cycle, rzg2l_gpt->rate_khz, USEC_PER_SEC);
280-
if (duty_ticks > RZG2L_MAX_TICKS)
281-
duty_ticks = RZG2L_MAX_TICKS;
284+
if (duty_ticks > period_ticks)
285+
duty_ticks = period_ticks;
282286
dc = rzg2l_gpt_calculate_pv_or_dc(duty_ticks, prescale);
283287

284288
/*

0 commit comments

Comments
 (0)