Re: [PATCH v2] hwmon: corsair-cpro: Change to HID driver

From: Marius Zachmann
Date: Wed Jul 15 2020 - 15:13:58 EST


On 15.07.20 at 17:35:08 CEST, Guenter Roeck wrote
> On 7/15/20 8:14 AM, Marius Zachmann wrote:
> > This changes corsair-cpro to a hid driver using hid reports.
> >
> > Signed-off-by: Marius Zachmann <mail@xxxxxxxxxxxxxxxxx>
> >
> > ---
>
...
> > -module_usb_driver(ccp_driver);
> > +static int __init ccp_init(void)
> > +{
> > + return hid_register_driver(&ccp_driver);
> > +}
> > +
> > +static void __exit ccp_exit(void)
> > +{
> > + hid_unregister_driver(&ccp_driver);
> > +}
> > +
> > +/* make sure it is loaded after hid */
> > +late_initcall(ccp_init);
> > +module_exit(ccp_exit);
>
> Sorry for not noticing before, but can you use module_hid_driver() ?
> That seems to work for other hid drivers.
>
> Thanks,
> Guenter
>

When using module_hid_driver() and compiling the driver as built-in
the driver init function will get called before hid and fail registering
the driver. late_initcall forces it to be loaded after hid.

Greetings,
Marius