diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-05-29 03:29:30 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-05-29 03:29:30 -0400 |
commit | 3108d42de4da0823feb37a55db62acdc01554625 (patch) | |
tree | 5c46888f791191d7595f0a4f809bc01062e55d75 /drivers/input | |
parent | 0fbf87caf70acec0c435233fbc39c7bd0aca3ca6 (diff) |
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>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/mouse/amimouse.c | 8 | ||||
-rw-r--r-- | drivers/input/mouse/inport.c | 20 | ||||
-rw-r--r-- | drivers/input/mouse/logibm.c | 7 | ||||
-rw-r--r-- | drivers/input/mouse/maplemouse.c | 73 | ||||
-rw-r--r-- | drivers/input/mouse/pc110pad.c | 7 |
5 files changed, 31 insertions, 84 deletions
diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c index 7baa09cca7c5..e994849efb8f 100644 --- a/drivers/input/mouse/amimouse.c +++ b/drivers/input/mouse/amimouse.c | |||
@@ -33,7 +33,6 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | |||
33 | MODULE_DESCRIPTION("Amiga mouse driver"); | 33 | MODULE_DESCRIPTION("Amiga mouse driver"); |
34 | MODULE_LICENSE("GPL"); | 34 | MODULE_LICENSE("GPL"); |
35 | 35 | ||
36 | static int amimouse_used = 0; | ||
37 | static int amimouse_lastx, amimouse_lasty; | 36 | static int amimouse_lastx, amimouse_lasty; |
38 | static struct input_dev amimouse_dev; | 37 | static struct input_dev amimouse_dev; |
39 | 38 | ||
@@ -81,16 +80,12 @@ static int amimouse_open(struct input_dev *dev) | |||
81 | { | 80 | { |
82 | unsigned short joy0dat; | 81 | unsigned short joy0dat; |
83 | 82 | ||
84 | if (amimouse_used++) | ||
85 | return 0; | ||
86 | |||
87 | joy0dat = custom.joy0dat; | 83 | joy0dat = custom.joy0dat; |
88 | 84 | ||
89 | amimouse_lastx = joy0dat & 0xff; | 85 | amimouse_lastx = joy0dat & 0xff; |
90 | amimouse_lasty = joy0dat >> 8; | 86 | amimouse_lasty = joy0dat >> 8; |
91 | 87 | ||
92 | if (request_irq(IRQ_AMIGA_VERTB, amimouse_interrupt, 0, "amimouse", amimouse_interrupt)) { | 88 | if (request_irq(IRQ_AMIGA_VERTB, amimouse_interrupt, 0, "amimouse", amimouse_interrupt)) { |
93 | amimouse_used--; | ||
94 | printk(KERN_ERR "amimouse.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB); | 89 | printk(KERN_ERR "amimouse.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB); |
95 | return -EBUSY; | 90 | return -EBUSY; |
96 | } | 91 | } |
@@ -100,8 +95,7 @@ static int amimouse_open(struct input_dev *dev) | |||
100 | 95 | ||
101 | static void amimouse_close(struct input_dev *dev) | 96 | static void amimouse_close(struct input_dev *dev) |
102 | { | 97 | { |
103 | if (!--amimouse_used) | 98 | free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt); |
104 | free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt); | ||
105 | } | 99 | } |
106 | 100 | ||
107 | static int __init amimouse_init(void) | 101 | static int __init amimouse_init(void) |
diff --git a/drivers/input/mouse/inport.c b/drivers/input/mouse/inport.c index ceeb2d66762c..1f62c0134010 100644 --- a/drivers/input/mouse/inport.c +++ b/drivers/input/mouse/inport.c | |||
@@ -87,29 +87,23 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)"); | |||
87 | 87 | ||
88 | __obsolete_setup("inport_irq="); | 88 | __obsolete_setup("inport_irq="); |
89 | 89 | ||
90 | static int inport_used; | ||
91 | |||
92 | static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs); | 90 | static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs); |
93 | 91 | ||
94 | static int inport_open(struct input_dev *dev) | 92 | static int inport_open(struct input_dev *dev) |
95 | { | 93 | { |
96 | if (!inport_used++) { | 94 | if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL)) |
97 | if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL)) | 95 | return -EBUSY; |
98 | return -EBUSY; | 96 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); |
99 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); | 97 | outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); |
100 | outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); | ||
101 | } | ||
102 | 98 | ||
103 | return 0; | 99 | return 0; |
104 | } | 100 | } |
105 | 101 | ||
106 | static void inport_close(struct input_dev *dev) | 102 | static void inport_close(struct input_dev *dev) |
107 | { | 103 | { |
108 | if (!--inport_used) { | 104 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); |
109 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); | 105 | outb(INPORT_MODE_BASE, INPORT_DATA_PORT); |
110 | outb(INPORT_MODE_BASE, INPORT_DATA_PORT); | 106 | free_irq(inport_irq, NULL); |
111 | free_irq(inport_irq, NULL); | ||
112 | } | ||
113 | } | 107 | } |
114 | 108 | ||
115 | static struct input_dev inport_dev = { | 109 | static struct input_dev inport_dev = { |
diff --git a/drivers/input/mouse/logibm.c b/drivers/input/mouse/logibm.c index 30a2758d0a0d..8b5243167227 100644 --- a/drivers/input/mouse/logibm.c +++ b/drivers/input/mouse/logibm.c | |||
@@ -77,16 +77,11 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)"); | |||
77 | 77 | ||
78 | __obsolete_setup("logibm_irq="); | 78 | __obsolete_setup("logibm_irq="); |
79 | 79 | ||
80 | static int logibm_used = 0; | ||
81 | |||
82 | static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs); | 80 | static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs); |
83 | 81 | ||
84 | static int logibm_open(struct input_dev *dev) | 82 | static int logibm_open(struct input_dev *dev) |
85 | { | 83 | { |
86 | if (logibm_used++) | ||
87 | return 0; | ||
88 | if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) { | 84 | if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) { |
89 | logibm_used--; | ||
90 | printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq); | 85 | printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq); |
91 | return -EBUSY; | 86 | return -EBUSY; |
92 | } | 87 | } |
@@ -96,8 +91,6 @@ static int logibm_open(struct input_dev *dev) | |||
96 | 91 | ||
97 | static void logibm_close(struct input_dev *dev) | 92 | static void logibm_close(struct input_dev *dev) |
98 | { | 93 | { |
99 | if (--logibm_used) | ||
100 | return; | ||
101 | outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); | 94 | outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); |
102 | free_irq(logibm_irq, NULL); | 95 | free_irq(logibm_irq, NULL); |
103 | } | 96 | } |
diff --git a/drivers/input/mouse/maplemouse.c b/drivers/input/mouse/maplemouse.c index 088f69406558..e90c60cbbf05 100644 --- a/drivers/input/mouse/maplemouse.c +++ b/drivers/input/mouse/maplemouse.c | |||
@@ -15,80 +15,51 @@ | |||
15 | MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>"); | 15 | MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>"); |
16 | MODULE_DESCRIPTION("SEGA Dreamcast mouse driver"); | 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 | static void dc_mouse_callback(struct mapleq *mq) | 18 | static void dc_mouse_callback(struct mapleq *mq) |
25 | { | 19 | { |
26 | int buttons, relx, rely, relz; | 20 | int buttons, relx, rely, relz; |
27 | struct maple_device *mapledev = mq->dev; | 21 | struct maple_device *mapledev = mq->dev; |
28 | struct dc_mouse *mouse = mapledev->private_data; | 22 | struct input_dev *dev = mapledev->private_data; |
29 | struct input_dev *dev = &mouse->dev; | ||
30 | unsigned char *res = mq->recvbuf; | 23 | unsigned char *res = mq->recvbuf; |
31 | 24 | ||
32 | buttons = ~res[8]; | 25 | buttons = ~res[8]; |
33 | relx=*(unsigned short *)(res+12)-512; | 26 | relx = *(unsigned short *)(res + 12) - 512; |
34 | rely=*(unsigned short *)(res+14)-512; | 27 | rely = *(unsigned short *)(res + 14) - 512; |
35 | relz=*(unsigned short *)(res+16)-512; | 28 | relz = *(unsigned short *)(res + 16) - 512; |
36 | 29 | ||
37 | input_report_key(dev, BTN_LEFT, buttons&4); | 30 | input_report_key(dev, BTN_LEFT, buttons & 4); |
38 | input_report_key(dev, BTN_MIDDLE, buttons&9); | 31 | input_report_key(dev, BTN_MIDDLE, buttons & 9); |
39 | input_report_key(dev, BTN_RIGHT, buttons&2); | 32 | input_report_key(dev, BTN_RIGHT, buttons & 2); |
40 | input_report_rel(dev, REL_X, relx); | 33 | input_report_rel(dev, REL_X, relx); |
41 | input_report_rel(dev, REL_Y, rely); | 34 | input_report_rel(dev, REL_Y, rely); |
42 | input_report_rel(dev, REL_WHEEL, relz); | 35 | input_report_rel(dev, REL_WHEEL, relz); |
43 | input_sync(dev); | 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 | static int dc_mouse_connect(struct maple_device *dev) | 39 | static int dc_mouse_connect(struct maple_device *dev) |
63 | { | 40 | { |
64 | unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); | 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 | return -1; | 45 | return -1; |
69 | memset(mouse, 0, sizeof(struct dc_mouse)); | ||
70 | |||
71 | dev->private_data = mouse; | ||
72 | |||
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); | ||
76 | 46 | ||
77 | init_input_dev(&mouse->dev); | 47 | dev->private_data = input_dev; |
78 | 48 | ||
79 | mouse->dev.private = mouse; | 49 | memset(input_dev, 0, sizeof(struct dc_mouse)); |
80 | mouse->dev.open = dc_mouse_open; | 50 | init_input_dev(input_dev); |
81 | mouse->dev.close = dc_mouse_close; | 51 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); |
82 | mouse->dev.event = NULL; | 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); | ||
83 | 54 | ||
84 | mouse->dev.name = dev->product_name; | 55 | input_dev->name = dev->product_name; |
85 | mouse->dev.id.bustype = BUS_MAPLE; | 56 | input_dev->id.bustype = BUS_MAPLE; |
86 | 57 | ||
87 | input_register_device(&mouse->dev); | 58 | input_register_device(input_dev); |
88 | 59 | ||
89 | maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE); | 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 | return 0; | 64 | return 0; |
94 | } | 65 | } |
@@ -96,10 +67,10 @@ static int dc_mouse_connect(struct maple_device *dev) | |||
96 | 67 | ||
97 | static void dc_mouse_disconnect(struct maple_device *dev) | 68 | static void dc_mouse_disconnect(struct maple_device *dev) |
98 | { | 69 | { |
99 | struct dc_mouse *mouse = dev->private_data; | 70 | struct input_dev *input_dev = dev->private_data; |
100 | 71 | ||
101 | input_unregister_device(&mouse->dev); | 72 | input_unregister_device(input_dev); |
102 | kfree(mouse); | 73 | kfree(input_dev); |
103 | } | 74 | } |
104 | 75 | ||
105 | 76 | ||
diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c index fe47dce28d29..93393d5c0078 100644 --- a/drivers/input/mouse/pc110pad.c +++ b/drivers/input/mouse/pc110pad.c | |||
@@ -56,7 +56,6 @@ static int pc110pad_io = 0x15e0; | |||
56 | static struct input_dev pc110pad_dev; | 56 | static struct input_dev pc110pad_dev; |
57 | static int pc110pad_data[3]; | 57 | static int pc110pad_data[3]; |
58 | static int pc110pad_count; | 58 | static int pc110pad_count; |
59 | static int pc110pad_used; | ||
60 | 59 | ||
61 | static char *pc110pad_name = "IBM PC110 TouchPad"; | 60 | static char *pc110pad_name = "IBM PC110 TouchPad"; |
62 | static char *pc110pad_phys = "isa15e0/input0"; | 61 | static char *pc110pad_phys = "isa15e0/input0"; |
@@ -90,15 +89,11 @@ static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs) | |||
90 | 89 | ||
91 | static void pc110pad_close(struct input_dev *dev) | 90 | static void pc110pad_close(struct input_dev *dev) |
92 | { | 91 | { |
93 | if (!--pc110pad_used) | 92 | outb(PC110PAD_OFF, pc110pad_io + 2); |
94 | outb(PC110PAD_OFF, pc110pad_io + 2); | ||
95 | } | 93 | } |
96 | 94 | ||
97 | static int pc110pad_open(struct input_dev *dev) | 95 | static int pc110pad_open(struct input_dev *dev) |
98 | { | 96 | { |
99 | if (pc110pad_used++) | ||
100 | return 0; | ||
101 | |||
102 | pc110pad_interrupt(0,NULL,NULL); | 97 | pc110pad_interrupt(0,NULL,NULL); |
103 | pc110pad_interrupt(0,NULL,NULL); | 98 | pc110pad_interrupt(0,NULL,NULL); |
104 | pc110pad_interrupt(0,NULL,NULL); | 99 | pc110pad_interrupt(0,NULL,NULL); |