Input: sidewinder - handle errors from input_register_device()
authorDmitry Torokhov <dtor_core@ameritech.net>
Mon, 30 Jan 2006 02:51:56 +0000 (21:51 -0500)
committerDmitry Torokhov <dtor_core@ameritech.net>
Mon, 30 Jan 2006 02:51:56 +0000 (21:51 -0500)
Also set .owner in driver structure so we'll have a link between
module and driver in sysfs.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/input/joystick/sidewinder.c

index 03f9e7ed0304b587f77fec02b00f6ad456cb550f..2b2ec1057deeff1c9fc40f963da81cbbd7267de5 100644 (file)
@@ -771,12 +771,15 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
 
                dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k);
 
-               input_register_device(sw->dev[i]);
+               err = input_register_device(sw->dev[i]);
+               if (err)
+                       goto fail4;
        }
 
        return 0;
 
- fail3: while (--i >= 0)
+ fail4:        input_free_device(sw->dev[i]);
+ fail3:        while (--i >= 0)
                input_unregister_device(sw->dev[i]);
  fail2:        gameport_close(gameport);
  fail1:        gameport_set_drvdata(gameport, NULL);
@@ -801,6 +804,7 @@ static void sw_disconnect(struct gameport *gameport)
 static struct gameport_driver sw_drv = {
        .driver         = {
                .name   = "sidewinder",
+               .owner  = THIS_MODULE,
        },
        .description    = DRIVER_DESC,
        .connect        = sw_connect,