Input: remove user counters from drivers/input/mouse since input
authorDmitry Torokhov <dtor_core@ameritech.net>
Sun, 29 May 2005 07:29:30 +0000 (02:29 -0500)
committerDmitry Torokhov <dtor_core@ameritech.net>
Sun, 29 May 2005 07:29:30 +0000 (02:29 -0500)
       core takes care of calling open and close methods only
       when needed.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/input/mouse/amimouse.c
drivers/input/mouse/inport.c
drivers/input/mouse/logibm.c
drivers/input/mouse/maplemouse.c
drivers/input/mouse/pc110pad.c

index 7baa09cca7c5341a5422a84fbceca005657bf2b3..e994849efb8fca3d6e69604caffeee7f5ec7db6a 100644 (file)
@@ -33,7 +33,6 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
 MODULE_DESCRIPTION("Amiga mouse driver");
 MODULE_LICENSE("GPL");
 
-static int amimouse_used = 0;
 static int amimouse_lastx, amimouse_lasty;
 static struct input_dev amimouse_dev;
 
@@ -81,16 +80,12 @@ static int amimouse_open(struct input_dev *dev)
 {
        unsigned short joy0dat;
 
-        if (amimouse_used++)
-                return 0;
-
        joy0dat = custom.joy0dat;
 
        amimouse_lastx = joy0dat & 0xff;
        amimouse_lasty = joy0dat >> 8;
 
        if (request_irq(IRQ_AMIGA_VERTB, amimouse_interrupt, 0, "amimouse", amimouse_interrupt)) {
-                amimouse_used--;
                 printk(KERN_ERR "amimouse.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB);
                 return -EBUSY;
         }
@@ -100,8 +95,7 @@ static int amimouse_open(struct input_dev *dev)
 
 static void amimouse_close(struct input_dev *dev)
 {
-        if (!--amimouse_used)
-               free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt);
+       free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt);
 }
 
 static int __init amimouse_init(void)
index ceeb2d66762c2555903f545c9a299ff2443f4f53..1f62c013401067fcb51d6d07485dee727e9338d7 100644 (file)
@@ -87,29 +87,23 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)");
 
 __obsolete_setup("inport_irq=");
 
-static int inport_used;
-
 static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 static int inport_open(struct input_dev *dev)
 {
-       if (!inport_used++) {
-               if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL))
-                       return -EBUSY;
-               outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
-               outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
-       }
+       if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL))
+               return -EBUSY;
+       outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
+       outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
 
        return 0;
 }
 
 static void inport_close(struct input_dev *dev)
 {
-       if (!--inport_used) {
-               outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
-               outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
-               free_irq(inport_irq, NULL);
-       }
+       outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
+       outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
+       free_irq(inport_irq, NULL);
 }
 
 static struct input_dev inport_dev = {
index 30a2758d0a0d53c90765afa524e44ee646284dbe..8b5243167227ba364315cedc9f5d4e06696d682a 100644 (file)
@@ -77,16 +77,11 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)");
 
 __obsolete_setup("logibm_irq=");
 
-static int logibm_used = 0;
-
 static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
 static int logibm_open(struct input_dev *dev)
 {
-       if (logibm_used++)
-               return 0;
        if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) {
-               logibm_used--;
                printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq);
                return -EBUSY;
        }
@@ -96,8 +91,6 @@ static int logibm_open(struct input_dev *dev)
 
 static void logibm_close(struct input_dev *dev)
 {
-       if (--logibm_used)
-               return;
        outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);
        free_irq(logibm_irq, NULL);
 }
index 088f6940655865cb8c3569fdb0c826670bfc7fc9..e90c60cbbf05a00459f56359c9d52e9a11eddec1 100644 (file)
 MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>");
 MODULE_DESCRIPTION("SEGA Dreamcast mouse driver");
 
