Article View: linux.kernel.netdev
Article #26331[PATCH v5 18/33] Input: serio - use the compatibility driver attachment API
From: Leon Romanovsky
Date: Thu, 03 Dec 2026 12:03
Date: Thu, 03 Dec 2026 12:03
72 lines
10479 bytes
10479 bytes
From: Leon Romanovsky <leonro@nvidia.com>
Manual serio binding holds serio_mutex, but generic sysfs probing does
not take that mutex. The two paths can race while updating driver state
or cleaning up a failed probe.
Use device_driver_attach_unrestricted() after the port ID check to
centralize binding and cleanup. Acquire the device lock with
device_trylock() to exclude generic probing, returning -EBUSY instead of
waiting while holding serio_mutex. Map legacy -1 connect failures to
-ENODEV in the probe callback so they are not reported as -EPERM, while
preserving errors returned by the attachment helper.
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/input/serio/serio.c | 29 ++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 54dd26249b02..f239217d7de4 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -83,26 +83,15 @@ static int serio_bind_driver(struct serio *serio, struct serio_driver *drv)
{
int error;
- if (serio_match_port(drv->id_table, serio)) {
+ if (!serio_match_port(drv->id_table, serio))
+ return 0;
- serio->dev.driver = &drv->driver;
- if (serio_connect_driver(serio, drv)) {
- serio->dev.driver = NULL;
- return -ENODEV;
- }
+ if (!device_trylock(&serio->dev))
+ return -EBUSY;
- error = device_bind_driver(&serio->dev);
- if (error) {
- dev_warn(&serio->dev,
- "device_bind_driver() failed for %s (%s) and %s, error: %d\n",
- serio->phys, serio->name,
- drv->description, error);
- serio_disconnect_driver(serio);
- serio->dev.driver = NULL;
- return error;
- }
- }
- return 0;
+ error = device_driver_attach_unrestricted(&drv->driver, &serio->dev);
+ device_unlock(&serio->dev);
+ return error;
}
static void serio_find_driver(struct serio *serio)
@@ -744,8 +733,10 @@ static int serio_driver_probe(struct device *dev)
{
struct serio *serio = to_serio_port(dev);
struct serio_driver *drv = to_serio_driver(dev->driver);
+ int error;
- return serio_connect_driver(serio, drv);
+ error = serio_connect_driver(serio, drv);
+ return error == -1 ? -ENODEV : error;
}
static void serio_driver_remove(struct device *dev)
--
2.56.1
Technical Details
Message-ID:
<20261203-device-trust-core-v5-18-485cc6eddd46@nvidia.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376553-linux-kernel-netdev=dewy.ruReferences:
<20261203-device-trust-core-v5-0-485cc6eddd46@nvidia.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376553-linux-kernel-netdev=dewy.ru From: leon@kernel.org (Leon Romanovsky) Newsgroups: linux.kernel.netdev Subject: [PATCH v5 18/33] Input: serio - use the compatibility driver attachment API Date: Thu, 3 Dec 2026 14:03:40 +0200 Organization: Usenet Network Message-ID: <20261203-device-trust-core-v5-18-485cc6eddd46@nvidia.com> References: <20261203-device-trust-core-v5-0-485cc6eddd46@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2480974"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:GSaoAf2HePv/bmWri1mr3SP9d90= sha256:OFuHU7KsMH1KMG3ssseeobHk95th0q2EteGDbiQ1hhk= sha1:hmDJqk8gQlx02NRNhpe665/ER4s= sha256:4B99VKkqlwwYeUvXsdkPHnlnhw9Fu4zHwMPC4FpysRo= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 04C71117912; Thu, 3 Dec 2026 15:07:39 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.64 X-Spam-Status: No, score=-2.64 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mYUN_YHvtSjp; Thu, 3 Dec 2026 15:07:37 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-376553-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id F0CF4117904; Thu, 3 Dec 2026 15:07:28 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 8D64C603BCD; Thu, 3 Dec 2026 12:07:28 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796299505; b=yqaHG5sXrBD6CDI/LZDxETExzh9g4KxcPM1JHOiKBNxlz/93m1juYpK9TytHlKCq2HAN kR41yIMbxljwKj3HAVikKm9NmVgbUpdcOqub2lwlA6HfOsXJgfTt0GPmmXBLHg39090Hv KsuZ+w5uC3xBQNvuKP4gh48fAJ4E4s72L0BvxEMSmLZId9q/9nzCMY/SITajf2pyj3UVL SgJqsE3Ymladrk/JkQCD7fv/XxZa+LjpVkETmr5aHmqz+tYHEBG6Xn87Obcd6qCsfOCk5 mXKu6HaopWYL5st4eGmPpyKhl5UevFkCtag8H0jZvzFvcAZoPR5nNvA4jNJKEFDW+ww== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796299505; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Type:X-Mailer: Content-Transfer-Encoding; bh=nC+ulJqMvilFgNHO2tTVhKAB5qSzbF3Geobxjj15X10=; b=fd6CP4ydX8XZeaWoJ9C0wdpCBO+MjKZtYC1qtd89IDr1IfW74VN+sgauN15KiYMBsMaW MUgNXVrlsDeGH/K8S3GYynaGhMaQzjHX0++YyTsnRZPEQZ8PtUGU1IYqqMQzKIfJry6AN KFTDgvOfKm8FBaJOuBqoGwbFFoLaWrh3ZqZysmdvcUfVVpl1M3bTvNFnFZOpF3GJ4sVZ6 2tCFILw23qRGA9k+vJzpSEutHQ++yHWmmqY88HJm6wn3w2ULADbOI4HSMl/KUqNirb+rG yuH3/l3GbXoB1J9ytu7//Mo5cgDv7Jf1bk/BwZB+br8ywO6uDc6+c67jov/GzvvfprA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SYgMv+zt; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 72C7A60A6F70; Thu, 3 Dec 2026 12:05:05 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SYgMv+zt X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796299499; b=fycG2f2YXolN05+FdUmAoyTv6zBA6uuaaudow/XQPFPFWf96fzkQdvloOvNf/i4RCQ3Q gU16O/x+3G59O3mtjiqGmnITgDOy3DaK5wgrUKMH7wFVaGnDObieBcgCaJx5QUZ14HF35 fqkykpu+rKUTE6nv1qfwpVLYuXlwCshg5BW2jRD3oDIO4/D5vs52sL1u+IB3jqwk66ypu h7u0Y8UqdRIW2Hh69l9ZXtVP3m55ua8sn+NbNkoQACpW3ecz8Kh2eLy2AHvypqRTpYozK QWrSAF8EQRQYoPJs4C+CWQZ5soPAzQf6E0ZqPl/UX2B40dMlWRGDZw+Mymh+ZMtevqg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796299499; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type:X-Mailer: Content-Transfer-Encoding; bh=nC+ulJqMvilFgNHO2tTVhKAB5qSzbF3Geobxjj15X10=; b=YquwiqJWqU1kjlRNwBHU9WMeVGcL7FqW5ieK9XLtWT9XOYwBoVB26VJWVLmT9xV3Bbww vos5UiRUskiEIhQPKZxVlIlXk9YsUFGO5KL7MBwJUs8kPX0SYlyIRJWqFQ4BiXoDPawqk xfiO5OaSxkM+QG++jEoIT9xN9/7rxEuhl9zpnIzlV+lMbbrdaW3SaxBPUhDyeZKAvNhVD 62YSq9GQtgLi/YASn7YK4IBvBc2rZNJprMhWFceuwOwtxaWNm4sfnziFADiOYNBQvOgjL bubR7aBG09XQ8DHsB4p9oLFD5/iMArXJ2A1JDLrom0kDkWWlt7vlTWJwSPkSPgkdLaw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SYgMv+zt; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DEED606FD01; Thu, 3 Dec 2026 12:04:59 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A73C71F000C1; Thu, 3 Dec 2026 12:04:58 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796299499; bh=nC+ulJqMvilFgNHO2tTVhKAB5qSzbF3Geobxjj15X10=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SYgMv+ztJ4M79S+txnANgasr6bvLzH27F/WhDZ4L1l/yIM16CmsoALBaVTnivyC8i CTjyqsJMCePycgOPvwuBsJRl8YC386+aBUNcYQknnzM0ZECBJE70JeohyhXqoPPGOl khmd6y/rb80k5+HHGk5johmfBTVNIldFAlpapElB1J0YaBCrhXmo7HUGVJJZINRjzR kuobQhAGCCMRaI7bnKpxMXfandaB+o2/MqY8xlgFsdMWIkfWbzcVATGdDQUOrT29Rl eZess017OafykrLCNe6dmVJttZNr0PGXy29jzdkIlnVeHR7K0Ndit+TQzYHWpqGu5m c3RQEWcbxajyQ== X-Cc: linux-kernel@vger.kernel.org, driver-core@lists.linux.dev, linux-input@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-usb@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-acpi@vger.kernel.org, linux-doc@vger.kernel.org, linux-pci@vger.kernel.org, iommu@lists.linux.dev, linux-coco@lists.linux.dev, Alexey Kardashevskiy <aik@amd.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Greg Kroah-Hartman <gregkh@suse.de>, linux-sound@vger.kernel.org, Jason Gunthorpe <jgg@ziepe.ca> X-Mailer: git-send-email 2.56.1 X-In-Reply-To: <20261203-device-trust-core-v5-0-485cc6eddd46@nvidia.com> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-Mailer: b4 0.17-dev-d2b70