Skip to content

Commit 461d68d

Browse files
ukleinekUwe Kleine-König
authored andcommitted
pwm: Add actual hardware state to pwm debugfs file
Traditionally /sys/kernel/debug/pwm only contained info from pwm->state. Most of the time this data represents the last requested setting which might differ considerably from the actually configured in hardware setting. Expand the information in the debugfs file with the actual values. Signed-off-by: Uwe Kleine-König <[email protected]> Reviewed-by: Trevor Gamblin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 7cfe1e2 commit 461d68d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

drivers/pwm/core.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,25 +2221,28 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
22212221

22222222
for (i = 0; i < chip->npwm; i++) {
22232223
struct pwm_device *pwm = &chip->pwms[i];
2224-
struct pwm_state state;
2224+
struct pwm_state state, hwstate;
22252225

22262226
pwm_get_state(pwm, &state);
2227+
pwm_get_state_hw(pwm, &hwstate);
22272228

22282229
seq_printf(s, " pwm-%-3d (%-20.20s):", i, pwm->label);
22292230

22302231
if (test_bit(PWMF_REQUESTED, &pwm->flags))
22312232
seq_puts(s, " requested");
22322233

2233-
if (state.enabled)
2234-
seq_puts(s, " enabled");
2234+
seq_puts(s, "\n");
22352235

2236-
seq_printf(s, " period: %llu ns", state.period);
2237-
seq_printf(s, " duty: %llu ns", state.duty_cycle);
2238-
seq_printf(s, " polarity: %s",
2236+
seq_printf(s, " requested configuration: %3sabled, %llu/%llu ns, %s polarity",
2237+
state.enabled ? "en" : "dis", state.duty_cycle, state.period,
22392238
state.polarity ? "inverse" : "normal");
2240-
22412239
if (state.usage_power)
2242-
seq_puts(s, " usage_power");
2240+
seq_puts(s, ", usage_power");
2241+
seq_puts(s, "\n");
2242+
2243+
seq_printf(s, " actual configuration: %3sabled, %llu/%llu ns, %s polarity",
2244+
hwstate.enabled ? "en" : "dis", hwstate.duty_cycle, hwstate.period,
2245+
hwstate.polarity ? "inverse" : "normal");
22432246

22442247
seq_puts(s, "\n");
22452248
}

0 commit comments

Comments
 (0)