Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp721216ybh; Wed, 15 Jul 2020 13:24:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9gUd39cGhvAIQr+5zgEGjwZNqrPTH0qqqxpaW/P79sAhiHCWdLeuDoL97NraClmGXZL18 X-Received: by 2002:a05:6402:a50:: with SMTP id bt16mr1041650edb.281.1594844643877; Wed, 15 Jul 2020 13:24:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594844643; cv=none; d=google.com; s=arc-20160816; b=ZqddcKpHBRtP53vnVdUCYE1GixKSbWNR5hhWeaic6d7ikgEpHm77ZUegmseIC7TanW G77Edd7/QnFnjTfdCFuDhEKLYjK9QyJ+ik0wH8T/1GOP0cqzUw5gwOmoH5JHBAnzA5fS RmHyR9wJWEviNVWXMKQsRht6xh72z1DOySNqxdejX6G4Q2mtzN81npDBOhIxyDXE3u9s 9oWOT0ZHXJAWpFpvtygJigX/zCbAyifWQug24W9j6K2FluurMAdxBEl1Qp9qqHB3uElx Uz2m7No93NpEXp0FsOmnsBFmrv7VNPVSaAEGVqipODSPWkQBiIZoSxnYjRhXWTtOCG8z yQRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=FK9QZRLxqW6NbjAKwbsnO+X7z8ChdpP9p4WPx0ISjoI=; b=LoF6FU7bOA77Kpssq+gAfU52hKwkd3DoNYAEP/w9/SDjCHJikdonTZCSVFMVQPCQaP 7lSS6HcGpZzS1jyboYZdHLUxT4bppwpCpW0Ut+kZ19V9TWboMIjySXXJ+kyyGF//7TkP 1YjbFjIrENxshnqCKb7UUfqLRjNxloOrIofHicZD4540k0drEjMngT0lQxaETthmK39w qimxu0Qj/HBCMhDcMn1Om4Hwf83el5lr3lxJGzPK2qZvCdWHPnF0cfepF5cOxsyrJCNE TF+s1UlAhLDIRIpI9hl197cf9Y7QhqyquOyiUfaf5PbJQA0dOPZcU7XGcaES9OwX1eqQ nNWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o26si1935195edq.32.2020.07.15.13.23.40; Wed, 15 Jul 2020 13:24:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727825AbgGOUXD (ORCPT + 99 others); Wed, 15 Jul 2020 16:23:03 -0400 Received: from ms-10.1blu.de ([178.254.4.101]:33922 "EHLO ms-10.1blu.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbgGOUXC (ORCPT ); Wed, 15 Jul 2020 16:23:02 -0400 Received: from [78.43.71.214] (helo=marius.localnet) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvnvf-00049v-Fg; Wed, 15 Jul 2020 22:22:59 +0200 From: Marius Zachmann To: Guenter Roeck Cc: Jean Delvare , 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 Message-ID: <3539133.zoi8ogbS3G@marius> In-Reply-To: <7a45a7ac-ef4d-b9c8-fac7-6c226baf1329@roeck-us.net> References: <20200715151419.43134-1-mail@mariuszachmann.de> <3864498.z6qT3ff8q6@marius> <7a45a7ac-ef4d-b9c8-fac7-6c226baf1329@roeck-us.net> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Con-Id: 241080 X-Con-U: 0-mail X-Originating-IP: 78.43.71.214 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > >>>>> > >>>>> --- > >>>> > >>> ... > >>>>> -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