aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input/usbkbd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/input/usbkbd.c')
-rw-r--r--drivers/usb/input/usbkbd.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
index 7038fb9d1ced..f35db1974c42 100644
--- a/drivers/usb/input/usbkbd.c
+++ b/drivers/usb/input/usbkbd.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
@@ -72,7 +72,6 @@ struct usb_kbd {
72 unsigned char newleds; 72 unsigned char newleds;
73 char name[128]; 73 char name[128];
74 char phys[64]; 74 char phys[64];
75 int open;
76 75
77 unsigned char *new; 76 unsigned char *new;
78 struct usb_ctrlrequest *cr; 77 struct usb_ctrlrequest *cr;
@@ -166,7 +165,7 @@ static void usb_kbd_led(struct urb *urb, struct pt_regs *regs)
166 165
167 if (urb->status) 166 if (urb->status)
168 warn("led urb status %d received", urb->status); 167 warn("led urb status %d received", urb->status);
169 168
170 if (*(kbd->leds) == kbd->newleds) 169 if (*(kbd->leds) == kbd->newleds)
171 return; 170 return;
172 171
@@ -180,14 +179,9 @@ static int usb_kbd_open(struct input_dev *dev)
180{ 179{
181 struct usb_kbd *kbd = dev->private; 180 struct usb_kbd *kbd = dev->private;
182 181
183 if (kbd->open++)
184 return 0;
185
186 kbd->irq->dev = kbd->usbdev; 182 kbd->irq->dev = kbd->usbdev;
187 if (usb_submit_urb(kbd->irq, GFP_KERNEL)) { 183 if (usb_submit_urb(kbd->irq, GFP_KERNEL))
188 kbd->open--;
189 return -EIO; 184 return -EIO;
190 }
191 185
192 return 0; 186 return 0;
193} 187}
@@ -196,8 +190,7 @@ static void usb_kbd_close(struct input_dev *dev)
196{ 190{
197 struct usb_kbd *kbd = dev->private; 191 struct usb_kbd *kbd = dev->private;
198 192
199 if (!--kbd->open) 193 usb_kill_urb(kbd->irq);
200 usb_kill_urb(kbd->irq);
201} 194}
202 195
203static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd) 196static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd)
@@ -230,7 +223,7 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd)
230 usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma); 223 usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma);
231} 224}
232 225
233static int usb_kbd_probe(struct usb_interface *iface, 226static int usb_kbd_probe(struct usb_interface *iface,
234 const struct usb_device_id *id) 227 const struct usb_device_id *id)
235{ 228{
236 struct usb_device * dev = interface_to_usbdev(iface); 229 struct usb_device * dev = interface_to_usbdev(iface);
@@ -272,7 +265,7 @@ static int usb_kbd_probe(struct usb_interface *iface,
272 for (i = 0; i < 255; i++) 265 for (i = 0; i < 255; i++)
273 set_bit(usb_kbd_keycode[i], kbd->dev.keybit); 266 set_bit(usb_kbd_keycode[i], kbd->dev.keybit);
274 clear_bit(0, kbd->dev.keybit); 267 clear_bit(0, kbd->dev.keybit);
275 268
276 kbd->dev.private = kbd; 269 kbd->dev.private = kbd;
277 kbd->dev.event = usb_kbd_event; 270 kbd->dev.event = usb_kbd_event;
278 kbd->dev.open = usb_kbd_open; 271 kbd->dev.open = usb_kbd_open;
@@ -294,7 +287,7 @@ static int usb_kbd_probe(struct usb_interface *iface,
294 sprintf(kbd->phys, "%s/input0", path); 287 sprintf(kbd->phys, "%s/input0", path);
295 288
296 kbd->dev.name = kbd->name; 289 kbd->dev.name = kbd->name;
297 kbd->dev.phys = kbd->phys; 290 kbd->dev.phys = kbd->phys;
298 kbd->dev.id.bustype = BUS_USB; 291 kbd->dev.id.bustype = BUS_USB;
299 kbd->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor); 292 kbd->dev.id.vendor = le16_to_cpu(dev->descriptor.idVendor);
300 kbd->dev.id.product = le16_to_cpu(dev->descriptor.idProduct); 293 kbd->dev.id.product = le16_to_cpu(dev->descriptor.idProduct);
@@ -329,7 +322,7 @@ static int usb_kbd_probe(struct usb_interface *iface,
329static void usb_kbd_disconnect(struct usb_interface *intf) 322static void usb_kbd_disconnect(struct usb_interface *intf)
330{ 323{
331 struct usb_kbd *kbd = usb_get_intfdata (intf); 324 struct usb_kbd *kbd = usb_get_intfdata (intf);
332 325
333 usb_set_intfdata(intf, NULL); 326 usb_set_intfdata(intf, NULL);
334 if (kbd) { 327 if (kbd) {
335 usb_kill_urb(kbd->irq); 328 usb_kill_urb(kbd->irq);