Skip to content

Commit fda6e00

Browse files
ukleinekUwe Kleine-König
authored andcommitted
pwm: stm32: Search an appropriate duty_cycle if period cannot be modified
If another channel is already enabled period must not be modified. If the requested period is smaller than this unchangable period the driver is still supposed to search a duty_cycle according to the usual rounding rules. So don't set the duty_cycle to 0 but continue to determine an appropriate value for ccr. Fixes: deaba9c ("pwm: stm32: Implementation of the waveform callbacks") Signed-off-by: Uwe Kleine-König <[email protected]> Link: https://lore.kernel.org/r/f0c50df31daa3d6069bfa8d7fb3e71fae241b026.1743844730.git.u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 00e53d0 commit fda6e00

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

drivers/pwm/pwm-stm32.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,16 @@ static int stm32_pwm_round_waveform_tohw(struct pwm_chip *chip,
103103
if (ret)
104104
goto out;
105105

106-
/*
107-
* calculate the best value for ARR for the given PSC, refuse if
108-
* the resulting period gets bigger than the requested one.
109-
*/
110106
arr = mul_u64_u64_div_u64(wf->period_length_ns, rate,
111107
(u64)NSEC_PER_SEC * (wfhw->psc + 1));
112108
if (arr <= wfhw->arr) {
113109
/*
114-
* requested period is small than the currently
110+
* requested period is smaller than the currently
115111
* configured and unchangable period, report back the smallest
116-
* possible period, i.e. the current state; Initialize
117-
* ccr to anything valid.
112+
* possible period, i.e. the current state and return 1
113+
* to indicate the wrong rounding direction.
118114
*/
119-
wfhw->ccr = 0;
120115
ret = 1;
121-
goto out;
122116
}
123117

124118
} else {

0 commit comments

Comments
 (0)