aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2006-11-05 22:40:09 -0500
committerDmitry Torokhov <dtor@insightbb.com>2006-11-05 22:40:09 -0500
commit127278ce2254c61f1346500374d61e33f74a8729 (patch)
treef7460f3f452d3dbe2d7a52dfa23a51dee0d312f3 /drivers
parent52c1f5704d7555a16641429b2e7af5d26d7b119a (diff)
Input: joysticks - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/joystick/adi.c10
-rw-r--r--drivers/input/joystick/amijoy.c6
-rw-r--r--drivers/input/joystick/analog.c10
-rw-r--r--drivers/input/joystick/cobra.c7
-rw-r--r--drivers/input/joystick/gf2k.c4
-rw-r--r--drivers/input/joystick/grip_mp.c13
-rw-r--r--drivers/input/joystick/guillemot.c4
-rw-r--r--drivers/input/joystick/iforce/iforce-main.c17
-rw-r--r--drivers/input/joystick/iforce/iforce-serio.c20
-rw-r--r--drivers/input/joystick/interact.c4
-rw-r--r--drivers/input/joystick/magellan.c14
-rw-r--r--drivers/input/joystick/spaceball.c14
-rw-r--r--drivers/input/joystick/spaceorb.c14
-rw-r--r--drivers/input/joystick/stinger.c14
-rw-r--r--drivers/input/joystick/twidjoy.c14
-rw-r--r--drivers/input/joystick/warrior.c14
16 files changed, 120 insertions, 59 deletions
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index 704bf70f1db7..6279ced8a35b 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -521,11 +521,19 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
521 for (i = 0; i < 2; i++) 521 for (i = 0; i < 2; i++)
522 if (port->adi[i].length > 0) { 522 if (port->adi[i].length > 0) {
523 adi_init_center(port->adi + i); 523 adi_init_center(port->adi + i);
524 input_register_device(port->adi[i].dev); 524 err = input_register_device(port->adi[i].dev);
525 if (err)
526 goto fail3;
525 } 527 }
526 528
527 return 0; 529 return 0;
528 530
531 fail3: while (--i >= 0) {
532 if (port->adi[i].length > 0) {
533 input_unregister_device(port->adi[i].dev);
534 port->adi[i].dev = NULL;
535 }
536 }
529 fail2: for (i = 0; i < 2; i++) 537 fail2: for (i = 0; i < 2; i++)
530 if (port->adi[i].dev) 538 if (port->adi[i].dev)
531 input_free_device(port->adi[i].dev); 539 input_free_device(port->adi[i].dev);
diff --git a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c
index 650acf3a30b7..e608691b5a61 100644
--- a/drivers/input/joystick/amijoy.c
+++ b/drivers/input/joystick/amijoy.c
@@ -147,7 +147,11 @@ static int __init amijoy_init(void)
147 amijoy_dev[i]->absmax[ABS_X + j] = 1; 147 amijoy_dev[i]->absmax[ABS_X + j] = 1;
148 } 148 }
149 149
150 input_register_device(amijoy_dev[i]); 150 err = input_register_device(amijoy_dev[i]);
151 if (err) {
152 input_free_device(amijoy_dev[i]);
153 goto fail;
154 }
151 } 155 }
152 return 0; 156 return 0;
153 157
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
index e9a02db36ecc..7ef68456d7d6 100644
--- a/drivers/input/joystick/analog.c
+++ b/drivers/input/joystick/analog.c
@@ -434,6 +434,7 @@ static int analog_init_device(struct analog_port *port, struct analog *analog, i
434{ 434{
435 struct input_dev *input_dev; 435 struct input_dev *input_dev;
436 int i, j, t, v, w, x, y, z; 436 int i, j, t, v, w, x, y, z;
437 int error;
437 438
438 analog_name(analog); 439 analog_name(analog);
439 snprintf(analog->phys, sizeof(analog->phys), 440 snprintf(analog->phys, sizeof(analog->phys),
@@ -505,7 +506,11 @@ static int analog_init_device(struct analog_port *port, struct analog *analog, i
505 506
506 analog_decode(analog, port->axes, port->initial, port->buttons); 507 analog_decode(analog, port->axes, port->initial, port->buttons);
507 508
508 input_register_device(analog->dev); 509 error = input_register_device(analog->dev);
510 if (error) {
511 input_free_device(analog->dev);
512 return error;
513 }
509 514
510 return 0; 515 return 0;
511} 516}
@@ -668,7 +673,8 @@ static int analog_connect(struct gameport *gameport, struct gameport_driver *drv
668 return 0; 673 return 0;
669 674
670 fail3: while (--i >= 0) 675 fail3: while (--i >= 0)
671 input_unregister_device(port->analog[i].dev); 676 if (port->analog[i].mask)
677 input_unregister_device(port->analog[i].dev);
672 fail2: gameport_close(gameport); 678 fail2: gameport_close(gameport);
673 fail1: gameport_set_drvdata(gameport, NULL); 679 fail1: gameport_set_drvdata(gameport, NULL);
674 kfree(port); 680 kfree(port);
diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c
index d5e42eb88a20..034ec39c251d 100644
--- a/drivers/input/joystick/cobra.c
+++ b/drivers/input/joystick/cobra.c
@@ -223,12 +223,15 @@ static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv)
223 for (j = 0; cobra_btn[j]; j++) 223 for (j = 0; cobra_btn[j]; j++)
224 set_bit(cobra_btn[j], input_dev->keybit); 224 set_bit(cobra_btn[j], input_dev->keybit);
225 225
226 input_register_device(cobra->dev[i]); 226 err = input_register_device(cobra->dev[i]);
227 if (err)
228 goto fail4;
227 } 229 }
228 230
229 return 0; 231 return 0;
230 232
231 fail3: for (i = 0; i < 2; i++) 233 fail4: input_free_device(cobra->dev[i]);
234 fail3: while (--i >= 0)
232 if (cobra->dev[i]) 235 if (cobra->dev[i])
233 input_unregister_device(cobra->dev[i]); 236 input_unregister_device(cobra->dev[i]);
234 fail2: gameport_close(gameport); 237 fail2: gameport_close(gameport);
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c
index e4a699f6ec87..bacbab5d1b6f 100644
--- a/drivers/input/joystick/gf2k.c
+++ b/drivers/input/joystick/gf2k.c
@@ -341,7 +341,9 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
341 input_dev->absflat[gf2k_abs[i]] = (i < 2) ? 24 : 0; 341 input_dev->absflat[gf2k_abs[i]] = (i < 2) ? 24 : 0;
342 } 342 }
343 343
344 input_register_device(gf2k->dev); 344 err = input_register_device(gf2k->dev);
345 if (err)
346 goto fail2;
345 347
346 return 0; 348 return 0;
347 349
diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c
index 62438944a69a..8120a9c40773 100644
--- a/drivers/input/joystick/grip_mp.c
+++ b/drivers/input/joystick/grip_mp.c
@@ -423,7 +423,10 @@ static int get_and_decode_packet(struct grip_mp *grip, int flags)
423 423
424 if (!port->registered) { 424 if (!port->registered) {
425 dbg("New Grip pad in multiport slot %d.\n", slot); 425 dbg("New Grip pad in multiport slot %d.\n", slot);
426 register_slot(slot, grip); 426 if (register_slot(slot, grip)) {
427 port->mode = GRIP_MODE_RESET;
428 port->dirty = 0;
429 }
427 } 430 }
428 return flags; 431 return flags;
429 } 432 }
@@ -585,6 +588,7 @@ static int register_slot(int slot, struct grip_mp *grip)
585 struct grip_port *port = grip->port[slot]; 588 struct grip_port *port = grip->port[slot];
586 struct input_dev *input_dev; 589 struct input_dev *input_dev;
587 int j, t; 590 int j, t;
591 int err;
588 592
589 port->dev = input_dev = input_allocate_device(); 593 port->dev = input_dev = input_allocate_device();
590 if (!input_dev) 594 if (!input_dev)
@@ -610,7 +614,12 @@ static int register_slot(int slot, struct grip_mp *grip)
610 if (t > 0) 614 if (t > 0)
611 set_bit(t, input_dev->keybit); 615 set_bit(t, input_dev->keybit);
612 616
613 input_register_device(port->dev); 617 err = input_register_device(port->dev);
618 if (err) {
619 input_free_device(port->dev);
620 return err;
621 }
622
614 port->registered = 1; 623 port->registered = 1;
615 624
616 if (port->dirty) /* report initial state, if any */ 625 if (port->dirty) /* report initial state, if any */
diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c
index 840ed9b512b2..dbc5d92858b8 100644
--- a/drivers/input/joystick/guillemot.c
+++ b/drivers/input/joystick/guillemot.c
@@ -250,7 +250,9 @@ static int guillemot_connect(struct gameport *gameport, struct gameport_driver *
250 for (i = 0; (t = guillemot->type->btn[i]) >= 0; i++) 250 for (i = 0; (t = guillemot->type->btn[i]) >= 0; i++)
251 set_bit(t, input_dev->keybit); 251 set_bit(t, input_dev->keybit);
252 252
253 input_register_device(guillemot->dev); 253 err = input_register_device(guillemot->dev);
254 if (err)
255 goto fail2;
254 256
255 return 0; 257 return 0;
256 258
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c
index 24c684bc6337..706e0aea793c 100644
--- a/drivers/input/joystick/iforce/iforce-main.c
+++ b/drivers/input/joystick/iforce/iforce-main.c
@@ -325,8 +325,8 @@ int iforce_init_device(struct iforce *iforce)
325 325
326 if (i == 20) { /* 5 seconds */ 326 if (i == 20) { /* 5 seconds */
327 printk(KERN_ERR "iforce-main.c: Timeout waiting for response from device.\n"); 327 printk(KERN_ERR "iforce-main.c: Timeout waiting for response from device.\n");
328 input_free_device(input_dev); 328 error = -ENODEV;
329 return -ENODEV; 329 goto fail;
330 } 330 }
331 331
332/* 332/*
@@ -439,10 +439,8 @@ int iforce_init_device(struct iforce *iforce)
439 set_bit(iforce->type->ff[i], input_dev->ffbit); 439 set_bit(iforce->type->ff[i], input_dev->ffbit);
440 440
441 error = input_ff_create(input_dev, ff_effects); 441 error = input_ff_create(input_dev, ff_effects);
442 if (error) { 442 if (error)
443 input_free_device(input_dev); 443 goto fail;
444 return error;
445 }
446 444
447 ff = input_dev->ff; 445 ff = input_dev->ff;
448 ff->upload = iforce_upload_effect; 446 ff->upload = iforce_upload_effect;
@@ -455,11 +453,16 @@ int iforce_init_device(struct iforce *iforce)
455 * Register input device. 453 * Register input device.
456 */ 454 */
457 455
458 input_register_device(iforce->dev); 456 error = input_register_device(iforce->dev);
457 if (error)
458 goto fail;
459 459
460 printk(KERN_DEBUG "iforce->dev->open = %p\n", iforce->dev->open); 460 printk(KERN_DEBUG "iforce->dev->open = %p\n", iforce->dev->open);
461 461
462 return 0; 462 return 0;
463
464 fail: input_free_device(input_dev);
465 return error;
463} 466}
464 467
465static int __init iforce_init(void) 468static int __init iforce_init(void)
diff --git a/drivers/input/joystick/iforce/iforce-serio.c b/drivers/input/joystick/iforce/iforce-serio.c
index ca08f45c2040..ec4be535f483 100644
--- a/drivers/input/joystick/iforce/iforce-serio.c
+++ b/drivers/input/joystick/iforce/iforce-serio.c
@@ -141,21 +141,19 @@ static int iforce_serio_connect(struct serio *serio, struct serio_driver *drv)
141 serio_set_drvdata(serio, iforce); 141 serio_set_drvdata(serio, iforce);
142 142
143 err = serio_open(serio, drv); 143 err = serio_open(serio, drv);
144 if (err) { 144 if (err)
145 serio_set_drvdata(serio, NULL); 145 goto fail1;
146 kfree(iforce);
147 return err;
148 }
149 146
150 err = iforce_init_device(iforce); 147 err = iforce_init_device(iforce);
151 if (err) { 148 if (err)
152 serio_close(serio); 149 goto fail2;
153 serio_set_drvdata(serio, NULL);
154 kfree(iforce);
155 return -ENODEV;
156 }
157 150
158 return 0; 151 return 0;
152
153 fail2: serio_close(serio);
154 fail1: serio_set_drvdata(serio, NULL);
155 kfree(iforce);
156 return err;
159} 157}
160 158
161static void iforce_serio_disconnect(struct serio *serio) 159static void iforce_serio_disconnect(struct serio *serio)
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c
index bbfeb9c59b87..fec8b3d0967d 100644
--- a/drivers/input/joystick/interact.c
+++ b/drivers/input/joystick/interact.c
@@ -283,7 +283,9 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d
283 for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++) 283 for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++)
284 set_bit(t, input_dev->keybit); 284 set_bit(t, input_dev->keybit);
285 285
286 input_register_device(interact->dev); 286 err = input_register_device(interact->dev);
287 if (err)
288 goto fail2;
287 289
288 return 0; 290 return 0;
289 291
diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
index e3d19444ba2e..d512b0a0282e 100644
--- a/drivers/input/joystick/magellan.c
+++ b/drivers/input/joystick/magellan.c
@@ -157,7 +157,7 @@ static int magellan_connect(struct serio *serio, struct serio_driver *drv)
157 magellan = kzalloc(sizeof(struct magellan), GFP_KERNEL); 157 magellan = kzalloc(sizeof(struct magellan), GFP_KERNEL);
158 input_dev = input_allocate_device(); 158 input_dev = input_allocate_device();
159 if (!magellan || !input_dev) 159 if (!magellan || !input_dev)
160 goto fail; 160 goto fail1;
161 161
162 magellan->dev = input_dev; 162 magellan->dev = input_dev;
163 snprintf(magellan->phys, sizeof(magellan->phys), "%s/input0", serio->phys); 163 snprintf(magellan->phys, sizeof(magellan->phys), "%s/input0", serio->phys);
@@ -183,13 +183,17 @@ static int magellan_connect(struct serio *serio, struct serio_driver *drv)
183 183
184 err = serio_open(serio, drv); 184 err = serio_open(serio, drv);
185 if (err) 185 if (err)
186 goto fail; 186 goto fail2;
187
188 err = input_register_device(magellan->dev);
189 if (err)
190 goto fail3;
187 191
188 input_register_device(magellan->dev);
189 return 0; 192 return 0;
190 193
191 fail: serio_set_drvdata(serio, NULL); 194 fail3: serio_close(serio);
192 input_free_device(input_dev); 195 fail2: serio_set_drvdata(serio, NULL);
196 fail1: input_free_device(input_dev);
193 kfree(magellan); 197 kfree(magellan);
194 return err; 198 return err;
195} 199}
diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c
index 2a9808cf826f..9b3597343c1c 100644
--- a/drivers/input/joystick/spaceball.c
+++ b/drivers/input/joystick/spaceball.c
@@ -215,7 +215,7 @@ static int spaceball_connect(struct serio *serio, struct serio_driver *drv)
215 spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL); 215 spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL);
216 input_dev = input_allocate_device(); 216 input_dev = input_allocate_device();
217 if (!spaceball || !input_dev) 217 if (!spaceball || !input_dev)
218 goto fail; 218 goto fail1;
219 219
220 spaceball->dev = input_dev; 220 spaceball->dev = input_dev;
221 snprintf(spaceball->phys, sizeof(spaceball->phys), "%s/input0", serio->phys); 221 snprintf(spaceball->phys, sizeof(spaceball->phys), "%s/input0", serio->phys);
@@ -252,13 +252,17 @@ static int spaceball_connect(struct serio *serio, struct serio_driver *drv)
252 252
253 err = serio_open(serio, drv); 253 err = serio_open(serio, drv);
254 if (err) 254 if (err)
255 goto fail; 255 goto fail2;
256
257 err = input_register_device(spaceball->dev);
258 if (err)
259 goto fail3;
256 260
257 input_register_device(spaceball->dev);
258 return 0; 261 return 0;
259 262
260 fail: serio_set_drvdata(serio, NULL); 263 fail3: serio_close(serio);
261 input_free_device(input_dev); 264 fail2: serio_set_drvdata(serio, NULL);
265 fail1: input_free_device(input_dev);
262 kfree(spaceball); 266 kfree(spaceball);
263 return err; 267 return err;
264} 268}
diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c
index c4db0247c5fb..ea9d51e70a12 100644
--- a/drivers/input/joystick/spaceorb.c
+++ b/drivers/input/joystick/spaceorb.c
@@ -172,7 +172,7 @@ static int spaceorb_connect(struct serio *serio, struct serio_driver *drv)
172 spaceorb = kzalloc(sizeof(struct spaceorb), GFP_KERNEL); 172 spaceorb = kzalloc(sizeof(struct spaceorb), GFP_KERNEL);
173 input_dev = input_allocate_device(); 173 input_dev = input_allocate_device();
174 if (!spaceorb || !input_dev) 174 if (!spaceorb || !input_dev)
175 goto fail; 175 goto fail1;
176 176
177 spaceorb->dev = input_dev; 177 spaceorb->dev = input_dev;
178 snprintf(spaceorb->phys, sizeof(spaceorb->phys), "%s/input0", serio->phys); 178 snprintf(spaceorb->phys, sizeof(spaceorb->phys), "%s/input0", serio->phys);
@@ -198,13 +198,17 @@ static int spaceorb_connect(struct serio *serio, struct serio_driver *drv)
198 198
199 err = serio_open(serio, drv); 199 err = serio_open(serio, drv);
200 if (err) 200 if (err)
201 goto fail; 201 goto fail2;
202
203 err = input_register_device(spaceorb->dev);
204 if (err)
205 goto fail3;
202 206
203 input_register_device(spaceorb->dev);
204 return 0; 207 return 0;
205 208
206 fail: serio_set_drvdata(serio, NULL); 209 fail3: serio_close(serio);
207 input_free_device(input_dev); 210 fail2: serio_set_drvdata(serio, NULL);
211 fail1: input_free_device(input_dev);
208 kfree(spaceorb); 212 kfree(spaceorb);
209 return err; 213 return err;
210} 214}
diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c
index 1ffb03223311..b51a4a4c7f60 100644
--- a/drivers/input/joystick/stinger.c
+++ b/drivers/input/joystick/stinger.c
@@ -143,7 +143,7 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv)
143 stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL); 143 stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL);
144 input_dev = input_allocate_device(); 144 input_dev = input_allocate_device();
145 if (!stinger || !input_dev) 145 if (!stinger || !input_dev)
146 goto fail; 146 goto fail1;
147 147
148 stinger->dev = input_dev; 148 stinger->dev = input_dev;
149 snprintf(stinger->phys, sizeof(stinger->phys), "%s/serio0", serio->phys); 149 snprintf(stinger->phys, sizeof(stinger->phys), "%s/serio0", serio->phys);
@@ -168,13 +168,17 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv)
168 168
169 err = serio_open(serio, drv); 169 err = serio_open(serio, drv);
170 if (err) 170 if (err)
171 goto fail; 171 goto fail2;
172
173 err = input_register_device(stinger->dev);
174 if (err)
175 goto fail3;
172 176
173 input_register_device(stinger->dev);
174 return 0; 177 return 0;
175 178
176 fail: serio_set_drvdata(serio, NULL); 179 fail3: serio_close(serio);
177 input_free_device(input_dev); 180 fail2: serio_set_drvdata(serio, NULL);
181 fail1: input_free_device(input_dev);
178 kfree(stinger); 182 kfree(stinger);
179 return err; 183 return err;
180} 184}
diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c
index 49085df2d631..3c1c83e8609a 100644
--- a/drivers/input/joystick/twidjoy.c
+++ b/drivers/input/joystick/twidjoy.c
@@ -194,7 +194,7 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
194 twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL); 194 twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL);
195 input_dev = input_allocate_device(); 195 input_dev = input_allocate_device();
196 if (!twidjoy || !input_dev) 196 if (!twidjoy || !input_dev)
197 goto fail; 197 goto fail1;
198 198
199 twidjoy->dev = input_dev; 199 twidjoy->dev = input_dev;
200 snprintf(twidjoy->phys, sizeof(twidjoy->phys), "%s/input0", serio->phys); 200 snprintf(twidjoy->phys, sizeof(twidjoy->phys), "%s/input0", serio->phys);
@@ -221,13 +221,17 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
221 221
222 err = serio_open(serio, drv); 222 err = serio_open(serio, drv);
223 if (err) 223 if (err)
224 goto fail; 224 goto fail2;
225
226 err = input_register_device(twidjoy->dev);
227 if (err)
228 goto fail3;
225 229
226 input_register_device(twidjoy->dev);
227 return 0; 230 return 0;
228 231
229 fail: serio_set_drvdata(serio, NULL); 232 fail3: serio_close(serio);
230 input_free_device(input_dev); 233 fail2: serio_set_drvdata(serio, NULL);
234 fail1: input_free_device(input_dev);
231 kfree(twidjoy); 235 kfree(twidjoy);
232 return err; 236 return err;
233} 237}
diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c
index 35edea1ab955..1e4828b9a1ab 100644
--- a/drivers/input/joystick/warrior.c
+++ b/drivers/input/joystick/warrior.c
@@ -149,7 +149,7 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv)
149 warrior = kzalloc(sizeof(struct warrior), GFP_KERNEL); 149 warrior = kzalloc(sizeof(struct warrior), GFP_KERNEL);
150 input_dev = input_allocate_device(); 150 input_dev = input_allocate_device();
151 if (!warrior || !input_dev) 151 if (!warrior || !input_dev)
152 goto fail; 152 goto fail1;
153 153
154 warrior->dev = input_dev; 154 warrior->dev = input_dev;
155 snprintf(warrior->phys, sizeof(warrior->phys), "%s/input0", serio->phys); 155 snprintf(warrior->phys, sizeof(warrior->phys), "%s/input0", serio->phys);
@@ -176,13 +176,17 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv)
176 176
177 err = serio_open(serio, drv); 177 err = serio_open(serio, drv);
178 if (err) 178 if (err)
179 goto fail; 179 goto fail2;
180
181 err = input_register_device(warrior->dev);
182 if (err)
183 goto fail3;
180 184
181 input_register_device(warrior->dev);
182 return 0; 185 return 0;
183 186
184 fail: serio_set_drvdata(serio, NULL); 187 fail3: serio_close(serio);
185 input_free_device(input_dev); 188 fail2: serio_set_drvdata(serio, NULL);
189 fail1: input_free_device(input_dev);
186 kfree(warrior); 190 kfree(warrior);
187 return err; 191 return err;
188} 192}