Message ID | 20231207210723.222552-1-W_Armin@gmx.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5064072vqy; Thu, 7 Dec 2023 13:07:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8MYXLAogwMRk/DBnRvY2AChwOVLV486YkVMWERiccXFdvTOfuCCceEoSHlrAs0AKNC3nM X-Received: by 2002:a17:90b:4a11:b0:286:6cc1:3f14 with SMTP id kk17-20020a17090b4a1100b002866cc13f14mr3270083pjb.75.1701983278905; Thu, 07 Dec 2023 13:07:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701983278; cv=none; d=google.com; s=arc-20160816; b=oX/BnBtSQO1GhqW1lQsU5KC2Wj3NL+wOTDRvf4VTB7y2qiD/w1D53I/kKAaunFslYm Sc7auJ0lVa79d8teGhhbc2SZSz73qMw31ds9TddCCpRKKho9osdU/ngeblfl5IcV4bE6 5gLoOu/0zQVO31aFFLlWd1sgPHpzupexMkATvyunvXsfi3oIIIErt5HHI37p5aPelnI2 RyBo0eTnZbNLMJJiiqg+BPRVHJNHEK3j1GsHpXdALpzj1I6OkEoB9z47vyhbAitavWwq JVM51kvD7o2ltapJf9FT8IDWiC+kzctpRQWF64HD8+E+aGnyz6Kx385bnfQx9IhJQPpP Q9Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=e/LmYFqCVADPOiBxxiSjVAuh5B8vjfEnZaLk8Ubh/EQ=; fh=jdSS6GGUJUnrRu9xInwYEEtFjAfCHiASnNAZCFiYzSE=; b=XR1R8ATrwZni0KW0eP6iQTUwD81U3DxSSWa7HWDik4meLfLM/YIjDU+N+Akk39kcfc TzGKkNYPu3ItG0zXMaCNaofgegY5+ef/h/0hFoAqf7bejS+BnGgcw1vEHkjIMuS4vV/X O2/Gb7Yg0boc+v6yG1f/CPlHMgcMxDFfuALMzGwxZdGofBVQDT0BvcEBFVAJZyXhB7HZ B5sIzvdBLi1wN2mPR1rHGYzYklQ0AgWoA9S7LV0f1uzHHu+x298lRP76yiPQz7t+CB6t E9DK3DdizN449m5MqEe+vU3JHhubM+XD6xwjDcMtONZg9Rb/b7MBxYWOD9YApyU3mHQ8 ilwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=PqXNYQK6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z7-20020a17090abd8700b00285cc4f0e09si409727pjr.185.2023.12.07.13.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 13:07:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=PqXNYQK6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id EB70E80CF551; Thu, 7 Dec 2023 13:07:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235271AbjLGVHq (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Thu, 7 Dec 2023 16:07:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233305AbjLGVHo (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 7 Dec 2023 16:07:44 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B4501718; Thu, 7 Dec 2023 13:07:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1701983253; x=1702588053; i=w_armin@gmx.de; bh=dokTWT5/qKEIWL3FjJAfR6lazLd3nT0Z4f+vw5U4Urg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=PqXNYQK65B3Z1cuoUX+pUYSpj+feZYpdLXyrFla7F+ShY+RbsJYKOy0aV0MsapHh 2NUUkrkjRtaia8BAnATWr+/dCQAfCdk4Eg72YudIZvG85sn3swvi8cEZiP6eFHPft ReYx/3KvdctwQvS6sxa61rbIFVWn1parj07M0fDh/3f2/fQMPmjtLEfVZZveTwyDj MzAyzicDD6Sq3faUuKLmoKoZ2gpNXZqGXB1TZpc9NLQZQgXOYCnfceKb35PheNUk1 D2PI88aWlJ7y26PFxHmWpyYBrPhVajVLfaMsB5sgtA7NFodRr3eFNiP8j1vsqa9Sa pRMW8a6uGsMlHW0FEg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MmUHp-1rc7q02jfF-00iQck; Thu, 07 Dec 2023 22:07:33 +0100 From: Armin Wolf <W_Armin@gmx.de> To: wilken.gottwalt@posteo.net Cc: jdelvare@suse.com, linux@roeck-us.net, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] hwmon: (corsair-psu) Fix probe when built-in Date: Thu, 7 Dec 2023 22:07:23 +0100 Message-Id: <20231207210723.222552-1-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:GCP0IYyl6x0+7OkHz3se1KwxZHXxR7z9mJpNQtKLxCeiqWUcqKF sWLZKmt9pQCxmcmgCLFtmHBpc9oGRalpZRtXADrgH7xUscT9B12Dy6vPgZgMDAZqtTwT30M 7toyZtXQWCO/FVpA9CaZJfGFxFTqphENMZXQWQvCuv3jwV67QHTl+S9m/+q3azcXTdIm3si zzWeu1pnMDLYXVs1bs1+Q== UI-OutboundReport: notjunk:1;M01:P0:vHqp8faGvxk=;VPD02ArP9LJBfdJYyRNb5iGd9bE oYy6JcnGI+jpPnZpbLXra+I1k2Un/Q1ODq2DVk8tLB2ed70csY6c25QEwDfs7XxXrbrOCGh0O GPz4uLcOi3WtRi25MeKybEWbd5FDX6aGdIM1J5qjIKUqqlO29UX8D5YCE1Q9Am/ayaipPJ7bN HTjAiwWmZFPwPqpb+QpCjfK4A2UQDbwVC6ZvruHkmy3fv5YFJIBoZdzUBKseoIShG+ZErsX1n 8dFQA0enQNcxvs6FNTaqncO88dRzYNhPs1x+9D6QVa8Th4fRR4+UlHTXr0WMrZxDCBJ4J7FGU 5hxGXdEd9Lxu2UFalqL6xjiZrJNnQHjVjQrmjr1BH1nQYwcOGHPh3/2NcQLr0H6Zl5f/JlvWU PoY+KaePeIWKp2T+FtYXBFWEZlz3wWud5yyrs7cPw1J8XuTwHJXXkfPyU0TGkTa496eH8QZtx QHUF/bDoAEdMaiT19EBUFdTvVvkI4zL1VgL8uC5LSiILE51v7akzZNcZYcTrmG3pzbJU42IzC Am+YGAJnpnNf0reyQqxnn7WZWuKmzCX0vff8Tu1CNk4Zc4+PRXzqL4wan3IwQpnxKwg/8UH7U j0mvhebBv5mu6hS9HYRon3aA1oTXho4wklEYioWrIM3GoaSxpOlU7w/9Jbw/vuB8i8tr8wHRN mroiAiEB59QQkXYglyaH4qZxJAJbBRZFyVzLU/thihY5V9u0V0aaotB7vWxvBFuC+Bi74bTJs 7AhGOrq6iFPfWo3yhAbvNIvMZYwuv1PSSEsN8PGmU/tp5P4RpQkyVXX+/s+aTeift0tU8EGtT CD3Z4j9Zfix4OpxfirbLI1nHpysPks9NKrTUIFlo2B8jtZyYRQgBc1kx4y1Dksn3HtEZ4uNht zfafgsISWG98Q/KCMk5n3rOfESqg0iVYwGea9B5DAKvp65Q+yRhVdVjP9/SkYojVq0tdBhhnO 6BomVApjEXey2XIZ+ooT+kzOySQ= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 07 Dec 2023 13:07:58 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784658818522671424 X-GMAIL-MSGID: 1784658818522671424 |
Series |
hwmon: (corsair-psu) Fix probe when built-in
|
|
Commit Message
Armin Wolf
Dec. 7, 2023, 9:07 p.m. UTC
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.
Compile-tested only.
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
drivers/hwmon/corsair-psu.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
--
2.39.2
Comments
On Thu, 7 Dec 2023 22:07:23 +0100 Armin Wolf <W_Armin@gmx.de> wrote: > 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. > > Compile-tested only. So you did not test this? Well, I did. [ 2.225831] Driver 'corsair-psu' was unable to register with bus_type 'hid' because the bus was not initialized. [ 2.225835] amd_pstate: driver load is disabled, boot with specific mode to enable this [ 2.226363] ledtrig-cpu: registered to indicate activity on CPUs [ 2.226679] hid: raw HID events driver (C) Jiri Kosina You are right, it is a timing issue and this can actually happen. I'm fine with the fix. Though, this could even be a bigger issue. There are currently 104 HID drivers using the module_hid_driver macro. Maybe it would be a better idea to change the module_hid_driver macro to use the lateinit calls instead of the plain init/exit calls. greetings, Will > Signed-off-by: Armin Wolf <W_Armin@gmx.de> > --- > drivers/hwmon/corsair-psu.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/drivers/hwmon/corsair-psu.c b/drivers/hwmon/corsair-psu.c > index 904890598c11..2c7c92272fe3 100644 > --- a/drivers/hwmon/corsair-psu.c > +++ b/drivers/hwmon/corsair-psu.c > @@ -899,7 +899,23 @@ static struct hid_driver corsairpsu_driver = { > .reset_resume = corsairpsu_resume, > #endif > }; > -module_hid_driver(corsairpsu_driver); > + > +static int __init corsair_init(void) > +{ > + return hid_register_driver(&corsairpsu_driver); > +} > + > +static void __exit corsair_exit(void) > +{ > + hid_unregister_driver(&corsairpsu_driver); > +} > + > +/* > + * With module_init() the driver would load before the HID bus when > + * built-in, so use late_initcall() instead. > + */ > +late_initcall(corsair_init); > +module_exit(corsair_exit); > > MODULE_LICENSE("GPL"); > MODULE_AUTHOR("Wilken Gottwalt <wilken.gottwalt@posteo.net>"); > -- > 2.39.2 >
On Thu, Dec 07, 2023 at 10:07:23PM +0100, Armin Wolf wrote: > 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. > > Compile-tested only. > > Signed-off-by: Armin Wolf <W_Armin@gmx.de> Applied. I dropped the "Compile-tested only" comment and added a note that the patch was tested but the tested did not provide a Tested-by: tag. Thanks, Guenter
On Thu, 7 Dec 2023 22:07:23 +0100 Armin Wolf <W_Armin@gmx.de> wrote: Just forgot. Did both, works just fine. Is it okay that way? This is my first time. Tested-by: Wilken Gottwalt <wilken.gottwalt@posteo.net> Reviewed-by: Wilken Gottwalt <wilken.gottwalt@posteo.net> > 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. > > Compile-tested only. > > Signed-off-by: Armin Wolf <W_Armin@gmx.de> > --- > drivers/hwmon/corsair-psu.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/drivers/hwmon/corsair-psu.c b/drivers/hwmon/corsair-psu.c > index 904890598c11..2c7c92272fe3 100644 > --- a/drivers/hwmon/corsair-psu.c > +++ b/drivers/hwmon/corsair-psu.c > @@ -899,7 +899,23 @@ static struct hid_driver corsairpsu_driver = { > .reset_resume = corsairpsu_resume, > #endif > }; > -module_hid_driver(corsairpsu_driver); > + > +static int __init corsair_init(void) > +{ > + return hid_register_driver(&corsairpsu_driver); > +} > + > +static void __exit corsair_exit(void) > +{ > + hid_unregister_driver(&corsairpsu_driver); > +} > + > +/* > + * With module_init() the driver would load before the HID bus when > + * built-in, so use late_initcall() instead. > + */ > +late_initcall(corsair_init); > +module_exit(corsair_exit); > > MODULE_LICENSE("GPL"); > MODULE_AUTHOR("Wilken Gottwalt <wilken.gottwalt@posteo.net>"); > -- > 2.39.2 >
On 12/8/23 10:44, Wilken Gottwalt wrote: > On Thu, 7 Dec 2023 22:07:23 +0100 > Armin Wolf <W_Armin@gmx.de> wrote: > > Just forgot. Did both, works just fine. Is it okay that way? This is my first > time. > > Tested-by: Wilken Gottwalt <wilken.gottwalt@posteo.net> > Reviewed-by: Wilken Gottwalt <wilken.gottwalt@posteo.net> > Yes, it is perfect, just a bit late. I sent the pull request pretty much in parallel (I didn't want to wait to make sure the patch makes it into v6.7-rc5). Thanks, Guenter
diff --git a/drivers/hwmon/corsair-psu.c b/drivers/hwmon/corsair-psu.c index 904890598c11..2c7c92272fe3 100644 --- a/drivers/hwmon/corsair-psu.c +++ b/drivers/hwmon/corsair-psu.c @@ -899,7 +899,23 @@ static struct hid_driver corsairpsu_driver = { .reset_resume = corsairpsu_resume, #endif }; -module_hid_driver(corsairpsu_driver); + +static int __init corsair_init(void) +{ + return hid_register_driver(&corsairpsu_driver); +} + +static void __exit corsair_exit(void) +{ + hid_unregister_driver(&corsairpsu_driver); +} + +/* + * With module_init() the driver would load before the HID bus when + * built-in, so use late_initcall() instead. + */ +late_initcall(corsair_init); +module_exit(corsair_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Wilken Gottwalt <wilken.gottwalt@posteo.net>");