Input: joysticks - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
Родитель
52c1f5704d
Коммит
127278ce22
|
@ -521,11 +521,19 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
|
|||
for (i = 0; i < 2; i++)
|
||||
if (port->adi[i].length > 0) {
|
||||
adi_init_center(port->adi + i);
|
||||
input_register_device(port->adi[i].dev);
|
||||
err = input_register_device(port->adi[i].dev);
|
||||
if (err)
|
||||
goto fail3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail3: while (--i >= 0) {
|
||||
if (port->adi[i].length > 0) {
|
||||
input_unregister_device(port->adi[i].dev);
|
||||
port->adi[i].dev = NULL;
|
||||
}
|
||||
}
|
||||
fail2: for (i = 0; i < 2; i++)
|
||||
if (port->adi[i].dev)
|
||||
input_free_device(port->adi[i].dev);
|
||||
|
|
|
@ -147,7 +147,11 @@ static int __init amijoy_init(void)
|
|||
amijoy_dev[i]->absmax[ABS_X + j] = 1;
|
||||
}
|
||||
|
||||
input_register_device(amijoy_dev[i]);
|
||||
err = input_register_device(amijoy_dev[i]);
|
||||
if (err) {
|
||||
input_free_device(amijoy_dev[i]);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -434,6 +434,7 @@ static int analog_init_device(struct analog_port *port, struct analog *analog, i
|
|||
{
|
||||
struct input_dev *input_dev;
|
||||
int i, j, t, v, w, x, y, z;
|
||||
int error;
|
||||
|
||||
analog_name(analog);
|
||||
snprintf(analog->phys, sizeof(analog->phys),
|
||||
|
@ -505,7 +506,11 @@ static int analog_init_device(struct analog_port *port, struct analog *analog, i
|
|||
|
||||
analog_decode(analog, port->axes, port->initial, port->buttons);
|
||||
|
||||
input_register_device(analog->dev);
|
||||
error = input_register_device(analog->dev);
|
||||
if (error) {
|
||||
input_free_device(analog->dev);
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -668,7 +673,8 @@ static int analog_connect(struct gameport *gameport, struct gameport_driver *drv
|
|||
return 0;
|
||||
|
||||
fail3: while (--i >= 0)
|
||||
input_unregister_device(port->analog[i].dev);
|
||||
if (port->analog[i].mask)
|
||||
input_unregister_device(port->analog[i].dev);
|
||||
fail2: gameport_close(gameport);
|
||||
fail1: gameport_set_drvdata(gameport, NULL);
|
||||
kfree(port);
|
||||
|
|
|
@ -223,12 +223,15 @@ static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv)
|
|||
for (j = 0; cobra_btn[j]; j++)
|
||||
set_bit(cobra_btn[j], input_dev->keybit);
|
||||
|
||||
input_register_device(cobra->dev[i]);
|
||||
err = input_register_device(cobra->dev[i]);
|
||||
if (err)
|
||||
goto fail4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail3: for (i = 0; i < 2; i++)
|
||||
fail4: input_free_device(cobra->dev[i]);
|
||||
fail3: while (--i >= 0)
|
||||
if (cobra->dev[i])
|
||||
input_unregister_device(cobra->dev[i]);
|
||||
fail2: gameport_close(gameport);
|
||||
|
|
|
@ -341,7 +341,9 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
|
|||
input_dev->absflat[gf2k_abs[i]] = (i < 2) ? 24 : 0;
|
||||
}
|
||||
|
||||
input_register_device(gf2k->dev);
|
||||
err = input_register_device(gf2k->dev);
|
||||
if (err)
|
||||
goto fail2;
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -423,7 +423,10 @@ static int get_and_decode_packet(struct grip_mp *grip, int flags)
|
|||
|
||||
if (!port->registered) {
|
||||
dbg("New Grip pad in multiport slot %d.\n", slot);
|
||||
register_slot(slot, grip);
|
||||
if (register_slot(slot, grip)) {
|
||||
port->mode = GRIP_MODE_RESET;
|
||||
port->dirty = 0;
|
||||
}
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
@ -585,6 +588,7 @@ static int register_slot(int slot, struct grip_mp *grip)
|
|||
struct grip_port *port = grip->port[slot];
|
||||
struct input_dev *input_dev;
|
||||
int j, t;
|
||||
int err;
|
||||
|
||||
port->dev = input_dev = input_allocate_device();
|
||||
if (!input_dev)
|
||||
|
@ -610,7 +614,12 @@ static int register_slot(int slot, struct grip_mp *grip)
|
|||
if (t > 0)
|
||||
set_bit(t, input_dev->keybit);
|
||||
|
||||
input_register_device(port->dev);
|
||||
err = input_register_device(port->dev);
|
||||
if (err) {
|
||||
input_free_device(port->dev);
|
||||
return err;
|
||||
}
|
||||
|
||||
port->registered = 1;
|
||||
|
||||
if (port->dirty) /* report initial state, if any */
|
||||
|
|
|
@ -250,7 +250,9 @@ static int guillemot_connect(struct gameport *gameport, struct gameport_driver *
|
|||
for (i = 0; (t = guillemot->type->btn[i]) >= 0; i++)
|
||||
set_bit(t, input_dev->keybit);
|
||||
|
||||
input_register_device(guillemot->dev);
|
||||
err = input_register_device(guillemot->dev);
|
||||
if (err)
|
||||
goto fail2;
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -325,8 +325,8 @@ int iforce_init_device(struct iforce *iforce)
|
|||
|
||||
if (i == 20) { /* 5 seconds */
|
||||
printk(KERN_ERR "iforce-main.c: Timeout waiting for response from device.\n");
|
||||
input_free_device(input_dev);
|
||||
return -ENODEV;
|
||||
error = -ENODEV;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -439,10 +439,8 @@ int iforce_init_device(struct iforce *iforce)
|
|||
set_bit(iforce->type->ff[i], input_dev->ffbit);
|
||||
|
||||
error = input_ff_create(input_dev, ff_effects);
|
||||
if (error) {
|
||||
input_free_device(input_dev);
|
||||
return error;
|
||||
}
|
||||
if (error)
|
||||
goto fail;
|
||||
|
||||
ff = input_dev->ff;
|
||||
ff->upload = iforce_upload_effect;
|
||||
|
@ -455,11 +453,16 @@ int iforce_init_device(struct iforce *iforce)
|
|||
* Register input device.
|
||||
*/
|
||||
|
||||
input_register_device(iforce->dev);
|
||||
error = input_register_device(iforce->dev);
|
||||
if (error)
|
||||
goto fail;
|
||||
|
||||
printk(KERN_DEBUG "iforce->dev->open = %p\n", iforce->dev->open);
|
||||
|
||||
return 0;
|
||||
|
||||
fail: input_free_device(input_dev);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int __init iforce_init(void)
|
||||
|
|
|
@ -141,21 +141,19 @@ static int iforce_serio_connect(struct serio *serio, struct serio_driver *drv)
|
|||
serio_set_drvdata(serio, iforce);
|
||||
|
||||
err = serio_open(serio, drv);
|
||||
if (err) {
|
||||
serio_set_drvdata(serio, NULL);
|
||||
kfree(iforce);
|
||||
return err;
|
||||
}
|
||||
if (err)
|
||||
goto fail1;
|
||||
|
||||
err = iforce_init_device(iforce);
|
||||
if (err) {
|
||||
serio_close(serio);
|
||||
serio_set_drvdata(serio, NULL);
|
||||
kfree(iforce);
|
||||
return -ENODEV;
|
||||
}
|
||||
if (err)
|
||||
goto fail2;
|
||||
|
||||
return 0;
|
||||
|
||||
fail2: serio_close(serio);
|
||||
fail1: serio_set_drvdata(serio, NULL);
|
||||
kfree(iforce);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void iforce_serio_disconnect(struct serio *serio)
|
||||
|
|
|
@ -283,7 +283,9 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d
|
|||
for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++)
|
||||
set_bit(t, input_dev->keybit);
|
||||
|
||||
input_register_device(interact->dev);
|
||||
err = input_register_device(interact->dev);
|
||||
if (err)
|
||||
goto fail2;
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ static int magellan_connect(struct serio *serio, struct serio_driver *drv)
|
|||
magellan = kzalloc(sizeof(struct magellan), GFP_KERNEL);
|
||||
input_dev = input_allocate_device();
|
||||
if (!magellan || !input_dev)
|
||||
goto fail;
|
||||
goto fail1;
|
||||
|
||||
magellan->dev = input_dev;
|
||||
snprintf(magellan->phys, sizeof(magellan->phys), "%s/input0", serio->phys);
|
||||
|
@ -183,13 +183,17 @@ static int magellan_connect(struct serio *serio, struct serio_driver *drv)
|
|||
|
||||
err = serio_open(serio, drv);
|
||||
if (err)
|
||||
goto fail;
|
||||
goto fail2;
|
||||
|
||||
err = input_register_device(magellan->dev);
|
||||
if (err)
|
||||
goto fail3;
|
||||
|
||||
input_register_device(magellan->dev);
|
||||
return 0;
|
||||
|
||||
fail: serio_set_drvdata(serio, NULL);
|
||||
input_free_device(input_dev);
|
||||
fail3: serio_close(serio);
|
||||
fail2: serio_set_drvdata(serio, NULL);
|
||||
fail1: input_free_device(input_dev);
|
||||
kfree(magellan);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ static int spaceball_connect(struct serio *serio, struct serio_driver *drv)
|
|||
spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL);
|
||||
input_dev = input_allocate_device();
|
||||
if (!spaceball || !input_dev)
|
||||
goto fail;
|
||||
goto fail1;
|
||||
|
||||
spaceball->dev = input_dev;
|
||||
snprintf(spaceball->phys, sizeof(spaceball->phys), "%s/input0", serio->phys);
|
||||
|
@ -252,13 +252,17 @@ static int spaceball_connect(struct serio *serio, struct serio_driver *drv)
|
|||
|
||||
err = serio_open(serio, drv);
|
||||
if (err)
|
||||
goto fail;
|
||||
goto fail2;
|
||||
|
||||
err = input_register_device(spaceball->dev);
|
||||
if (err)
|
||||
goto fail3;
|
||||
|
||||
input_register_device(spaceball->dev);
|
||||
return 0;
|
||||
|
||||
fail: serio_set_drvdata(serio, NULL);
|
||||
input_free_device(input_dev);
|
||||
fail3: serio_close(serio);
|
||||
fail2: serio_set_drvdata(serio, NULL);
|
||||
fail1: input_free_device(input_dev);
|
||||
kfree(spaceball);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ static int spaceorb_connect(struct serio *serio, struct serio_driver *drv)
|
|||
spaceorb = kzalloc(sizeof(struct spaceorb), GFP_KERNEL);
|
||||
input_dev = input_allocate_device();
|
||||
if (!spaceorb || !input_dev)
|
||||
goto fail;
|
||||
goto fail1;
|
||||
|
||||
spaceorb->dev = input_dev;
|
||||
snprintf(spaceorb->phys, sizeof(spaceorb->phys), "%s/input0", serio->phys);
|
||||
|
@ -198,13 +198,17 @@ static int spaceorb_connect(struct serio *serio, struct serio_driver *drv)
|
|||
|
||||
err = serio_open(serio, drv);
|
||||
if (err)
|
||||
goto fail;
|
||||
goto fail2;
|
||||
|
||||
err = input_register_device(spaceorb->dev);
|
||||
if (err)
|
||||
goto fail3;
|
||||
|
||||
input_register_device(spaceorb->dev);
|
||||
return 0;
|
||||
|
||||
fail: serio_set_drvdata(serio, NULL);
|
||||
input_free_device(input_dev);
|
||||
fail3: serio_close(serio);
|
||||
fail2: serio_set_drvdata(serio, NULL);
|
||||
fail1: input_free_device(input_dev);
|
||||
kfree(spaceorb);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv)
|
|||
stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL);
|
||||
input_dev = input_allocate_device();
|
||||
if (!stinger || !input_dev)
|
||||
goto fail;
|
||||
goto fail1;
|
||||
|
||||
stinger->dev = input_dev;
|
||||
snprintf(stinger->phys, sizeof(stinger->phys), "%s/serio0", serio->phys);
|
||||
|
@ -168,13 +168,17 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv)
|
|||
|
||||
err = serio_open(serio, drv);
|
||||
if (err)
|
||||
goto fail;
|
||||
goto fail2;
|
||||
|
||||
err = input_register_device(stinger->dev);
|
||||
if (err)
|
||||
goto fail3;
|
||||
|
||||
input_register_device(stinger->dev);
|
||||
return 0;
|
||||
|
||||
fail: serio_set_drvdata(serio, NULL);
|
||||
input_free_device(input_dev);
|
||||
fail3: serio_close(serio);
|
||||
fail2: serio_set_drvdata(serio, NULL);
|
||||
fail1: input_free_device(input_dev);
|
||||
kfree(stinger);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
|
|||
twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL);
|
||||
input_dev = input_allocate_device();
|
||||
if (!twidjoy || !input_dev)
|
||||
goto fail;
|
||||
goto fail1;
|
||||
|
||||
twidjoy->dev = input_dev;
|
||||
snprintf(twidjoy->phys, sizeof(twidjoy->phys), "%s/input0", serio->phys);
|
||||
|
@ -221,13 +221,17 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
|
|||
|
||||
err = serio_open(serio, drv);
|
||||
if (err)
|
||||
goto fail;
|
||||
goto fail2;
|
||||
|
||||
err = input_register_device(twidjoy->dev);
|
||||
if (err)
|
||||
goto fail3;
|
||||
|
||||
input_register_device(twidjoy->dev);
|
||||
return 0;
|
||||
|
||||
fail: serio_set_drvdata(serio, NULL);
|
||||
input_free_device(input_dev);
|
||||
fail3: serio_close(serio);
|
||||
fail2: serio_set_drvdata(serio, NULL);
|
||||
fail1: input_free_device(input_dev);
|
||||
kfree(twidjoy);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv)
|
|||
warrior = kzalloc(sizeof(struct warrior), GFP_KERNEL);
|
||||
input_dev = input_allocate_device();
|
||||
if (!warrior || !input_dev)
|
||||
goto fail;
|
||||
goto fail1;
|
||||
|
||||
warrior->dev = input_dev;
|
||||
snprintf(warrior->phys, sizeof(warrior->phys), "%s/input0", serio->phys);
|
||||
|
@ -176,13 +176,17 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv)
|
|||
|
||||
err = serio_open(serio, drv);
|
||||
if (err)
|
||||
goto fail;
|
||||
goto fail2;
|
||||
|
||||
err = input_register_device(warrior->dev);
|
||||
if (err)
|
||||
goto fail3;
|
||||
|
||||
input_register_device(warrior->dev);
|
||||
return 0;
|
||||
|
||||
fail: serio_set_drvdata(serio, NULL);
|
||||
input_free_device(input_dev);
|
||||
fail3: serio_close(serio);
|
||||
fail2: serio_set_drvdata(serio, NULL);
|
||||
fail1: input_free_device(input_dev);
|
||||
kfree(warrior);
|
||||
return err;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче