From: Leon Romanovsky 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 --- drivers/input/gameport/gameport.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) 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) -- 2.56.0