Input: hil_ptr - check return value of input_register_device()

[dtor@mail.ru: also signal correct return value to callers]
Signed-off-by: Andres Salomon <dilinger@debian.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
Andres Salomon 2008-05-06 12:10:39 -04:00 committed by Dmitry Torokhov
parent e9542dff39
commit 2ff9814784

View File

@ -251,15 +251,20 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
const char *txt; const char *txt;
unsigned int i, naxsets, btntype; unsigned int i, naxsets, btntype;
uint8_t did, *idd; uint8_t did, *idd;
int error;
if (!(ptr = kzalloc(sizeof(struct hil_ptr), GFP_KERNEL))) ptr = kzalloc(sizeof(struct hil_ptr), GFP_KERNEL);
if (!ptr)
return -ENOMEM; return -ENOMEM;
ptr->dev = input_allocate_device(); ptr->dev = input_allocate_device();
if (!ptr->dev) if (!ptr->dev) {
error = -ENOMEM;
goto bail0; goto bail0;
}
if (serio_open(serio, driver)) error = serio_open(serio, driver);
if (error)
goto bail1; goto bail1;
serio_set_drvdata(serio, ptr); serio_set_drvdata(serio, ptr);
@ -297,6 +302,7 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
did = ptr->idd[0]; did = ptr->idd[0];
idd = ptr->idd + 1; idd = ptr->idd + 1;
txt = "unknown"; txt = "unknown";
if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) { if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) {
ptr->dev->evbit[0] = BIT_MASK(EV_REL); ptr->dev->evbit[0] = BIT_MASK(EV_REL);
txt = "relative"; txt = "relative";
@ -306,8 +312,11 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
ptr->dev->evbit[0] = BIT_MASK(EV_ABS); ptr->dev->evbit[0] = BIT_MASK(EV_ABS);
txt = "absolute"; txt = "absolute";
} }
if (!ptr->dev->evbit[0])
if (!ptr->dev->evbit[0]) {
error = -ENODEV;
goto bail2; goto bail2;
}
ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd); ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd);
if (ptr->nbtn) if (ptr->nbtn)
@ -380,13 +389,19 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
ptr->dev->id.version = 0x0100; /* TODO: get from ptr->rsc */ ptr->dev->id.version = 0x0100; /* TODO: get from ptr->rsc */
ptr->dev->dev.parent = &serio->dev; ptr->dev->dev.parent = &serio->dev;
input_register_device(ptr->dev); error = input_register_device(ptr->dev);
if (error) {
printk(KERN_INFO PREFIX "Unable to register input device\n");
goto bail2;
}
printk(KERN_INFO "input: %s (%s), ID: %d\n", printk(KERN_INFO "input: %s (%s), ID: %d\n",
ptr->dev->name, ptr->dev->name,
(btntype == BTN_MOUSE) ? "HIL mouse":"HIL tablet or touchpad", (btntype == BTN_MOUSE) ? "HIL mouse":"HIL tablet or touchpad",
did); did);
return 0; return 0;
bail2: bail2:
serio_close(serio); serio_close(serio);
bail1: bail1:
@ -394,7 +409,7 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
bail0: bail0:
kfree(ptr); kfree(ptr);
serio_set_drvdata(serio, NULL); serio_set_drvdata(serio, NULL);
return -ENODEV; return error;
} }
static struct serio_device_id hil_ptr_ids[] = { static struct serio_device_id hil_ptr_ids[] = {