Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pwm: Fix various formatting issues in kernel-doc

Add Return and (where interesting) Context sections, fix some formatting
and drop documenting the internal function __pwm_apply().

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20250417181611.2693599-2-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
7f8ce4d8 061f087f

+32 -18
+27 -15
drivers/pwm/core.c
··· 216 216 * 217 217 * Typically a given waveform cannot be implemented exactly by hardware, e.g. 218 218 * because hardware only supports coarse period resolution or no duty_offset. 219 - * This function returns the actually implemented waveform if you pass wf to 220 - * pwm_set_waveform_might_sleep now. 219 + * This function returns the actually implemented waveform if you pass @wf to 220 + * pwm_set_waveform_might_sleep() now. 221 221 * 222 222 * Note however that the world doesn't stop turning when you call it, so when 223 - * doing 223 + * doing:: 224 224 * 225 - * pwm_round_waveform_might_sleep(mypwm, &wf); 226 - * pwm_set_waveform_might_sleep(mypwm, &wf, true); 225 + * pwm_round_waveform_might_sleep(mypwm, &wf); 226 + * pwm_set_waveform_might_sleep(mypwm, &wf, true); 227 227 * 228 228 * the latter might fail, e.g. because an input clock changed its rate between 229 229 * these two calls and the waveform determined by ··· 233 233 * value (in the order period_length_ns, duty_length_ns and then 234 234 * duty_offset_ns). Only if this isn't possible, a value might grow. 235 235 * 236 - * Returns 0 on success, 1 if at least one value had to be rounded up or a 236 + * Returns: 0 on success, 1 if at least one value had to be rounded up or a 237 237 * negative errno. 238 + * Context: May sleep. 238 239 */ 239 240 int pwm_round_waveform_might_sleep(struct pwm_device *pwm, struct pwm_waveform *wf) 240 241 { ··· 292 291 * 293 292 * Stores the current configuration of the PWM in @wf. Note this is the 294 293 * equivalent of pwm_get_state_hw() (and not pwm_get_state()) for pwm_waveform. 294 + * 295 + * Returns: 0 on success or a negative errno 296 + * Context: May sleep. 295 297 */ 296 298 int pwm_get_waveform_might_sleep(struct pwm_device *pwm, struct pwm_waveform *wf) 297 299 { ··· 403 399 * 404 400 * Typically a requested waveform cannot be implemented exactly, e.g. because 405 401 * you requested .period_length_ns = 100 ns, but the hardware can only set 406 - * periods that are a multiple of 8.5 ns. With that hardware passing exact = 402 + * periods that are a multiple of 8.5 ns. With that hardware passing @exact = 407 403 * true results in pwm_set_waveform_might_sleep() failing and returning 1. If 408 - * exact = false you get a period of 93.5 ns (i.e. the biggest period not bigger 404 + * @exact = false you get a period of 93.5 ns (i.e. the biggest period not bigger 409 405 * than the requested value). 410 - * Note that even with exact = true, some rounding by less than 1 is 406 + * Note that even with @exact = true, some rounding by less than 1 ns is 411 407 * possible/needed. In the above example requesting .period_length_ns = 94 and 412 - * exact = true, you get the hardware configured with period = 93.5 ns. 408 + * @exact = true, you get the hardware configured with period = 93.5 ns. 409 + * 410 + * Returns: 0 on success, 1 if was rounded up (if !@exact) or no perfect match was 411 + * possible (if @exact), or a negative errno 412 + * Context: May sleep. 413 413 */ 414 414 int pwm_set_waveform_might_sleep(struct pwm_device *pwm, 415 415 const struct pwm_waveform *wf, bool exact) ··· 573 565 return true; 574 566 } 575 567 576 - /** 577 - * __pwm_apply() - atomically apply a new state to a PWM device 578 - * @pwm: PWM device 579 - * @state: new state to apply 580 - */ 581 568 static int __pwm_apply(struct pwm_device *pwm, const struct pwm_state *state) 582 569 { 583 570 struct pwm_chip *chip; ··· 681 678 * Cannot be used in atomic context. 682 679 * @pwm: PWM device 683 680 * @state: new state to apply 681 + * 682 + * Returns: 0 on success, or a negative errno 683 + * Context: May sleep. 684 684 */ 685 685 int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state) 686 686 { ··· 725 719 * Not all PWM devices support this function, check with pwm_might_sleep(). 726 720 * @pwm: PWM device 727 721 * @state: new state to apply 722 + * 723 + * Returns: 0 on success, or a negative errno 724 + * Context: Any 728 725 */ 729 726 int pwm_apply_atomic(struct pwm_device *pwm, const struct pwm_state *state) 730 727 { ··· 801 792 * This function will adjust the PWM config to the PWM arguments provided 802 793 * by the DT or PWM lookup table. This is particularly useful to adapt 803 794 * the bootloader config to the Linux one. 795 + * 796 + * Returns: 0 on success or a negative error code on failure. 797 + * Context: May sleep. 804 798 */ 805 799 int pwm_adjust_config(struct pwm_device *pwm) 806 800 {
+5 -3
include/linux/pwm.h
··· 218 218 * 219 219 * pwm_get_state(pwm, &state); 220 220 * duty = pwm_get_relative_duty_cycle(&state, 100); 221 + * 222 + * Returns: rounded relative duty cycle multiplied by @scale 221 223 */ 222 224 static inline unsigned int 223 225 pwm_get_relative_duty_cycle(const struct pwm_state *state, unsigned int scale) ··· 246 244 * pwm_set_relative_duty_cycle(&state, 50, 100); 247 245 * pwm_apply_might_sleep(pwm, &state); 248 246 * 249 - * This functions returns -EINVAL if @duty_cycle and/or @scale are 250 - * inconsistent (@scale == 0 or @duty_cycle > @scale). 247 + * Returns: 0 on success or ``-EINVAL`` if @duty_cycle and/or @scale are 248 + * inconsistent (@scale == 0 or @duty_cycle > @scale) 251 249 */ 252 250 static inline int 253 251 pwm_set_relative_duty_cycle(struct pwm_state *state, unsigned int duty_cycle, ··· 353 351 * pwmchip_supports_waveform() - checks if the given chip supports waveform callbacks 354 352 * @chip: The pwm_chip to test 355 353 * 356 - * Returns true iff the pwm chip support the waveform functions like 354 + * Returns: true iff the pwm chip support the waveform functions like 357 355 * pwm_set_waveform_might_sleep() and pwm_round_waveform_might_sleep() 358 356 */ 359 357 static inline bool pwmchip_supports_waveform(struct pwm_chip *chip)