Skip to content

Commit 307004e

Browse files
Wer-Wolfgroeck
authored andcommitted
hwmon: (corsair-psu) Fix probe when built-in
It seems that when the driver is built-in, the HID bus is initialized after the driver is loaded, which whould cause module_hid_driver() to fail. Fix this by registering the driver after the HID bus using late_initcall() in accordance with other hwmon HID drivers. Signed-off-by: Armin Wolf <[email protected]> Link: https://lore.kernel.org/r/[email protected] [groeck: Dropped "compile tested" comment; the patch has been tested but the tester did not provide a Tested-by: tag] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 35fe2ad commit 307004e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

drivers/hwmon/corsair-psu.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,23 @@ static struct hid_driver corsairpsu_driver = {
899899
.reset_resume = corsairpsu_resume,
900900
#endif
901901
};
902-
module_hid_driver(corsairpsu_driver);
902+
903+
static int __init corsair_init(void)
904+
{
905+
return hid_register_driver(&corsairpsu_driver);
906+
}
907+
908+
static void __exit corsair_exit(void)
909+
{
910+
hid_unregister_driver(&corsairpsu_driver);
911+
}
912+
913+
/*
914+
* With module_init() the driver would load before the HID bus when
915+
* built-in, so use late_initcall() instead.
916+
*/
917+
late_initcall(corsair_init);
918+
module_exit(corsair_exit);
903919

904920
MODULE_LICENSE("GPL");
905921
MODULE_AUTHOR("Wilken Gottwalt <[email protected]>");

0 commit comments

Comments
 (0)