aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/gameport/gameport.c39
-rw-r--r--drivers/input/serio/serio.c41
2 files changed, 28 insertions, 52 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)
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index a15e531ec755..5895202b972c 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -115,18 +115,18 @@ static int serio_match_port(const struct serio_device_id *ids, struct serio *ser
115 * Basic serio -> driver core mappings 115 * Basic serio -> driver core mappings
116 */ 116 */
117 117
118static void serio_bind_driver(struct serio *serio, struct serio_driver *drv) 118static int serio_bind_driver(struct serio *serio, struct serio_driver *drv)
119{ 119{
120 int error; 120 int error;
121 121
122 down_write(&serio_bus.subsys.rwsem);
123
124 if (serio_match_port(drv->id_table, serio)) { 122 if (serio_match_port(drv->id_table, serio)) {
123
125 serio->dev.driver = &drv->driver; 124 serio->dev.driver = &drv->driver;
126 if (serio_connect_driver(serio, drv)) { 125 if (serio_connect_driver(serio, drv)) {
127 serio->dev.driver = NULL; 126 serio->dev.driver = NULL;
128 goto out; 127 return -ENODEV;
129 } 128 }
129
130 error = device_bind_driver(&serio->dev); 130 error = device_bind_driver(&serio->dev);
131 if (error) { 131 if (error) {
132 printk(KERN_WARNING 132 printk(KERN_WARNING
@@ -136,31 +136,21 @@ static void serio_bind_driver(struct serio *serio, struct serio_driver *drv)
136 drv->description, error); 136 drv->description, error);
137 serio_disconnect_driver(serio); 137 serio_disconnect_driver(serio);
138 serio->dev.driver = NULL; 138 serio->dev.driver = NULL;
139 goto out; 139 return error;
140 } 140 }
141 } 141 }
142 out: 142 return 0;
143 up_write(&serio_bus.subsys.rwsem);
144}
145
146static void serio_release_driver(struct serio *serio)
147{
148 down_write(&serio_bus.subsys.rwsem);
149 device_release_driver(&serio->dev);
150 up_write(&serio_bus.subsys.rwsem);
151} 143}
152 144
153static void serio_find_driver(struct serio *serio) 145static void serio_find_driver(struct serio *serio)
154{ 146{
155 int error; 147 int error;
156 148
157 down_write(&serio_bus.subsys.rwsem);
158 error = device_attach(&serio->dev); 149 error = device_attach(&serio->dev);
159 if (error < 0) 150 if (error < 0)
160 printk(KERN_WARNING 151 printk(KERN_WARNING
161 "serio: device_attach() failed for %s (%s), error: %d\n", 152 "serio: device_attach() failed for %s (%s), error: %d\n",
162 serio->phys, serio->name, error); 153 serio->phys, serio->name, error);
163 up_write(&serio_bus.subsys.rwsem);
164} 154}
165 155
166 156
@@ -470,13 +460,12 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *
470{ 460{
471 struct serio *serio = to_serio_port(dev); 461 struct serio *serio = to_serio_port(dev);
472 struct device_driver *drv; 462 struct device_driver *drv;
473 int retval; 463 int error;
474 464
475 retval = mutex_lock_interruptible(&serio_mutex); 465 error = mutex_lock_interruptible(&serio_mutex);
476 if (retval) 466 if (error)
477 return retval; 467 return error;
478 468
479 retval = count;
480 if (!strncmp(buf, "none", count)) { 469 if (!strncmp(buf, "none", count)) {
481 serio_disconnect_port(serio); 470 serio_disconnect_port(serio);
482 } else if (!strncmp(buf, "reconnect", count)) { 471 } else if (!strncmp(buf, "reconnect", count)) {
@@ -486,15 +475,15 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *
486 serio_find_driver(serio); 475 serio_find_driver(serio);
487 } else if ((drv = driver_find(buf, &serio_bus)) != NULL) { 476 } else if ((drv = driver_find(buf, &serio_bus)) != NULL) {
488 serio_disconnect_port(serio); 477 serio_disconnect_port(serio);
489 serio_bind_driver(serio, to_serio_driver(drv)); 478 error = serio_bind_driver(serio, to_serio_driver(drv));
490 put_driver(drv); 479 put_driver(drv);
491 } else { 480 } else {
492 retval = -EINVAL; 481 error = -EINVAL;
493 } 482 }
494 483
495 mutex_unlock(&serio_mutex); 484 mutex_unlock(&serio_mutex);
496 485
497 return retval; 486 return error ? error : count;
498} 487}
499 488
500static ssize_t serio_show_bind_mode(struct device *dev, struct device_attribute *attr, char *buf) 489static ssize_t serio_show_bind_mode(struct device *dev, struct device_attribute *attr, char *buf)
@@ -665,7 +654,7 @@ static void serio_disconnect_port(struct serio *serio)
665 do { 654 do {
666 parent = s->parent; 655 parent = s->parent;
667 656
668 serio_release_driver(s); 657 device_release_driver(&s->dev);
669 serio_destroy_port(s); 658 serio_destroy_port(s);
670 } while ((s = parent) != serio); 659 } while ((s = parent) != serio);
671 } 660 }
@@ -673,7 +662,7 @@ static void serio_disconnect_port(struct serio *serio)
673 /* 662 /*
674 * Ok, no children left, now disconnect this port 663 * Ok, no children left, now disconnect this port
675 */ 664 */
676 serio_release_driver(serio); 665 device_release_driver(&serio->dev);
677} 666}
678 667
679void serio_rescan(struct serio *serio) 668void serio_rescan(struct serio *serio)