aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/gameport
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2007-04-10 00:40:48 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-04-27 13:57:30 -0400
commit79580057de60867f535b7e7ec17c85709853d6bf (patch)
tree8030db5da8fa478e452d02dff7f7ff9500328f98 /drivers/input/gameport
parent70f256fda1649fbb3deea37e86342f6139a0a82c (diff)
Input: gameport - do not touch bus's rwsem
The subsystem rwsem is not used by the driver core at all, so there is no point in trying to access it. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/input/gameport')
-rw-r--r--drivers/input/gameport/gameport.c39
1 files changed, 13 insertions, 26 deletions
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index a00fe470a829..bd686a2a517d 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -190,16 +190,14 @@ static void gameport_run_poll_handler(unsigned long d)
190 * Basic gameport -> driver core mappings 190 * Basic gameport -> driver core mappings
191 */ 191 */
192 192
193static void gameport_bind_driver(struct gameport *gameport, struct gameport_driver *drv) 193static int gameport_bind_driver(struct gameport *gameport, struct gameport_driver *drv)
194{ 194{
195 int error; 195 int error;
196 196
197 down_write(&gameport_bus.subsys.rwsem);
198
199 gameport->dev.driver = &drv->driver; 197 gameport->dev.driver = &drv->driver;
200 if (drv->connect(gameport, drv)) { 198 if (drv->connect(gameport, drv)) {
201 gameport->dev.driver = NULL; 199 gameport->dev.driver = NULL;
202 goto out; 200 return -ENODEV;
203 } 201 }
204 202
205 error = device_bind_driver(&gameport->dev); 203 error = device_bind_driver(&gameport->dev);
@@ -211,31 +209,21 @@ static void gameport_bind_driver(struct gameport *gameport, struct gameport_driv
211 drv->description, error); 209 drv->description, error);
212 drv->disconnect(gameport); 210 drv->disconnect(gameport);
213 gameport->dev.driver = NULL; 211 gameport->dev.driver = NULL;
214 goto out; 212 return error;
215 } 213 }
216 214
217 out: 215 return 0;
218 up_write(&gameport_bus.subsys.rwsem);
219}
220
221static 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);
226} 216}
227 217
228static void gameport_find_driver(struct gameport *gameport) 218static void gameport_find_driver(struct gameport *gameport)
229{ 219{
230 int error; 220 int error;
231 221
232 down_write(&gameport_bus.subsys.rwsem);
233 error = device_attach(&gameport->dev); 222 error = device_attach(&gameport->dev);
234 if (error < 0) 223 if (error < 0)
235 printk(KERN_WARNING 224 printk(KERN_WARNING
236 "gameport: device_attach() failed for %s (%s), error: %d\n", 225 "gameport: device_attach() failed for %s (%s), error: %d\n",
237 gameport->phys, gameport->name, error); 226 gameport->phys, gameport->name, error);
238 up_write(&gameport_bus.subsys.rwsem);
239} 227}
240 228
241 229
@@ -483,13 +471,12 @@ static ssize_t gameport_rebind_driver(struct device *dev, struct device_attribut
483{ 471{
484 struct gameport *gameport = to_gameport_port(dev); 472 struct gameport *gameport = to_gameport_port(dev);
485 struct device_driver *drv; 473 struct device_driver *drv;
486 int retval; 474 int error;
487 475
488 retval = mutex_lock_interruptible(&gameport_mutex); 476 error = mutex_lock_interruptible(&gameport_mutex);
489 if (retval) 477 if (error)
490 return retval; 478 return error;
491 479
492 retval = count;
493 if (!strncmp(buf, "none", count)) { 480 if (!strncmp(buf, "none", count)) {
494 gameport_disconnect_port(gameport); 481 gameport_disconnect_port(gameport);
495 } else if (!strncmp(buf, "reconnect", count)) { 482 } else if (!strncmp(buf, "reconnect", count)) {
@@ -499,15 +486,15 @@ static ssize_t gameport_rebind_driver(struct device *dev, struct device_attribut
499 gameport_find_driver(gameport); 486 gameport_find_driver(gameport);
500 } else if ((drv = driver_find(buf, &gameport_bus)) != NULL) { 487 } else if ((drv = driver_find(buf, &gameport_bus)) != NULL) {
501 gameport_disconnect_port(gameport); 488 gameport_disconnect_port(gameport);
502 gameport_bind_driver(gameport, to_gameport_driver(drv)); 489 error = gameport_bind_driver(gameport, to_gameport_driver(drv));
503 put_driver(drv); 490 put_driver(drv);
504 } else { 491 } else {
505 retval = -EINVAL; 492 error = -EINVAL;
506 } 493 }
507 494
508 mutex_unlock(&gameport_mutex); 495 mutex_unlock(&gameport_mutex);
509 496
510 return retval; 497 return error ? error : count;
511} 498}
512 499
513static struct device_attribute gameport_device_attrs[] = { 500static struct device_attribute gameport_device_attrs[] = {
@@ -655,7 +642,7 @@ static void gameport_disconnect_port(struct gameport *gameport)
655 do { 642 do {
656 parent = s->parent; 643 parent = s->parent;
657 644
658 gameport_release_driver(s); 645 device_release_driver(&s->dev);
659 gameport_destroy_port(s); 646 gameport_destroy_port(s);
660 } while ((s = parent) != gameport); 647 } while ((s = parent) != gameport);
661 } 648 }
@@ -663,7 +650,7 @@ static void gameport_disconnect_port(struct gameport *gameport)
663 /* 650 /*
664 * Ok, no children left, now disconnect this port 651 * Ok, no children left, now disconnect this port
665 */ 652 */
666 gameport_release_driver(gameport); 653 device_release_driver(&gameport->dev);
667} 654}
668 655
669void gameport_rescan(struct gameport *gameport) 656void gameport_rescan(struct gameport *gameport)