]> www.infradead.org Git - users/willy/xarray.git/commitdiff
pwm: Add actual hardware state to pwm debugfs file
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>
Fri, 4 Apr 2025 10:48:42 +0000 (12:48 +0200)
committerUwe Kleine-König <ukleinek@kernel.org>
Mon, 14 Apr 2025 06:03:16 +0000 (08:03 +0200)
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>
drivers/pwm/core.c

index 0387bd838487b1d93a7d8c786b03ffcaa9070b0d..02d98e4c75a5f84caaa3bc46e51308fb62f95ed4 100644 (file)
@@ -2221,25 +2221,28 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
 
        for (i = 0; i < chip->npwm; i++) {
                struct pwm_device *pwm = &chip->pwms[i];
-               struct pwm_state state;
+               struct pwm_state state, hwstate;
 
                pwm_get_state(pwm, &state);
+               pwm_get_state_hw(pwm, &hwstate);
 
                seq_printf(s, " pwm-%-3d (%-20.20s):", i, pwm->label);
 
                if (test_bit(PWMF_REQUESTED, &pwm->flags))
                        seq_puts(s, " requested");
 
-               if (state.enabled)
-                       seq_puts(s, " enabled");
+               seq_puts(s, "\n");
 
-               seq_printf(s, " period: %llu ns", state.period);
-               seq_printf(s, " duty: %llu ns", state.duty_cycle);
-               seq_printf(s, " polarity: %s",
+               seq_printf(s, "  requested configuration: %3sabled, %llu/%llu ns, %s polarity",
+                          state.enabled ? "en" : "dis", state.duty_cycle, state.period,
                           state.polarity ? "inverse" : "normal");
-
                if (state.usage_power)
-                       seq_puts(s, " usage_power");
+                       seq_puts(s, ", usage_power");
+               seq_puts(s, "\n");
+
+               seq_printf(s, "  actual configuration:    %3sabled, %llu/%llu ns, %s polarity",
+                          hwstate.enabled ? "en" : "dis", hwstate.duty_cycle, hwstate.period,
+                          hwstate.polarity ? "inverse" : "normal");
 
                seq_puts(s, "\n");
        }