X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Finput%2Fmouse%2Fhil_ptr.c;h=e532c48410ea63013b5d558ae3d150fd5e77fb44;hb=9b46333406b9cb3397ab538485a4d57c316af0ff;hp=449bf4dcbbcc726cc7546edbbeb122078d039a1c;hpb=bc95f3669f5e6f63cf0b84fe4922c3c6dd4aa775;p=linux-2.6-omap-h63xx.git diff --git a/drivers/input/mouse/hil_ptr.c b/drivers/input/mouse/hil_ptr.c index 449bf4dcbbc..e532c48410e 100644 --- a/drivers/input/mouse/hil_ptr.c +++ b/drivers/input/mouse/hil_ptr.c @@ -247,19 +247,24 @@ static void hil_ptr_disconnect(struct serio *serio) static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) { - struct hil_ptr *ptr; - const char *txt; - unsigned int i, naxsets, btntype; - uint8_t did, *idd; - - if (!(ptr = kzalloc(sizeof(struct hil_ptr), GFP_KERNEL))) + struct hil_ptr *ptr; + const char *txt; + unsigned int i, naxsets, btntype; + uint8_t did, *idd; + int error; + + ptr = kzalloc(sizeof(struct hil_ptr), GFP_KERNEL); + if (!ptr) return -ENOMEM; ptr->dev = input_allocate_device(); - if (!ptr->dev) + if (!ptr->dev) { + error = -ENOMEM; goto bail0; + } - if (serio_open(serio, driver)) + error = serio_open(serio, driver); + if (error) goto bail1; serio_set_drvdata(serio, ptr); @@ -297,21 +302,25 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) did = ptr->idd[0]; idd = ptr->idd + 1; txt = "unknown"; + if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) { - ptr->dev->evbit[0] = BIT(EV_REL); + ptr->dev->evbit[0] = BIT_MASK(EV_REL); txt = "relative"; } if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_ABS) { - ptr->dev->evbit[0] = BIT(EV_ABS); + ptr->dev->evbit[0] = BIT_MASK(EV_ABS); txt = "absolute"; } - if (!ptr->dev->evbit[0]) + + if (!ptr->dev->evbit[0]) { + error = -ENODEV; goto bail2; + } ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd); if (ptr->nbtn) - ptr->dev->evbit[0] |= BIT(EV_KEY); + ptr->dev->evbit[0] |= BIT_MASK(EV_KEY); naxsets = HIL_IDD_NUM_AXSETS(*idd); ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd); @@ -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->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", ptr->dev->name, (btntype == BTN_MOUSE) ? "HIL mouse":"HIL tablet or touchpad", did); return 0; + bail2: serio_close(serio); bail1: @@ -394,7 +409,7 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) bail0: kfree(ptr); serio_set_drvdata(serio, NULL); - return -ENODEV; + return error; } static struct serio_device_id hil_ptr_ids[] = {