aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input/usbmouse.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/input/usbmouse.c')
-rw-r--r--drivers/usb/input/usbmouse.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
index 01155bbddd43..1ec41b5effe6 100644
--- a/drivers/usb/input/usbmouse.c
+++ b/drivers/usb/input/usbmouse.c
@@ -9,18 +9,18 @@
9/* 9/*
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or 12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. 13 * (at your option) any later version.
14 * 14 *
15 * This program is distributed in the hope that it will be useful, 15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * 23 *
24 * Should you need to contact me, the author, you can do so either by 24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: 25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic 26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
@@ -51,7 +51,6 @@ struct usb_mouse {
51 struct usb_device *usbdev; 51 struct usb_device *usbdev;
52 struct input_dev dev; 52 struct input_dev dev;
53 struct urb *irq; 53 struct urb *irq;
54 int open;
55 54
56 signed char *data; 55 signed char *data;
57 dma_addr_t data_dma; 56 dma_addr_t data_dma;
@@ -101,14 +100,9 @@ static int usb_mouse_open(struct input_dev *dev)
101{ 100{
102 struct usb_mouse *mouse = dev->private; 101 struct usb_mouse *mouse = dev->private;
103 102
104 if (mouse->open++)
105 return 0;
106
107 mouse->irq->dev = mouse->usbdev; 103 mouse->irq->dev = mouse->usbdev;
108 if (usb_submit_urb(mouse->irq, GFP_KERNEL)) { 104 if (usb_submit_urb(mouse->irq, GFP_KERNEL))
109 mouse->open--;
110 return -EIO; 105 return -EIO;
111 }
112 106
113 return 0; 107 return 0;
114} 108}
@@ -117,8 +111,7 @@ static void usb_mouse_close(struct input_dev *dev)
117{ 111{
118 struct usb_mouse *mouse = dev->private; 112 struct usb_mouse *mouse = dev->private;
119 113
120 if (!--mouse->open) 114 usb_kill_urb(mouse->irq);
121 usb_kill_urb(mouse->irq);
122} 115}
123 116
124static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_id * id) 117static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_id * id)
@@ -132,19 +125,19 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_
132 125
133 interface = intf->cur_altsetting; 126 interface = intf->cur_altsetting;
134 127
135 if (interface->desc.bNumEndpoints != 1) 128 if (interface->desc.bNumEndpoints != 1)
136 return -ENODEV; 129 return -ENODEV;
137 130
138 endpoint = &interface->endpoint[0].desc; 131 endpoint = &interface->endpoint[0].desc;
139 if (!(endpoint->bEndpointAddress & 0x80)) 132 if (!(endpoint->bEndpointAddress & 0x80))
140 return -ENODEV; 133 return -ENODEV;
141 if ((endpoint->bmAttributes & 3) != 3) 134 if ((endpoint->bmAttributes & 3) != 3)
142 return -ENODEV; 135 return -ENODEV;
143 136
144 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 137 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
145 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); 138 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
146 139
147 if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) 140 if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL)))
148 return -ENOMEM; 141 return -ENOMEM;
149 memset(mouse, 0, sizeof(struct usb_mouse)); 142 memset(mouse, 0, sizeof(struct usb_mouse));
150 143
@@ -209,7 +202,7 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_
209static void usb_mouse_disconnect(struct usb_interface *intf) 202static void usb_mouse_disconnect(struct usb_interface *intf)
210{ 203{
211 struct usb_mouse *mouse = usb_get_intfdata (intf); 204 struct usb_mouse *mouse = usb_get_intfdata (intf);
212 205
213 usb_set_intfdata(intf, NULL); 206 usb_set_intfdata(intf, NULL);
214 if (mouse) { 207 if (mouse) {
215 usb_kill_urb(mouse->irq); 208 usb_kill_urb(mouse->irq);
@@ -238,7 +231,7 @@ static struct usb_driver usb_mouse_driver = {
238static int __init usb_mouse_init(void) 231static int __init usb_mouse_init(void)
239{ 232{
240 int retval = usb_register(&usb_mouse_driver); 233 int retval = usb_register(&usb_mouse_driver);
241 if (retval == 0) 234 if (retval == 0)
242 info(DRIVER_VERSION ":" DRIVER_DESC); 235 info(DRIVER_VERSION ":" DRIVER_DESC);
243 return retval; 236 return retval;
244} 237}