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 pwm_set_waveform_might_sleep() return 0 instead of 1 after rounding up

While telling the caller of pwm_set_waveform_might_sleep() if the
request was completed by rounding down only or (some) rounding up gives
additional information, it makes usage this function needlessly hard and
the additional information is not used. A prove for that is that
currently both users of this function just pass the returned value up to
their caller even though a positive value isn't intended there.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/528cc3bbd9e35dea8646b1bcc0fbfe6c498bb4ed.1746010245.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
164c4ac7 e866834c

+8 -6
+8 -6
drivers/pwm/core.c
··· 411 411 * possible/needed. In the above example requesting .period_length_ns = 94 and 412 412 * @exact = true, you get the hardware configured with period = 93.5 ns. 413 413 * 414 - * Returns: 0 on success, 1 if was rounded up (if !@exact), -EDOM if setting 415 - * failed due to the exact waveform not being possible (if @exact), or a 416 - * different negative errno on failure. 414 + * Returns: 0 on success, -EDOM if setting failed due to the exact waveform not 415 + * being possible (if @exact), or a different negative errno on failure. 417 416 * Context: May sleep. 418 417 */ 419 418 int pwm_set_waveform_might_sleep(struct pwm_device *pwm, ··· 441 442 } 442 443 443 444 /* 444 - * map err == 1 to -EDOM for exact requests. Also make sure that -EDOM is 445 - * only returned in exactly that case. Note that __pwm_set_waveform() 446 - * should never return -EDOM which justifies the unlikely(). 445 + * map err == 1 to -EDOM for exact requests and 0 for !exact ones. Also 446 + * make sure that -EDOM is only returned in exactly that case. Note that 447 + * __pwm_set_waveform() should never return -EDOM which justifies the 448 + * unlikely(). 447 449 */ 448 450 if (unlikely(err == -EDOM)) 449 451 err = -EINVAL; 450 452 else if (exact && err == 1) 451 453 err = -EDOM; 454 + else if (err == 1) 455 + err = 0; 452 456 453 457 return err; 454 458 }