Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: remove user counters from drivers/input/mouse since input core takes care of calling open and close methods only when needed.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

+31 -84
+1 -7
drivers/input/mouse/amimouse.c
··· 33 33 MODULE_DESCRIPTION("Amiga mouse driver"); 34 34 MODULE_LICENSE("GPL"); 35 35 36 - static int amimouse_used = 0; 37 36 static int amimouse_lastx, amimouse_lasty; 38 37 static struct input_dev amimouse_dev; 39 38 ··· 80 81 { 81 82 unsigned short joy0dat; 82 83 83 - if (amimouse_used++) 84 - return 0; 85 - 86 84 joy0dat = custom.joy0dat; 87 85 88 86 amimouse_lastx = joy0dat & 0xff; 89 87 amimouse_lasty = joy0dat >> 8; 90 88 91 89 if (request_irq(IRQ_AMIGA_VERTB, amimouse_interrupt, 0, "amimouse", amimouse_interrupt)) { 92 - amimouse_used--; 93 90 printk(KERN_ERR "amimouse.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB); 94 91 return -EBUSY; 95 92 } ··· 95 100 96 101 static void amimouse_close(struct input_dev *dev) 97 102 { 98 - if (!--amimouse_used) 99 - free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt); 103 + free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt); 100 104 } 101 105 102 106 static int __init amimouse_init(void)
+7 -13
drivers/input/mouse/inport.c
··· 87 87 88 88 __obsolete_setup("inport_irq="); 89 89 90 - static int inport_used; 91 - 92 90 static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs); 93 91 94 92 static int inport_open(struct input_dev *dev) 95 93 { 96 - if (!inport_used++) { 97 - if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL)) 98 - return -EBUSY; 99 - outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 100 - outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); 101 - } 94 + if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL)) 95 + return -EBUSY; 96 + outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 97 + outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); 102 98 103 99 return 0; 104 100 } 105 101 106 102 static void inport_close(struct input_dev *dev) 107 103 { 108 - if (!--inport_used) { 109 - outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 110 - outb(INPORT_MODE_BASE, INPORT_DATA_PORT); 111 - free_irq(inport_irq, NULL); 112 - } 104 + outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 105 + outb(INPORT_MODE_BASE, INPORT_DATA_PORT); 106 + free_irq(inport_irq, NULL); 113 107 } 114 108 115 109 static struct input_dev inport_dev = {
-7
drivers/input/mouse/logibm.c
··· 77 77 78 78 __obsolete_setup("logibm_irq="); 79 79 80 - static int logibm_used = 0; 81 - 82 80 static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs); 83 81 84 82 static int logibm_open(struct input_dev *dev) 85 83 { 86 - if (logibm_used++) 87 - return 0; 88 84 if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) { 89 - logibm_used--; 90 85 printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq); 91 86 return -EBUSY; 92 87 } ··· 91 96 92 97 static void logibm_close(struct input_dev *dev) 93 98 { 94 - if (--logibm_used) 95 - return; 96 99 outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); 97 100 free_irq(logibm_irq, NULL); 98 101 }
+22 -51
drivers/input/mouse/maplemouse.c
··· 15 15 MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>"); 16 16 MODULE_DESCRIPTION("SEGA Dreamcast mouse driver"); 17 17 18 - struct dc_mouse { 19 - struct input_dev dev; 20 - int open; 21 - }; 22 - 23 - 24 18 static void dc_mouse_callback(struct mapleq *mq) 25 19 { 26 20 int buttons, relx, rely, relz; 27 21 struct maple_device *mapledev = mq->dev; 28 - struct dc_mouse *mouse = mapledev->private_data; 29 - struct input_dev *dev = &mouse->dev; 22 + struct input_dev *dev = mapledev->private_data; 30 23 unsigned char *res = mq->recvbuf; 31 24 32 25 buttons = ~res[8]; 33 - relx=*(unsigned short *)(res+12)-512; 34 - rely=*(unsigned short *)(res+14)-512; 35 - relz=*(unsigned short *)(res+16)-512; 26 + relx = *(unsigned short *)(res + 12) - 512; 27 + rely = *(unsigned short *)(res + 14) - 512; 28 + relz = *(unsigned short *)(res + 16) - 512; 36 29 37 - input_report_key(dev, BTN_LEFT, buttons&4); 38 - input_report_key(dev, BTN_MIDDLE, buttons&9); 39 - input_report_key(dev, BTN_RIGHT, buttons&2); 30 + input_report_key(dev, BTN_LEFT, buttons & 4); 31 + input_report_key(dev, BTN_MIDDLE, buttons & 9); 32 + input_report_key(dev, BTN_RIGHT, buttons & 2); 40 33 input_report_rel(dev, REL_X, relx); 41 34 input_report_rel(dev, REL_Y, rely); 42 35 input_report_rel(dev, REL_WHEEL, relz); 43 36 input_sync(dev); 44 37 } 45 38 46 - 47 - static int dc_mouse_open(struct input_dev *dev) 48 - { 49 - struct dc_mouse *mouse = dev->private; 50 - mouse->open++; 51 - return 0; 52 - } 53 - 54 - 55 - static void dc_mouse_close(struct input_dev *dev) 56 - { 57 - struct dc_mouse *mouse = dev->private; 58 - mouse->open--; 59 - } 60 - 61 - 62 39 static int dc_mouse_connect(struct maple_device *dev) 63 40 { 64 41 unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); 65 - struct dc_mouse *mouse; 42 + struct input_dev *input_dev; 66 43 67 - if (!(mouse = kmalloc(sizeof(struct dc_mouse), GFP_KERNEL))) 44 + if (!(input_dev = kmalloc(sizeof(struct input_dev), GFP_KERNEL))) 68 45 return -1; 69 - memset(mouse, 0, sizeof(struct dc_mouse)); 70 46 71 - dev->private_data = mouse; 47 + dev->private_data = input_dev; 72 48 73 - mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 74 - mouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 75 - mouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL); 49 + memset(input_dev, 0, sizeof(struct dc_mouse)); 50 + init_input_dev(input_dev); 51 + input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 52 + input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 53 + input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL); 76 54 77 - init_input_dev(&mouse->dev); 55 + input_dev->name = dev->product_name; 56 + input_dev->id.bustype = BUS_MAPLE; 78 57 79 - mouse->dev.private = mouse; 80 - mouse->dev.open = dc_mouse_open; 81 - mouse->dev.close = dc_mouse_close; 82 - mouse->dev.event = NULL; 83 - 84 - mouse->dev.name = dev->product_name; 85 - mouse->dev.id.bustype = BUS_MAPLE; 86 - 87 - input_register_device(&mouse->dev); 58 + input_register_device(input_dev); 88 59 89 60 maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE); 90 61 91 - printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, mouse->dev.name); 62 + printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, input_dev->name); 92 63 93 64 return 0; 94 65 } ··· 67 96 68 97 static void dc_mouse_disconnect(struct maple_device *dev) 69 98 { 70 - struct dc_mouse *mouse = dev->private_data; 99 + struct input_dev *input_dev = dev->private_data; 71 100 72 - input_unregister_device(&mouse->dev); 73 - kfree(mouse); 101 + input_unregister_device(input_dev); 102 + kfree(input_dev); 74 103 } 75 104 76 105
+1 -6
drivers/input/mouse/pc110pad.c
··· 56 56 static struct input_dev pc110pad_dev; 57 57 static int pc110pad_data[3]; 58 58 static int pc110pad_count; 59 - static int pc110pad_used; 60 59 61 60 static char *pc110pad_name = "IBM PC110 TouchPad"; 62 61 static char *pc110pad_phys = "isa15e0/input0"; ··· 89 90 90 91 static void pc110pad_close(struct input_dev *dev) 91 92 { 92 - if (!--pc110pad_used) 93 - outb(PC110PAD_OFF, pc110pad_io + 2); 93 + outb(PC110PAD_OFF, pc110pad_io + 2); 94 94 } 95 95 96 96 static int pc110pad_open(struct input_dev *dev) 97 97 { 98 - if (pc110pad_used++) 99 - return 0; 100 - 101 98 pc110pad_interrupt(0,NULL,NULL); 102 99 pc110pad_interrupt(0,NULL,NULL); 103 100 pc110pad_interrupt(0,NULL,NULL);