Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 248536
b: refs/heads/master
c: 6cb4b04
h: refs/heads/master
v: v3
  • Loading branch information
Jiri Kosina committed May 20, 2011
1 parent 8daa35b commit 3788e0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 437f3b199c437e2a9ac01b9ab733c78e5fc7c720
refs/heads/master: 6cb4b040795c555c7ab4b1ba29b0dba2b5a42beb
10 changes: 8 additions & 2 deletions trunk/drivers/hid/usbhid/hiddev.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ static int hiddev_release(struct inode * inode, struct file * file)
list_del(&list->node);
spin_unlock_irqrestore(&list->hiddev->list_lock, flags);

mutex_lock(&list->hiddev->existancelock);
if (!--list->hiddev->open) {
if (list->hiddev->exist) {
usbhid_close(list->hiddev->hid);
Expand All @@ -252,6 +253,7 @@ static int hiddev_release(struct inode * inode, struct file * file)
}

kfree(list);
mutex_unlock(&list->hiddev->existancelock);

return 0;
}
Expand Down Expand Up @@ -300,17 +302,21 @@ static int hiddev_open(struct inode *inode, struct file *file)
list_add_tail(&list->node, &hiddev->list);
spin_unlock_irq(&list->hiddev->list_lock);

mutex_lock(&hiddev->existancelock);
if (!list->hiddev->open++)
if (list->hiddev->exist) {
struct hid_device *hid = hiddev->hid;
res = usbhid_get_power(hid);
if (res < 0) {
res = -EIO;
goto bail;
goto bail_unlock;
}
usbhid_open(hid);
}
mutex_unlock(&hiddev->existancelock);
return 0;
bail_unlock:
mutex_unlock(&hiddev->existancelock);
bail:
file->private_data = NULL;
kfree(list);
Expand Down Expand Up @@ -911,7 +917,6 @@ void hiddev_disconnect(struct hid_device *hid)

mutex_lock(&hiddev->existancelock);
hiddev->exist = 0;
mutex_unlock(&hiddev->existancelock);

usb_deregister_dev(usbhid->intf, &hiddev_class);

Expand All @@ -921,4 +926,5 @@ void hiddev_disconnect(struct hid_device *hid)
} else {
kfree(hiddev);
}
mutex_unlock(&hiddev->existancelock);
}

0 comments on commit 3788e0f

Please sign in to comment.