Input: handle serio_register_driver() errors
Akinobu Mita [Fri, 24 Nov 2006 04:35:10 +0000 (23:35 -0500)]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

26 files changed:
drivers/input/joystick/iforce/iforce-main.c
drivers/input/joystick/magellan.c
drivers/input/joystick/spaceball.c
drivers/input/joystick/spaceorb.c
drivers/input/joystick/stinger.c
drivers/input/joystick/twidjoy.c
drivers/input/joystick/warrior.c
drivers/input/keyboard/atkbd.c
drivers/input/keyboard/hil_kbd.c
drivers/input/keyboard/lkkbd.c
drivers/input/keyboard/newtonkbd.c
drivers/input/keyboard/stowaway.c
drivers/input/keyboard/sunkbd.c
drivers/input/keyboard/xtkbd.c
drivers/input/mouse/hil_ptr.c
drivers/input/mouse/psmouse-base.c
drivers/input/mouse/sermouse.c
drivers/input/mouse/vsxxxaa.c
drivers/input/serio/serio_raw.c
drivers/input/touchscreen/elo.c
drivers/input/touchscreen/gunze.c
drivers/input/touchscreen/h3600_ts_input.c
drivers/input/touchscreen/mtouch.c
drivers/input/touchscreen/penmount.c
drivers/input/touchscreen/touchright.c
drivers/input/touchscreen/touchwin.c

index 706e0ae..3393a37 100644 (file)
@@ -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)
index d512b0a..4112789 100644 (file)
@@ -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)
index 9b35973..08bf113 100644 (file)
@@ -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)
index ea9d51e..c9c7921 100644 (file)
@@ -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)
index b51a4a4..ecb0916 100644 (file)
@@ -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)
index 3c1c83e..9cf17d6 100644 (file)
@@ -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)
index 1e4828b..29d339a 100644 (file)
@@ -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)
index 73c6946..498e64a 100644 (file)
@@ -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)
index e774dd3..7cc9728 100644 (file)
@@ -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)
index 0067c1f..1789785 100644 (file)
@@ -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
index 33e8139..aa29b50 100644 (file)
@@ -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)
index e60937d..f7b5c5b 100644 (file)
@@ -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)
index d1b62f7..d6ab6d4 100644 (file)
@@ -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)
index b53f716..a820934 100644 (file)
@@ -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)
index 4f2b503..bfb174f 100644 (file)
@@ -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)
index 58beca9..e626b1e 100644 (file)
@@ -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)
index 10b51e7..a85d747 100644 (file)
@@ -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)
index ffd0d66..c3d64fc 100644 (file)
@@ -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
index ba2a203..0e343a6 100644 (file)
@@ -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)
index 913e1b7..9d61cd1 100644 (file)
@@ -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)
index 44f397f..9157eb1 100644 (file)
@@ -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)
index d9e61ee..c4116d4 100644 (file)
@@ -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)
index c66b399..c3c2d73 100644 (file)
@@ -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)
index 6c7d0c2..bd27679 100644 (file)
@@ -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)
index c74f74e..35ba46c 100644 (file)
@@ -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)
index 9911820..4dc073d 100644 (file)
@@ -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)