Commit 4d462b9e authored by Dmitry Torokhov's avatar Dmitry Torokhov

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: default avatarDmitry Torokhov <dtor@mail.ru>
parent ab52cd66
...@@ -284,13 +284,13 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data) ...@@ -284,13 +284,13 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data)
struct tmdc_port *port; struct tmdc_port *port;
struct input_dev *input_dev; struct input_dev *input_dev;
int i, j, b = 0; int i, j, b = 0;
int err;
tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL); tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
if (!port || !input_dev) { if (!port || !input_dev) {
kfree(port); err = -ENOMEM;
input_free_device(input_dev); goto fail;
return -ENOMEM;
} }
port->mode = data[TMDC_BYTE_ID]; port->mode = data[TMDC_BYTE_ID];
...@@ -347,9 +347,15 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data) ...@@ -347,9 +347,15 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data)
b += port->btnc[i]; b += port->btnc[i];
} }
input_register_device(port->dev); err = input_register_device(port->dev);
if (err)
goto fail;
return 0; return 0;
fail: input_free_device(input_dev);
kfree(port);
return err;
} }
/* /*
...@@ -424,6 +430,7 @@ static void tmdc_disconnect(struct gameport *gameport) ...@@ -424,6 +430,7 @@ static void tmdc_disconnect(struct gameport *gameport)
static struct gameport_driver tmdc_drv = { static struct gameport_driver tmdc_drv = {
.driver = { .driver = {
.name = "tmdc", .name = "tmdc",
.owner = THIS_MODULE,
}, },
.description = DRIVER_DESC, .description = DRIVER_DESC,
.connect = tmdc_connect, .connect = tmdc_connect,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment