diff mbox series

[01/17] Input: gameport - attach manual drivers through the driver core

Message ID 20261105-device-trust-core-v1-1-1e536825b4eb@nvidia.com
State New
Headers show
Series driver core: Authorize device trust before driver binding | expand

Commit Message

Leon Romanovsky Nov. 5, 2026, 11:42 a.m. UTC
From: Leon Romanovsky <leonro@nvidia.com>

Manual gameport binding calls connect before publishing the binding, so
driver-core admission cannot reject a device before functional setup.

Use device_driver_attach() to run the existing bus probe and removal
callbacks under the device lock. This gives manual attachment the same
admission, setup and failure cleanup as automatic probing.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/input/gameport/gameport.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

Comments

sashiko-bot@kernel.org Nov. 6, 2026, 11:43 a.m. UTC | #1
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> Manual gameport binding calls connect before publishing the binding, so
> driver-core admission cannot reject a device before functional setup.
> 
> Use device_driver_attach() to run the existing bus probe and removal
> callbacks under the device lock. This gives manual attachment the same
> admission, setup and failure cleanup as automatic probing.
> 
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>

Sashiko has reviewed this patch and found no issues.
diff mbox series

Patch

diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index 9707b155bc947..c9efec2dc55da 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -214,26 +214,7 @@  static void gameport_run_poll_handler(struct timer_list *t)
 
 static int gameport_bind_driver(struct gameport *gameport, struct gameport_driver *drv)
 {
-	int error;
-
-	gameport->dev.driver = &drv->driver;
-	if (drv->connect(gameport, drv)) {
-		gameport->dev.driver = NULL;
-		return -ENODEV;
-	}
-
-	error = device_bind_driver(&gameport->dev);
-	if (error) {
-		dev_warn(&gameport->dev,
-			 "device_bind_driver() failed for %s (%s) and %s, error: %d\n",
-			gameport->phys, gameport->name,
-			drv->description, error);
-		drv->disconnect(gameport);
-		gameport->dev.driver = NULL;
-		return error;
-	}
-
-	return 0;
+	return device_driver_attach(&drv->driver, &gameport->dev);
 }
 
 static void gameport_find_driver(struct gameport *gameport)