From 127278ce2254c61f1346500374d61e33f74a8729 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 5 Nov 2006 22:40:09 -0500 Subject: Input: joysticks - handle errors when registering input devices Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/warrior.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'drivers/input/joystick/warrior.c') diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c index 35edea1ab95..1e4828b9a1a 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) warrior = kzalloc(sizeof(struct warrior), GFP_KERNEL); input_dev = input_allocate_device(); if (!warrior || !input_dev) - goto fail; + goto fail1; warrior->dev = input_dev; 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) err = serio_open(serio, drv); if (err) - goto fail; + goto fail2; + + err = input_register_device(warrior->dev); + if (err) + goto fail3; - input_register_device(warrior->dev); return 0; - fail: serio_set_drvdata(serio, NULL); - input_free_device(input_dev); + fail3: serio_close(serio); + fail2: serio_set_drvdata(serio, NULL); + fail1: input_free_device(input_dev); kfree(warrior); return err; } -- cgit v1.2.3-70-g09d2 From 153a9df01c0d1ecdc56161c7a0f830325145dd64 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Thu, 23 Nov 2006 23:35:10 -0500 Subject: Input: handle serio_register_driver() errors Signed-off-by: Akinobu Mita Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/iforce/iforce-main.c | 14 +++++++++++--- drivers/input/joystick/magellan.c | 3 +-- drivers/input/joystick/spaceball.c | 3 +-- drivers/input/joystick/spaceorb.c | 3 +-- drivers/input/joystick/stinger.c | 3 +-- drivers/input/joystick/twidjoy.c | 3 +-- drivers/input/joystick/warrior.c | 3 +-- drivers/input/keyboard/atkbd.c | 3 +-- drivers/input/keyboard/hil_kbd.c | 3 +-- drivers/input/keyboard/lkkbd.c | 3 +-- drivers/input/keyboard/newtonkbd.c | 3 +-- drivers/input/keyboard/stowaway.c | 3 +-- drivers/input/keyboard/sunkbd.c | 3 +-- drivers/input/keyboard/xtkbd.c | 3 +-- drivers/input/mouse/hil_ptr.c | 3 +-- drivers/input/mouse/psmouse-base.c | 8 ++++++-- drivers/input/mouse/sermouse.c | 3 +-- drivers/input/mouse/vsxxxaa.c | 3 +-- drivers/input/serio/serio_raw.c | 3 +-- drivers/input/touchscreen/elo.c | 3 +-- drivers/input/touchscreen/gunze.c | 3 +-- drivers/input/touchscreen/h3600_ts_input.c | 3 +-- drivers/input/touchscreen/mtouch.c | 3 +-- drivers/input/touchscreen/penmount.c | 3 +-- drivers/input/touchscreen/touchright.c | 3 +-- drivers/input/touchscreen/touchwin.c | 3 +-- 26 files changed, 41 insertions(+), 53 deletions(-) (limited to 'drivers/input/joystick/warrior.c') diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c index 706e0aea793..3393a37fec3 100644 --- a/drivers/input/joystick/iforce/iforce-main.c +++ b/drivers/input/joystick/iforce/iforce-main.c @@ -467,13 +467,21 @@ int iforce_init_device(struct iforce *iforce) static int __init iforce_init(void) { + int err = 0; + #ifdef CONFIG_JOYSTICK_IFORCE_USB - usb_register(&iforce_usb_driver); + err = usb_register(&iforce_usb_driver); + if (err) + return err; #endif #ifdef CONFIG_JOYSTICK_IFORCE_232 - serio_register_driver(&iforce_serio_drv); + err = serio_register_driver(&iforce_serio_drv); +#ifdef CONFIG_JOYSTICK_IFORCE_USB + if (err) + usb_deregister(&iforce_usb_driver); #endif - return 0; +#endif + return err; } static void __exit iforce_exit(void) diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c index d512b0a0282..4112789f119 100644 --- a/drivers/input/joystick/magellan.c +++ b/drivers/input/joystick/magellan.c @@ -231,8 +231,7 @@ static struct serio_driver magellan_drv = { static int __init magellan_init(void) { - serio_register_driver(&magellan_drv); - return 0; + return serio_register_driver(&magellan_drv); } static void __exit magellan_exit(void) diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c index 9b3597343c1..08bf113e62e 100644 --- a/drivers/input/joystick/spaceball.c +++ b/drivers/input/joystick/spaceball.c @@ -300,8 +300,7 @@ static struct serio_driver spaceball_drv = { static int __init spaceball_init(void) { - serio_register_driver(&spaceball_drv); - return 0; + return serio_register_driver(&spaceball_drv); } static void __exit spaceball_exit(void) diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c index ea9d51e70a1..c9c79211af7 100644 --- a/drivers/input/joystick/spaceorb.c +++ b/drivers/input/joystick/spaceorb.c @@ -246,8 +246,7 @@ static struct serio_driver spaceorb_drv = { static int __init spaceorb_init(void) { - serio_register_driver(&spaceorb_drv); - return 0; + return serio_register_driver(&spaceorb_drv); } static void __exit spaceorb_exit(void) diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c index b51a4a4c7f6..ecb0916215f 100644 --- a/drivers/input/joystick/stinger.c +++ b/drivers/input/joystick/stinger.c @@ -216,8 +216,7 @@ static struct serio_driver stinger_drv = { static int __init stinger_init(void) { - serio_register_driver(&stinger_drv); - return 0; + return serio_register_driver(&stinger_drv); } static void __exit stinger_exit(void) diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c index 3c1c83e8609..9cf17d6ced8 100644 --- a/drivers/input/joystick/twidjoy.c +++ b/drivers/input/joystick/twidjoy.c @@ -269,8 +269,7 @@ static struct serio_driver twidjoy_drv = { static int __init twidjoy_init(void) { - serio_register_driver(&twidjoy_drv); - return 0; + return serio_register_driver(&twidjoy_drv); } static void __exit twidjoy_exit(void) diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c index 1e4828b9a1a..29d339acf43 100644 --- a/drivers/input/joystick/warrior.c +++ b/drivers/input/joystick/warrior.c @@ -224,8 +224,7 @@ static struct serio_driver warrior_drv = { static int __init warrior_init(void) { - serio_register_driver(&warrior_drv); - return 0; + return serio_register_driver(&warrior_drv); } static void __exit warrior_exit(void) diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 73c6946b2d9..498e64a00e3 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -1389,8 +1389,7 @@ static ssize_t atkbd_show_err_count(struct atkbd *atkbd, char *buf) static int __init atkbd_init(void) { - serio_register_driver(&atkbd_drv); - return 0; + return serio_register_driver(&atkbd_drv); } static void __exit atkbd_exit(void) diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c index e774dd31e99..7cc9728b04d 100644 --- a/drivers/input/keyboard/hil_kbd.c +++ b/drivers/input/keyboard/hil_kbd.c @@ -381,8 +381,7 @@ struct serio_driver hil_kbd_serio_drv = { static int __init hil_kbd_init(void) { - serio_register_driver(&hil_kbd_serio_drv); - return 0; + return serio_register_driver(&hil_kbd_serio_drv); } static void __exit hil_kbd_exit(void) diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c index 0067c1fe3d4..1789785813e 100644 --- a/drivers/input/keyboard/lkkbd.c +++ b/drivers/input/keyboard/lkkbd.c @@ -758,8 +758,7 @@ static struct serio_driver lkkbd_drv = { static int __init lkkbd_init (void) { - serio_register_driver(&lkkbd_drv); - return 0; + return serio_register_driver(&lkkbd_drv); } static void __exit diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c index 33e813948d6..aa29b50765c 100644 --- a/drivers/input/keyboard/newtonkbd.c +++ b/drivers/input/keyboard/newtonkbd.c @@ -169,8 +169,7 @@ static struct serio_driver nkbd_drv = { static int __init nkbd_init(void) { - serio_register_driver(&nkbd_drv); - return 0; + return serio_register_driver(&nkbd_drv); } static void __exit nkbd_exit(void) diff --git a/drivers/input/keyboard/stowaway.c b/drivers/input/keyboard/stowaway.c index e60937d17b1..f7b5c5b8145 100644 --- a/drivers/input/keyboard/stowaway.c +++ b/drivers/input/keyboard/stowaway.c @@ -173,8 +173,7 @@ static struct serio_driver skbd_drv = { static int __init skbd_init(void) { - serio_register_driver(&skbd_drv); - return 0; + return serio_register_driver(&skbd_drv); } static void __exit skbd_exit(void) diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index d1b62f77a71..d6ab6d4b1fa 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c @@ -352,8 +352,7 @@ static struct serio_driver sunkbd_drv = { static int __init sunkbd_init(void) { - serio_register_driver(&sunkbd_drv); - return 0; + return serio_register_driver(&sunkbd_drv); } static void __exit sunkbd_exit(void) diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c index b53f7163858..a8209343213 100644 --- a/drivers/input/keyboard/xtkbd.c +++ b/drivers/input/keyboard/xtkbd.c @@ -174,8 +174,7 @@ static struct serio_driver xtkbd_drv = { static int __init xtkbd_init(void) { - serio_register_driver(&xtkbd_drv); - return 0; + return serio_register_driver(&xtkbd_drv); } static void __exit xtkbd_exit(void) diff --git a/drivers/input/mouse/hil_ptr.c b/drivers/input/mouse/hil_ptr.c index 4f2b503c1ac..bfb174fe323 100644 --- a/drivers/input/mouse/hil_ptr.c +++ b/drivers/input/mouse/hil_ptr.c @@ -417,8 +417,7 @@ static struct serio_driver hil_ptr_serio_driver = { static int __init hil_ptr_init(void) { - serio_register_driver(&hil_ptr_serio_driver); - return 0; + return serio_register_driver(&hil_ptr_serio_driver); } static void __exit hil_ptr_exit(void) diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 58beca99a9c..e626b1e737f 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -1524,15 +1524,19 @@ static int psmouse_get_maxproto(char *buffer, struct kernel_param *kp) static int __init psmouse_init(void) { + int err; + kpsmoused_wq = create_singlethread_workqueue("kpsmoused"); if (!kpsmoused_wq) { printk(KERN_ERR "psmouse: failed to create kpsmoused workqueue\n"); return -ENOMEM; } - serio_register_driver(&psmouse_drv); + err = serio_register_driver(&psmouse_drv); + if (err) + destroy_workqueue(kpsmoused_wq); - return 0; + return err; } static void __exit psmouse_exit(void) diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c index 10b51e7f01f..a85d74710b4 100644 --- a/drivers/input/mouse/sermouse.c +++ b/drivers/input/mouse/sermouse.c @@ -351,8 +351,7 @@ static struct serio_driver sermouse_drv = { static int __init sermouse_init(void) { - serio_register_driver(&sermouse_drv); - return 0; + return serio_register_driver(&sermouse_drv); } static void __exit sermouse_exit(void) diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c index ffd0d6624a8..c3d64fcc858 100644 --- a/drivers/input/mouse/vsxxxaa.c +++ b/drivers/input/mouse/vsxxxaa.c @@ -574,8 +574,7 @@ static struct serio_driver vsxxxaa_drv = { static int __init vsxxxaa_init (void) { - serio_register_driver(&vsxxxaa_drv); - return 0; + return serio_register_driver(&vsxxxaa_drv); } static void __exit diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c index ba2a2035d64..0e343a6cacc 100644 --- a/drivers/input/serio/serio_raw.c +++ b/drivers/input/serio/serio_raw.c @@ -389,8 +389,7 @@ static struct serio_driver serio_raw_drv = { static int __init serio_raw_init(void) { - serio_register_driver(&serio_raw_drv); - return 0; + return serio_register_driver(&serio_raw_drv); } static void __exit serio_raw_exit(void) diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c index 913e1b73bb0..9d61cd133d0 100644 --- a/drivers/input/touchscreen/elo.c +++ b/drivers/input/touchscreen/elo.c @@ -397,8 +397,7 @@ static struct serio_driver elo_drv = { static int __init elo_init(void) { - serio_register_driver(&elo_drv); - return 0; + return serio_register_driver(&elo_drv); } static void __exit elo_exit(void) diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c index 44f397fff71..9157eb148e8 100644 --- a/drivers/input/touchscreen/gunze.c +++ b/drivers/input/touchscreen/gunze.c @@ -194,8 +194,7 @@ static struct serio_driver gunze_drv = { static int __init gunze_init(void) { - serio_register_driver(&gunze_drv); - return 0; + return serio_register_driver(&gunze_drv); } static void __exit gunze_exit(void) diff --git a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c index d9e61ee05ea..c4116d4f64e 100644 --- a/drivers/input/touchscreen/h3600_ts_input.c +++ b/drivers/input/touchscreen/h3600_ts_input.c @@ -478,8 +478,7 @@ static struct serio_driver h3600ts_drv = { static int __init h3600ts_init(void) { - serio_register_driver(&h3600ts_drv); - return 0; + return serio_register_driver(&h3600ts_drv); } static void __exit h3600ts_exit(void) diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c index c66b399774f..c3c2d735d0e 100644 --- a/drivers/input/touchscreen/mtouch.c +++ b/drivers/input/touchscreen/mtouch.c @@ -208,8 +208,7 @@ static struct serio_driver mtouch_drv = { static int __init mtouch_init(void) { - serio_register_driver(&mtouch_drv); - return 0; + return serio_register_driver(&mtouch_drv); } static void __exit mtouch_exit(void) diff --git a/drivers/input/touchscreen/penmount.c b/drivers/input/touchscreen/penmount.c index 6c7d0c2c76c..bd2767991ae 100644 --- a/drivers/input/touchscreen/penmount.c +++ b/drivers/input/touchscreen/penmount.c @@ -171,8 +171,7 @@ static struct serio_driver pm_drv = { static int __init pm_init(void) { - serio_register_driver(&pm_drv); - return 0; + return serio_register_driver(&pm_drv); } static void __exit pm_exit(void) diff --git a/drivers/input/touchscreen/touchright.c b/drivers/input/touchscreen/touchright.c index c74f74e57af..35ba46c6ad2 100644 --- a/drivers/input/touchscreen/touchright.c +++ b/drivers/input/touchscreen/touchright.c @@ -182,8 +182,7 @@ static struct serio_driver tr_drv = { static int __init tr_init(void) { - serio_register_driver(&tr_drv); - return 0; + return serio_register_driver(&tr_drv); } static void __exit tr_exit(void) diff --git a/drivers/input/touchscreen/touchwin.c b/drivers/input/touchscreen/touchwin.c index 9911820fa2f..4dc073dacab 100644 --- a/drivers/input/touchscreen/touchwin.c +++ b/drivers/input/touchscreen/touchwin.c @@ -189,8 +189,7 @@ static struct serio_driver tw_drv = { static int __init tw_init(void) { - serio_register_driver(&tw_drv); - return 0; + return serio_register_driver(&tw_drv); } static void __exit tw_exit(void) -- cgit v1.2.3-70-g09d2