Skip to content

Commit 7f8ce4d

Browse files
ukleinekUwe Kleine-König
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 061f087 commit 7f8ce4d

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

drivers/pwm/core.c

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,14 @@ static int __pwm_write_waveform(struct pwm_chip *chip, struct pwm_device *pwm, c
216216
*
217217
* Typically a given waveform cannot be implemented exactly by hardware, e.g.
218218
* 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.
221221
*
222222
* Note however that the world doesn't stop turning when you call it, so when
223-
* doing
223+
* doing::
224224
*
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);
227227
*
228228
* the latter might fail, e.g. because an input clock changed its rate between
229229
* these two calls and the waveform determined by
@@ -233,8 +233,9 @@ static int __pwm_write_waveform(struct pwm_chip *chip, struct pwm_device *pwm, c
233233
* value (in the order period_length_ns, duty_length_ns and then
234234
* duty_offset_ns). Only if this isn't possible, a value might grow.
235235
*
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
237237
* negative errno.
238+
* Context: May sleep.
238239
*/
239240
int pwm_round_waveform_might_sleep(struct pwm_device *pwm, struct pwm_waveform *wf)
240241
{
@@ -291,6 +292,9 @@ EXPORT_SYMBOL_GPL(pwm_round_waveform_might_sleep);
291292
*
292293
* Stores the current configuration of the PWM in @wf. Note this is the
293294
* equivalent of pwm_get_state_hw() (and not pwm_get_state()) for pwm_waveform.
295+
*
296+
* Returns: 0 on success or a negative errno
297+
* Context: May sleep.
294298
*/
295299
int pwm_get_waveform_might_sleep(struct pwm_device *pwm, struct pwm_waveform *wf)
296300
{
@@ -399,13 +403,17 @@ static int __pwm_set_waveform(struct pwm_device *pwm,
399403
*
400404
* Typically a requested waveform cannot be implemented exactly, e.g. because
401405
* you requested .period_length_ns = 100 ns, but the hardware can only set
402-
* periods that are a multiple of 8.5 ns. With that hardware passing exact =
406+
* periods that are a multiple of 8.5 ns. With that hardware passing @exact =
403407
* true results in pwm_set_waveform_might_sleep() failing and returning 1. If
404-
* exact = false you get a period of 93.5 ns (i.e. the biggest period not bigger
408+
* @exact = false you get a period of 93.5 ns (i.e. the biggest period not bigger
405409
* than the requested value).
406-
* Note that even with exact = true, some rounding by less than 1 is
410+
* Note that even with @exact = true, some rounding by less than 1 ns is
407411
* possible/needed. In the above example requesting .period_length_ns = 94 and
408-
* exact = true, you get the hardware configured with period = 93.5 ns.
412+
* @exact = true, you get the hardware configured with period = 93.5 ns.
413+
*
414+
* Returns: 0 on success, 1 if was rounded up (if !@exact) or no perfect match was
415+
* possible (if @exact), or a negative errno
416+
* Context: May sleep.
409417
*/
410418
int pwm_set_waveform_might_sleep(struct pwm_device *pwm,
411419
const struct pwm_waveform *wf, bool exact)
@@ -565,11 +573,6 @@ static bool pwm_state_valid(const struct pwm_state *state)
565573
return true;
566574
}
567575

568-
/**
569-
* __pwm_apply() - atomically apply a new state to a PWM device
570-
* @pwm: PWM device
571-
* @state: new state to apply
572-
*/
573576
static int __pwm_apply(struct pwm_device *pwm, const struct pwm_state *state)
574577
{
575578
struct pwm_chip *chip;
@@ -678,6 +681,9 @@ static int __pwm_apply(struct pwm_device *pwm, const struct pwm_state *state)
678681
* Cannot be used in atomic context.
679682
* @pwm: PWM device
680683
* @state: new state to apply
684+
*
685+
* Returns: 0 on success, or a negative errno
686+
* Context: May sleep.
681687
*/
682688
int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state)
683689
{
@@ -719,6 +725,9 @@ EXPORT_SYMBOL_GPL(pwm_apply_might_sleep);
719725
* Not all PWM devices support this function, check with pwm_might_sleep().
720726
* @pwm: PWM device
721727
* @state: new state to apply
728+
*
729+
* Returns: 0 on success, or a negative errno
730+
* Context: Any
722731
*/
723732
int pwm_apply_atomic(struct pwm_device *pwm, const struct pwm_state *state)
724733
{
@@ -792,6 +801,9 @@ EXPORT_SYMBOL_GPL(pwm_get_state_hw);
792801
* This function will adjust the PWM config to the PWM arguments provided
793802
* by the DT or PWM lookup table. This is particularly useful to adapt
794803
* the bootloader config to the Linux one.
804+
*
805+
* Returns: 0 on success or a negative error code on failure.
806+
* Context: May sleep.
795807
*/
796808
int pwm_adjust_config(struct pwm_device *pwm)
797809
{

include/linux/pwm.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ static inline void pwm_init_state(const struct pwm_device *pwm,
218218
*
219219
* pwm_get_state(pwm, &state);
220220
* duty = pwm_get_relative_duty_cycle(&state, 100);
221+
*
222+
* Returns: rounded relative duty cycle multiplied by @scale
221223
*/
222224
static inline unsigned int
223225
pwm_get_relative_duty_cycle(const struct pwm_state *state, unsigned int scale)
@@ -244,8 +246,8 @@ pwm_get_relative_duty_cycle(const struct pwm_state *state, unsigned int scale)
244246
* pwm_set_relative_duty_cycle(&state, 50, 100);
245247
* pwm_apply_might_sleep(pwm, &state);
246248
*
247-
* This functions returns -EINVAL if @duty_cycle and/or @scale are
248-
* inconsistent (@scale == 0 or @duty_cycle > @scale).
249+
* Returns: 0 on success or ``-EINVAL`` if @duty_cycle and/or @scale are
250+
* inconsistent (@scale == 0 or @duty_cycle > @scale)
249251
*/
250252
static inline int
251253
pwm_set_relative_duty_cycle(struct pwm_state *state, unsigned int duty_cycle,
@@ -351,7 +353,7 @@ struct pwm_chip {
351353
* pwmchip_supports_waveform() - checks if the given chip supports waveform callbacks
352354
* @chip: The pwm_chip to test
353355
*
354-
* Returns true iff the pwm chip support the waveform functions like
356+
* Returns: true iff the pwm chip support the waveform functions like
355357
* pwm_set_waveform_might_sleep() and pwm_round_waveform_might_sleep()
356358
*/
357359
static inline bool pwmchip_supports_waveform(struct pwm_chip *chip)

0 commit comments

Comments
 (0)