Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20231207210723.222552-1-W_Armin@gmx.de
[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 <linux@roeck-us.net>

authored by

Armin Wolf and committed by
Guenter Roeck
307004e8 35fe2ad2

+17 -1
+17 -1
drivers/hwmon/corsair-psu.c
··· 899 899 .reset_resume = corsairpsu_resume, 900 900 #endif 901 901 }; 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); 903 919 904 920 MODULE_LICENSE("GPL"); 905 921 MODULE_AUTHOR("Wilken Gottwalt <wilken.gottwalt@posteo.net>");