linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marius Zachmann <mail@mariuszachmann.de>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Jean Delvare <jdelvare@suse.com>,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] hwmon: corsair-cpro: Change to HID driver
Date: Wed, 15 Jul 2020 22:22:58 +0200	[thread overview]
Message-ID: <3539133.zoi8ogbS3G@marius> (raw)
In-Reply-To: <7a45a7ac-ef4d-b9c8-fac7-6c226baf1329@roeck-us.net>

On 15.07.20 at 22:11:39 CEST, Guenter Roeck wrote
> On 7/15/20 12:55 PM, Marius Zachmann wrote:
> > On 15.07.20 at 21:49:59 CEST, Guenter Roeck wrote
> >> On 7/15/20 12:12 PM, Marius Zachmann wrote:
> >>> 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@mariuszachmann.de>
> >>>>>
> >>>>> ---
> >>>>
> >>> ...
> >>>>> -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.
> >>>
> >>
> >> That seems odd. Why does no other hid driver have that problem ?
> >> Your argument is pretty much that module_hid_driver() would not work,
> >> which seems unlikely.
> >>
> >> Thanks,
> >> Guenter
> >>
> > 
> > The order of initcalls is determined by the build order. Hwmon subsystem
> > gets build before hid subsystem and therefore the initcalls are earlier
> > than hid. But hid_register_driver needs the hid driver to be there.
> > 
> Hmm. I am not happy, but I guess we'll have to live with it.
> 
> Can you add the detailed explanation to the comment above ?
> "make sure it is loaded after hid" doesn't tell the whole story,
> and I want to avoid having to deal with "cleanup" patches later.
> 
> Alternatively, I wonder if it would make sense to force
> this driver to be built as module. Have you thought about that ?
> 
> Thanks,
> Guenter
> 

I am also not happy about this and thought about this, but I
think late_initcall is the least ugly solution to this.
I will add a more detailed explanation.

Greetings
Marius




      reply	other threads:[~2020-07-15 20:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-15 15:14 [PATCH v2] hwmon: corsair-cpro: Change to HID driver Marius Zachmann
2020-07-15 15:35 ` Guenter Roeck
2020-07-15 19:12   ` Marius Zachmann
2020-07-15 19:49     ` Guenter Roeck
2020-07-15 19:55       ` Marius Zachmann
2020-07-15 20:11         ` Guenter Roeck
2020-07-15 20:22           ` Marius Zachmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3539133.zoi8ogbS3G@marius \
    --to=mail@mariuszachmann.de \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).