aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/usbhid/hiddev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/usbhid/hiddev.c')
-rw-r--r--drivers/hid/usbhid/hiddev.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 93dcb7e29102..e9b436d2d944 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -246,10 +246,12 @@ static int hiddev_release(struct inode * inode, struct file * file)
246 spin_unlock_irqrestore(&list->hiddev->list_lock, flags); 246 spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
247 247
248 if (!--list->hiddev->open) { 248 if (!--list->hiddev->open) {
249 if (list->hiddev->exist) 249 if (list->hiddev->exist) {
250 usbhid_close(list->hiddev->hid); 250 usbhid_close(list->hiddev->hid);
251 else 251 usbhid_put_power(list->hiddev->hid);
252 } else {
252 kfree(list->hiddev); 253 kfree(list->hiddev);
254 }
253 } 255 }
254 256
255 kfree(list); 257 kfree(list);
@@ -300,6 +302,17 @@ static int hiddev_open(struct inode *inode, struct file *file)
300 list_add_tail(&list->node, &hiddev_table[i]->list); 302 list_add_tail(&list->node, &hiddev_table[i]->list);
301 spin_unlock_irq(&list->hiddev->list_lock); 303 spin_unlock_irq(&list->hiddev->list_lock);
302 304
305 if (!list->hiddev->open++)
306 if (list->hiddev->exist) {
307 struct hid_device *hid = hiddev_table[i]->hid;
308 res = usbhid_get_power(hid);
309 if (res < 0) {
310 res = -EIO;
311 goto bail;
312 }
313 usbhid_open(hid);
314 }
315
303 return 0; 316 return 0;
304bail: 317bail:
305 file->private_data = NULL; 318 file->private_data = NULL;