]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/input/mouse/inport.c
Input: psmouse - fix input_dev leak in lifebook driver
[linux-2.6-omap-h63xx.git] / drivers / input / mouse / inport.c
index e1252fa9a10788b88f38005b0eb78ebd3cfa41c3..26ec09529b515fce59a3324f8310b2c64c6a9b62 100644 (file)
@@ -61,7 +61,7 @@ MODULE_LICENSE("GPL");
 #define INPORT_REG_MODE                0x07
 #define INPORT_RESET           0x80
 
-#ifdef CONFIG_INPUT_ATIXL
+#ifdef CONFIG_MOUSE_ATIXL
 #define INPORT_NAME            "ATI XL Mouse"
 #define INPORT_VENDOR          0x0002
 #define INPORT_SPEED_30HZ      0x01
@@ -84,8 +84,6 @@ static int inport_irq = INPORT_IRQ;
 module_param_named(irq, inport_irq, uint, 0);
 MODULE_PARM_DESC(irq, "IRQ number (5=default)");
 
-__obsolete_setup("inport_irq=");
-
 static struct input_dev *inport_dev;
 
 static irqreturn_t inport_interrupt(int irq, void *dev_id)
@@ -135,6 +133,7 @@ static void inport_close(struct input_dev *dev)
 static int __init inport_init(void)
 {
        unsigned char a, b, c;
+       int err;
 
        if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) {
                printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE);
@@ -145,15 +144,16 @@ static int __init inport_init(void)
        b = inb(INPORT_SIGNATURE_PORT);
        c = inb(INPORT_SIGNATURE_PORT);
        if (a == b || a != c) {
-               release_region(INPORT_BASE, INPORT_EXTENT);
-               printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE);
-               return -ENODEV;
+               printk(KERN_INFO "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE);
+               err = -ENODEV;
+               goto err_release_region;
        }
 
-       if (!(inport_dev = input_allocate_device())) {
+       inport_dev = input_allocate_device();
+       if (!inport_dev) {
                printk(KERN_ERR "inport.c: Not enough memory for input device\n");
-               release_region(INPORT_BASE, INPORT_EXTENT);
-               return -ENOMEM;
+               err = -ENOMEM;
+               goto err_release_region;
        }
 
        inport_dev->name = INPORT_NAME;
@@ -163,9 +163,10 @@ static int __init inport_init(void)
        inport_dev->id.product = 0x0001;
        inport_dev->id.version = 0x0100;
 
-       inport_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
-       inport_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
-       inport_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
+       inport_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
+       inport_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) |
+               BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
+       inport_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
 
        inport_dev->open  = inport_open;
        inport_dev->close = inport_close;
@@ -174,9 +175,18 @@ static int __init inport_init(void)
        outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
        outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
 
-       input_register_device(inport_dev);
+       err = input_register_device(inport_dev);
+       if (err)
+               goto err_free_dev;
 
        return 0;
+
+ err_free_dev:
+       input_free_device(inport_dev);
+ err_release_region:
+       release_region(INPORT_BASE, INPORT_EXTENT);
+
+       return err;
 }
 
 static void __exit inport_exit(void)