Skip to content

Commit 44ee951

Browse files
ukleinekUwe Kleine-König
authored andcommitted
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]>
1 parent 9b22ceb commit 44ee951

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/pwm/core.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1705,9 +1705,17 @@ DEFINE_SEQ_ATTRIBUTE(pwm_debugfs);
17051705

17061706
static int __init pwm_init(void)
17071707
{
1708+
int ret;
1709+
1710+
ret = class_register(&pwm_class);
1711+
if (ret) {
1712+
pr_err("Failed to initialize PWM class (%pe)\n", ERR_PTR(ret));
1713+
return ret;
1714+
}
1715+
17081716
if (IS_ENABLED(CONFIG_DEBUG_FS))
17091717
debugfs_create_file("pwm", 0444, NULL, NULL, &pwm_debugfs_fops);
17101718

1711-
return class_register(&pwm_class);
1719+
return 0;
17121720
}
17131721
subsys_initcall(pwm_init);

0 commit comments

Comments
 (0)