aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2006-01-29 21:52:26 -0500
committerDmitry Torokhov <dtor_core@ameritech.net>2006-01-29 21:52:26 -0500
commit4d462b9e2372f9f5a885f8b7e1597fe7412347fd (patch)
tree81508384f3e74d1c410e60205b976caedebd6125 /drivers/input
parentab52cd66ae4c3e097811b6c370de7fc057959419 (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>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/joystick/tmdc.c15
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)
284 struct tmdc_port *port; 284 struct tmdc_port *port;
285 struct input_dev *input_dev; 285 struct input_dev *input_dev;
286 int i, j, b = 0; 286 int i, j, b = 0;
287 int err;
287 288
288 tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL); 289 tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL);
289 input_dev = input_allocate_device(); 290 input_dev = input_allocate_device();
290 if (!port || !input_dev) { 291 if (!port || !input_dev) {
291 kfree(port); 292 err = -ENOMEM;
292 input_free_device(input_dev); 293 goto fail;
293 return -ENOMEM;
294 } 294 }
295 295
296 port->mode = data[TMDC_BYTE_ID]; 296 port->mode = data[TMDC_BYTE_ID];
@@ -347,9 +347,15 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data)
347 b += port->btnc[i]; 347 b += port->btnc[i];
348 } 348 }
349 349
350 input_register_device(port->dev); 350 err = input_register_device(port->dev);
351 if (err)
352 goto fail;
351 353
352 return 0; 354 return 0;
355
356 fail: input_free_device(input_dev);
357 kfree(port);
358 return err;
353} 359}
354 360
355/* 361/*
@@ -424,6 +430,7 @@ static void tmdc_disconnect(struct gameport *gameport)
424static struct gameport_driver tmdc_drv = { 430static struct gameport_driver tmdc_drv = {
425 .driver = { 431 .driver = {
426 .name = "tmdc", 432 .name = "tmdc",
433 .owner = THIS_MODULE,
427 }, 434 },
428 .description = DRIVER_DESC, 435 .description = DRIVER_DESC,
429 .connect = tmdc_connect, 436 .connect = tmdc_connect,