aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/joystick/grip_mp.c
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/input/joystick/grip_mp.c
parent52c1f5704d7555a16641429b2e7af5d26d7b119a (diff)
Input: joysticks - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/joystick/grip_mp.c')
-rw-r--r--drivers/input/joystick/grip_mp.c13
1 files changed, 11 insertions, 2 deletions
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 */