diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-01-29 21:52:26 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-01-29 21:52:26 -0500 |
commit | 4d462b9e2372f9f5a885f8b7e1597fe7412347fd (patch) | |
tree | 81508384f3e74d1c410e60205b976caedebd6125 | |
parent | ab52cd66ae4c3e097811b6c370de7fc057959419 (diff) |
Input: tmdc - handle errors from input_register_device()
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>
-rw-r--r-- | drivers/input/joystick/tmdc.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c index 60e2aac7d06e..bb23ed2a04a6 100644 --- a/drivers/input/joystick/tmdc.c +++ b/drivers/input/joystick/tmdc.c @@ -284,13 +284,13 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data) struct tmdc_port *port; struct input_dev *input_dev; int i, j, b = 0; + int err; tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL); input_dev = input_allocate_device(); if (!port || !input_dev) { - kfree(port); - input_free_device(input_dev); - return -ENOMEM; + err = -ENOMEM; + goto fail; } port->mode = data[TMDC_BYTE_ID]; @@ -347,9 +347,15 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data) b += port->btnc[i]; } - input_register_device(port->dev); + err = input_register_device(port->dev); + if (err) + goto fail; return 0; + + fail: input_free_device(input_dev); + kfree(port); + return err; } /* @@ -424,6 +430,7 @@ static void tmdc_disconnect(struct gameport *gameport) static struct gameport_driver tmdc_drv = { .driver = { .name = "tmdc", + .owner = THIS_MODULE, }, .description = DRIVER_DESC, .connect = tmdc_connect, |