-struct dc_mouse {
-       struct input_dev dev;
-       int open;
-};
-
-
 static void dc_mouse_callback(struct mapleq *mq)
 {
        int buttons, relx, rely, relz;
        struct maple_device *mapledev = mq->dev;
-       struct dc_mouse *mouse = mapledev->private_data;
-       struct input_dev *dev = &mouse->dev;
+       struct input_dev *dev = mapledev->private_data;
        unsigned char *res = mq->recvbuf;
 
        buttons = ~res[8];
-       relx=*(unsigned short *)(res+12)-512;
-       rely=*(unsigned short *)(res+14)-512;
-       relz=*(unsigned short *)(res+16)-512;
+       relx = *(unsigned short *)(res + 12) - 512;
+       rely = *(unsigned short *)(res + 14) - 512;
+       relz = *(unsigned short *)(res + 16) - 512;
 
-       input_report_key(dev, BTN_LEFT,   buttons&4);
-       input_report_key(dev, BTN_MIDDLE, buttons&9);
-       input_report_key(dev, BTN_RIGHT,  buttons&2);
+       input_report_key(dev, BTN_LEFT,   buttons & 4);
+       input_report_key(dev, BTN_MIDDLE, buttons & 9);
+       input_report_key(dev, BTN_RIGHT,  buttons & 2);
        input_report_rel(dev, REL_X,      relx);
        input_report_rel(dev, REL_Y,      rely);
        input_report_rel(dev, REL_WHEEL,  relz);
        input_sync(dev);
 }
 
-
-static int dc_mouse_open(struct input_dev *dev)
-{
-       struct dc_mouse *mouse = dev->private;
-       mouse->open++;
-       return 0;
-}
-
-
-static void dc_mouse_close(struct input_dev *dev)
-{
-       struct dc_mouse *mouse = dev->private;
-       mouse->open--;
-}
-
-
 static int dc_mouse_connect(struct maple_device *dev)
 {
        unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]);
-       struct dc_mouse *mouse;
+       struct input_dev *input_dev;
 
-       if (!(mouse = kmalloc(sizeof(struct dc_mouse), GFP_KERNEL)))
+       if (!(input_dev = kmalloc(sizeof(struct input_dev), GFP_KERNEL)))
                return -1;
-       memset(mouse, 0, sizeof(struct dc_mouse));
-
-       dev->private_data = mouse;
-
-       mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
-       mouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
-       mouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
 
-       init_input_dev(&mouse->dev);
+       dev->private_data = input_dev;
 
-       mouse->dev.private = mouse;
-       mouse->dev.open = dc_mouse_open;
-       mouse->dev.close = dc_mouse_close;
-       mouse->dev.event = NULL;
+       memset(input_dev, 0, sizeof(struct dc_mouse));
+       init_input_dev(input_dev);
+       input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
+       input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
+       input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
 
-       mouse->dev.name = dev->product_name;
-       mouse->dev.id.bustype = BUS_MAPLE;
+       input_dev->name = dev->product_name;
+       input_dev->id.bustype = BUS_MAPLE;
 
-       input_register_device(&mouse->dev);
+       input_register_device(input_dev);
 
        maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE);
 
-       printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, mouse->dev.name);
+       printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, input_dev->name);
 
        return 0;
 }
@@ -96,10 +67,10 @@ static int dc_mouse_connect(struct maple_device *dev)
 
 static void dc_mouse_disconnect(struct maple_device *dev)
 {
-       struct dc_mouse *mouse = dev->private_data;
+       struct input_dev *input_dev = dev->private_data;
 
-       input_unregister_device(&mouse->dev);
-       kfree(mouse);
+       input_unregister_device(input_dev);
+       kfree(input_dev);
 }
 
 
index fe47dce28d29236b5ac51f3aa79dae075df72cc2..93393d5c007800b6cd57963903c56eb1e85daf3c 100644 (file)
@@ -56,7 +56,6 @@ static int pc110pad_io = 0x15e0;
 static struct input_dev pc110pad_dev;
 static int pc110pad_data[3];
 static int pc110pad_count;
-static int pc110pad_used;
 
 static char *pc110pad_name = "IBM PC110 TouchPad";
 static char *pc110pad_phys = "isa15e0/input0";
@@ -90,15 +89,11 @@ static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs)
 
 static void pc110pad_close(struct input_dev *dev)
 {
-       if (!--pc110pad_used)
-               outb(PC110PAD_OFF, pc110pad_io + 2);
+       outb(PC110PAD_OFF, pc110pad_io + 2);
 }
 
 static int pc110pad_open(struct input_dev *dev)
 {
-       if (pc110pad_used++)
-               return 0;
-
        pc110pad_interrupt(0,NULL,NULL);
        pc110pad_interrupt(0,NULL,NULL);
        pc110pad_interrupt(0,NULL,NULL);