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: 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 <u.kleine-koenig@baylibre.com>
Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
Link: https://lore.kernel.org/r/20250404104844.543479-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
461d68d4 7cfe1e20

+11 -8
+11 -8
drivers/pwm/core.c
··· 2221 2221 2222 2222 for (i = 0; i < chip->npwm; i++) { 2223 2223 struct pwm_device *pwm = &chip->pwms[i]; 2224 - struct pwm_state state; 2224 + struct pwm_state state, hwstate; 2225 2225 2226 2226 pwm_get_state(pwm, &state); 2227 + pwm_get_state_hw(pwm, &hwstate); 2227 2228 2228 2229 seq_printf(s, " pwm-%-3d (%-20.20s):", i, pwm->label); 2229 2230 2230 2231 if (test_bit(PWMF_REQUESTED, &pwm->flags)) 2231 2232 seq_puts(s, " requested"); 2232 2233 2233 - if (state.enabled) 2234 - seq_puts(s, " enabled"); 2234 + seq_puts(s, "\n"); 2235 2235 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, 2239 2238 state.polarity ? "inverse" : "normal"); 2240 - 2241 2239 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"); 2243 2246 2244 2247 seq_puts(s, "\n"); 2245 2248 }