[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231208130710.191420-1-savicaleksa83@gmail.com>
Date: Fri, 8 Dec 2023 14:07:10 +0100
From: Aleksa Savic <savicaleksa83@...il.com>
To: linux-hwmon@...r.kernel.org
Cc: Aleksa Savic <savicaleksa83@...il.com>,
Wilken Gottwalt <wilken.gottwalt@...teo.net>,
Jean Delvare <jdelvare@...e.com>,
Guenter Roeck <linux@...ck-us.net>,
linux-kernel@...r.kernel.org
Subject: [PATCH] hwmon: (corsair-psu) Fix failure to load when built-in to kernel
When built-in to the kernel, the corsair-psu driver fails to register with
the following message:
"Driver 'corsair-psu' was unable to register with bus_type 'hid'
because the bus was not initialized."
Fix this by initializing the driver after the HID bus using
late_initcall(), as hwmon is built before HID.
Fixes: d115b51e0e56 ("hwmon: add Corsair PSU HID controller driver")
Signed-off-by: Aleksa Savic <savicaleksa83@...il.com>
---
drivers/hwmon/corsair-psu.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/corsair-psu.c b/drivers/hwmon/corsair-psu.c
index 904890598c11..48831a528965 100644
--- a/drivers/hwmon/corsair-psu.c
+++ b/drivers/hwmon/corsair-psu.c
@@ -899,7 +899,20 @@ static struct hid_driver corsairpsu_driver = {
.reset_resume = corsairpsu_resume,
#endif
};
-module_hid_driver(corsairpsu_driver);
+
+static int __init corsairpsu_hid_init(void)
+{
+ return hid_register_driver(&corsairpsu_driver);
+}
+
+static void __exit corsairpsu_hid_exit(void)
+{
+ hid_unregister_driver(&corsairpsu_driver);
+}
+
+/* When compiled into the kernel, initialize after the hid bus */
+late_initcall(corsairpsu_hid_init);
+module_exit(corsairpsu_hid_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Wilken Gottwalt <wilken.gottwalt@...teo.net>");
--
2.43.0
Powered by blists - more mailing lists