Commit 6bb9cf3a authored by Luis R. Rodriguez's avatar Luis R. Rodriguez Committed by Greg Kroah-Hartman

firmware: provide helpers for registering the syfs loader

This makes init / exit much easier to read, and we can later
reuse this code on other errors not captured yet.
Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 59b6d859
...@@ -687,6 +687,16 @@ static struct class firmware_class = { ...@@ -687,6 +687,16 @@ static struct class firmware_class = {
.dev_release = fw_dev_release, .dev_release = fw_dev_release,
}; };
static inline int register_sysfs_loader(void)
{
return class_register(&firmware_class);
}
static inline void unregister_sysfs_loader(void)
{
class_unregister(&firmware_class);
}
static ssize_t firmware_loading_show(struct device *dev, static ssize_t firmware_loading_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
...@@ -1124,6 +1134,15 @@ fw_load_from_user_helper(struct firmware *firmware, const char *name, ...@@ -1124,6 +1134,15 @@ fw_load_from_user_helper(struct firmware *firmware, const char *name,
static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { } static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { }
static inline int register_sysfs_loader(void)
{
return 0;
}
static inline void unregister_sysfs_loader(void)
{
}
#endif /* CONFIG_FW_LOADER_USER_HELPER */ #endif /* CONFIG_FW_LOADER_USER_HELPER */
/* prepare firmware and firmware_buf structs; /* prepare firmware and firmware_buf structs;
...@@ -1842,20 +1861,14 @@ static int __init firmware_class_init(void) ...@@ -1842,20 +1861,14 @@ static int __init firmware_class_init(void)
return ret; return ret;
register_reboot_notifier(&fw_shutdown_nb); register_reboot_notifier(&fw_shutdown_nb);
#ifdef CONFIG_FW_LOADER_USER_HELPER return register_sysfs_loader();
return class_register(&firmware_class);
#else
return 0;
#endif
} }
static void __exit firmware_class_exit(void) static void __exit firmware_class_exit(void)
{ {
unregister_fw_pm_ops(); unregister_fw_pm_ops();
unregister_reboot_notifier(&fw_shutdown_nb); unregister_reboot_notifier(&fw_shutdown_nb);
#ifdef CONFIG_FW_LOADER_USER_HELPER unregister_sysfs_loader();
class_unregister(&firmware_class);
#endif
} }
fs_initcall(firmware_class_init); fs_initcall(firmware_class_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment