@@ -190,16 +190,14 @@ static void gameport_run_poll_handler(unsigned long d)
190190 * Basic gameport -> driver core mappings
191191 */
192192
193- static void gameport_bind_driver (struct gameport * gameport , struct gameport_driver * drv )
193+ static int gameport_bind_driver (struct gameport * gameport , struct gameport_driver * drv )
194194{
195195 int error ;
196196
197- down_write (& gameport_bus .subsys .rwsem );
198-
199197 gameport -> dev .driver = & drv -> driver ;
200198 if (drv -> connect (gameport , drv )) {
201199 gameport -> dev .driver = NULL ;
202- goto out ;
200+ return - ENODEV ;
203201 }
204202
205203 error = device_bind_driver (& gameport -> dev );
@@ -211,31 +209,21 @@ static void gameport_bind_driver(struct gameport *gameport, struct gameport_driv
211209 drv -> description , error );
212210 drv -> disconnect (gameport );
213211 gameport -> dev .driver = NULL ;
214- goto out ;
212+ return error ;
215213 }
216214
217- out :
218- up_write (& gameport_bus .subsys .rwsem );
219- }
220-
221- static void gameport_release_driver (struct gameport * gameport )
222- {
223- down_write (& gameport_bus .subsys .rwsem );
224- device_release_driver (& gameport -> dev );
225- up_write (& gameport_bus .subsys .rwsem );
215+ return 0 ;
226216}
227217
228218static void gameport_find_driver (struct gameport * gameport )
229219{
230220 int error ;
231221
232- down_write (& gameport_bus .subsys .rwsem );
233222 error = device_attach (& gameport -> dev );
234223 if (error < 0 )
235224 printk (KERN_WARNING
236225 "gameport: device_attach() failed for %s (%s), error: %d\n" ,
237226 gameport -> phys , gameport -> name , error );
238- up_write (& gameport_bus .subsys .rwsem );
239227}
240228
241229
@@ -483,13 +471,12 @@ static ssize_t gameport_rebind_driver(struct device *dev, struct device_attribut
483471{
484472 struct gameport * gameport = to_gameport_port (dev );
485473 struct device_driver * drv ;
486- int retval ;
474+ int error ;
487475
488- retval = mutex_lock_interruptible (& gameport_mutex );
489- if (retval )
490- return retval ;
476+ error = mutex_lock_interruptible (& gameport_mutex );
477+ if (error )
478+ return error ;
491479
492- retval = count ;
493480 if (!strncmp (buf , "none" , count )) {
494481 gameport_disconnect_port (gameport );
495482 } else if (!strncmp (buf , "reconnect" , count )) {
@@ -499,15 +486,15 @@ static ssize_t gameport_rebind_driver(struct device *dev, struct device_attribut
499486 gameport_find_driver (gameport );
500487 } else if ((drv = driver_find (buf , & gameport_bus )) != NULL ) {
501488 gameport_disconnect_port (gameport );
502- gameport_bind_driver (gameport , to_gameport_driver (drv ));
489+ error = gameport_bind_driver (gameport , to_gameport_driver (drv ));
503490 put_driver (drv );
504491 } else {
505- retval = - EINVAL ;
492+ error = - EINVAL ;
506493 }
507494
508495 mutex_unlock (& gameport_mutex );
509496
510- return retval ;
497+ return error ? error : count ;
511498}
512499
513500static struct device_attribute gameport_device_attrs [] = {
@@ -655,15 +642,15 @@ static void gameport_disconnect_port(struct gameport *gameport)
655642 do {
656643 parent = s -> parent ;
657644
658- gameport_release_driver ( s );
645+ device_release_driver ( & s -> dev );
659646 gameport_destroy_port (s );
660647 } while ((s = parent ) != gameport );
661648 }
662649
663650 /*
664651 * Ok, no children left, now disconnect this port
665652 */
666- gameport_release_driver ( gameport );
653+ device_release_driver ( & gameport -> dev );
667654}
668655
669656void gameport_rescan (struct gameport * gameport )
0 commit comments