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: Do stricter return value checking for .round_waveform_tohw()

The .round_waveform_tohw() is supposed to return 0 if the request could
be rounded down to match the hardware capabilities and return 1 if
rounding down wasn't possible.

Expand the PWM_DEBUG check to not only assert proper downrounding if 0
was returned but also check that it was actually rounded up when the
callback signalled uprounding.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/dfb824ae37f99df068c752d48cbd163c044a74fb.1743844730.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
96d20cfd fa829c1f

+6 -6
+6 -6
drivers/pwm/core.c
··· 270 270 wf_req.duty_length_ns, wf_req.period_length_ns, wf_req.duty_offset_ns, ret_tohw); 271 271 272 272 if (IS_ENABLED(CONFIG_PWM_DEBUG) && 273 - ret_tohw == 0 && !pwm_check_rounding(&wf_req, wf)) 274 - dev_err(&chip->dev, "Wrong rounding: requested %llu/%llu [+%llu], result %llu/%llu [+%llu]\n", 273 + (ret_tohw == 0) != pwm_check_rounding(&wf_req, wf)) 274 + dev_err(&chip->dev, "Wrong rounding: requested %llu/%llu [+%llu], result %llu/%llu [+%llu], ret: %d\n", 275 275 wf_req.duty_length_ns, wf_req.period_length_ns, wf_req.duty_offset_ns, 276 - wf->duty_length_ns, wf->period_length_ns, wf->duty_offset_ns); 276 + wf->duty_length_ns, wf->period_length_ns, wf->duty_offset_ns, ret_tohw); 277 277 278 278 return ret_tohw; 279 279 } ··· 341 341 if (err) 342 342 return err; 343 343 344 - if (IS_ENABLED(CONFIG_PWM_DEBUG) && ret_tohw == 0 && !pwm_check_rounding(wf, &wf_rounded)) 345 - dev_err(&chip->dev, "Wrong rounding: requested %llu/%llu [+%llu], result %llu/%llu [+%llu]\n", 344 + if (IS_ENABLED(CONFIG_PWM_DEBUG) && (ret_tohw == 0) != pwm_check_rounding(wf, &wf_rounded)) 345 + dev_err(&chip->dev, "Wrong rounding: requested %llu/%llu [+%llu], result %llu/%llu [+%llu], ret: %d\n", 346 346 wf->duty_length_ns, wf->period_length_ns, wf->duty_offset_ns, 347 - wf_rounded.duty_length_ns, wf_rounded.period_length_ns, wf_rounded.duty_offset_ns); 347 + wf_rounded.duty_length_ns, wf_rounded.period_length_ns, wf_rounded.duty_offset_ns, ret_tohw); 348 348 349 349 if (exact && pwmwfcmp(wf, &wf_rounded)) { 350 350 dev_dbg(&chip->dev, "Requested no rounding, but %llu/%llu [+%llu] -> %llu/%llu [+%llu]\n",