diff options
author | Uwe Kleine-König <[email protected]> | 2024-06-27 00:25:27 +0200 |
---|---|---|
committer | Uwe Kleine-König <[email protected]> | 2024-07-10 17:53:51 +0200 |
commit | 44ee95184e785c64e301498dec112bb1582bffd2 (patch) | |
tree | 63753ca585850ef423d116ddf9a8e430d7aba4b1 | |
parent | 9b22ceb31a7dda9a78959db3c6e35b04888032f9 (diff) |
pwm: Register debugfs operations after the pwm class
While the debugfs operations don't technically depend on an initialized
class, they loop over the idr that only can get entries when the class
is properly initialized.
This also fixes the ugly (but harmless) corner case that the debugfs
file stays around after the pwm class failed to initialize.
While at it, add an appropriate error message when class initialization
fails.
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]>
-rw-r--r-- | drivers/pwm/core.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 5c1d20985148..84ca846120a2 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -1705,9 +1705,17 @@ DEFINE_SEQ_ATTRIBUTE(pwm_debugfs); static int __init pwm_init(void) { + int ret; + + ret = class_register(&pwm_class); + if (ret) { + pr_err("Failed to initialize PWM class (%pe)\n", ERR_PTR(ret)); + return ret; + } + if (IS_ENABLED(CONFIG_DEBUG_FS)) debugfs_create_file("pwm", 0444, NULL, NULL, &pwm_debugfs_fops); - return class_register(&pwm_class); + return 0; } subsys_initcall(pwm_init); |