[PATCH 02/17] Input: serio - attach manual drivers through the driver core

From: Leon Romanovsky

Date: Thu Nov 05 2026 - 06:46:45 EST


From: Leon Romanovsky <leonro@xxxxxxxxxx>

Manual serio binding connects a driver before driver core can admit the
device. A rejected binding therefore arrives after functional setup.

Keep the port ID check and use device_driver_attach() for the existing bus
probe path. Driver core then serializes admission and handles probe failure
before publishing the binding.

Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
---
drivers/input/serio/serio.c | 24 +++---------------------
1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 54dd26249b027..604440244c1ca 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -81,28 +81,10 @@ static int serio_match_port(const struct serio_device_id *ids, struct serio *ser

static int serio_bind_driver(struct serio *serio, struct serio_driver *drv)
{
- int error;
-
- if (serio_match_port(drv->id_table, serio)) {
-
- serio->dev.driver = &drv->driver;
- if (serio_connect_driver(serio, drv)) {
- serio->dev.driver = NULL;
- return -ENODEV;
- }
+ if (!serio_match_port(drv->id_table, serio))
+ return 0;

- 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;
+ return device_driver_attach(&drv->driver, &serio->dev);
}

static void serio_find_driver(struct serio *serio)

--
2.56.0