[PATCH v2 09/19] Input: serio - use the compatibility driver attachment API

From: Leon Romanovsky

Date: Mon Nov 09 2026 - 02:41:04 EST


From: Leon Romanovsky <leonro@xxxxxxxxxx>

Manual serio binding invokes connect and publishes the binding under its
own subsystem serialization. Driver core needs an entry point before
connect to enforce device trust admission.

Use device_driver_attach_full() after the port ID check. Preserve the
existing locking and let the helper handle probe and binding cleanup.

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..b54072769ab68 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_full(&drv->driver, &serio->dev);
}

static void serio_find_driver(struct serio *serio)

--
2.56.0