Lines Matching refs:hiddev
44 struct hiddev *hiddev; member
143 struct hiddev *hiddev = hid->hiddev; in hiddev_send_event() local
147 spin_lock_irqsave(&hiddev->list_lock, flags); in hiddev_send_event()
148 list_for_each_entry(list, &hiddev->list, node) { in hiddev_send_event()
157 spin_unlock_irqrestore(&hiddev->list_lock, flags); in hiddev_send_event()
159 wake_up_interruptible(&hiddev->wait); in hiddev_send_event()
221 spin_lock_irqsave(&list->hiddev->list_lock, flags); in hiddev_release()
223 spin_unlock_irqrestore(&list->hiddev->list_lock, flags); in hiddev_release()
225 mutex_lock(&list->hiddev->existancelock); in hiddev_release()
226 if (!--list->hiddev->open) { in hiddev_release()
227 if (list->hiddev->exist) { in hiddev_release()
228 hid_hw_close(list->hiddev->hid); in hiddev_release()
229 hid_hw_power(list->hiddev->hid, PM_HINT_NORMAL); in hiddev_release()
231 mutex_unlock(&list->hiddev->existancelock); in hiddev_release()
232 kfree(list->hiddev); in hiddev_release()
238 mutex_unlock(&list->hiddev->existancelock); in hiddev_release()
244 static int __hiddev_open(struct hiddev *hiddev, struct file *file) in __hiddev_open() argument
249 lockdep_assert_held(&hiddev->existancelock); in __hiddev_open()
256 list->hiddev = hiddev; in __hiddev_open()
258 if (!hiddev->open++) { in __hiddev_open()
259 error = hid_hw_power(hiddev->hid, PM_HINT_FULLON); in __hiddev_open()
263 error = hid_hw_open(hiddev->hid); in __hiddev_open()
268 spin_lock_irq(&hiddev->list_lock); in __hiddev_open()
269 list_add_tail(&list->node, &hiddev->list); in __hiddev_open()
270 spin_unlock_irq(&hiddev->list_lock); in __hiddev_open()
277 hid_hw_power(hiddev->hid, PM_HINT_NORMAL); in __hiddev_open()
279 hiddev->open--; in __hiddev_open()
291 struct hiddev *hiddev; in hiddev_open() local
299 hiddev = hid->hiddev; in hiddev_open()
301 mutex_lock(&hiddev->existancelock); in hiddev_open()
302 res = hiddev->exist ? __hiddev_open(hiddev, file) : -ENODEV; in hiddev_open()
303 mutex_unlock(&hiddev->existancelock); in hiddev_open()
339 prepare_to_wait(&list->hiddev->wait, &wait, TASK_INTERRUPTIBLE); in hiddev_read()
346 if (!list->hiddev->exist) { in hiddev_read()
359 finish_wait(&list->hiddev->wait, &wait); in hiddev_read()
364 finish_wait(&list->hiddev->wait, &wait); in hiddev_read()
416 poll_wait(file, &list->hiddev->wait, wait); in hiddev_poll()
419 if (!list->hiddev->exist) in hiddev_poll()
427 static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd, void __user *user_a… in hiddev_ioctl_usage() argument
429 struct hid_device *hid = hiddev->hid; in hiddev_ioctl_usage()
566 static noinline int hiddev_ioctl_string(struct hiddev *hiddev, unsigned int cmd, void __user *user_… in hiddev_ioctl_string() argument
568 struct hid_device *hid = hiddev->hid; in hiddev_ioctl_string()
597 struct hiddev *hiddev = list->hiddev; in hiddev_ioctl() local
610 mutex_lock(&hiddev->existancelock); in hiddev_ioctl()
611 if (!hiddev->exist) { in hiddev_ioctl()
616 hid = hiddev->hid; in hiddev_ioctl()
685 r = hiddev_ioctl_string(hiddev, cmd, user_arg); in hiddev_ioctl()
690 hiddev->initialized = true; in hiddev_ioctl()
793 if (!hiddev->initialized) { in hiddev_ioctl()
795 hiddev->initialized = true; in hiddev_ioctl()
797 r = hiddev_ioctl_usage(hiddev, cmd, user_arg); in hiddev_ioctl()
843 mutex_unlock(&hiddev->existancelock); in hiddev_ioctl()
877 struct hiddev *hiddev; in hiddev_connect() local
893 if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL))) in hiddev_connect()
896 init_waitqueue_head(&hiddev->wait); in hiddev_connect()
897 INIT_LIST_HEAD(&hiddev->list); in hiddev_connect()
898 spin_lock_init(&hiddev->list_lock); in hiddev_connect()
899 mutex_init(&hiddev->existancelock); in hiddev_connect()
900 hid->hiddev = hiddev; in hiddev_connect()
901 hiddev->hid = hid; in hiddev_connect()
902 hiddev->exist = 1; in hiddev_connect()
906 hid->hiddev = NULL; in hiddev_connect()
907 kfree(hiddev); in hiddev_connect()
915 hiddev->initialized = hid->quirks & HID_QUIRK_NO_INIT_REPORTS; in hiddev_connect()
917 hiddev->minor = usbhid->intf->minor; in hiddev_connect()
929 struct hiddev *hiddev = hid->hiddev; in hiddev_disconnect() local
934 mutex_lock(&hiddev->existancelock); in hiddev_disconnect()
935 hiddev->exist = 0; in hiddev_disconnect()
937 if (hiddev->open) { in hiddev_disconnect()
938 hid_hw_close(hiddev->hid); in hiddev_disconnect()
939 wake_up_interruptible(&hiddev->wait); in hiddev_disconnect()
940 mutex_unlock(&hiddev->existancelock); in hiddev_disconnect()
942 mutex_unlock(&hiddev->existancelock); in hiddev_disconnect()
943 kfree(hiddev); in hiddev_disconnect()