Lines Matching refs:hdev

1515 static bool hid_match_one_id(struct hid_device *hdev,  in hid_match_one_id()  argument
1518 return (id->bus == HID_BUS_ANY || id->bus == hdev->bus) && in hid_match_one_id()
1519 (id->group == HID_GROUP_ANY || id->group == hdev->group) && in hid_match_one_id()
1520 (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && in hid_match_one_id()
1521 (id->product == HID_ANY_ID || id->product == hdev->product); in hid_match_one_id()
1524 const struct hid_device_id *hid_match_id(struct hid_device *hdev, in hid_match_id() argument
1528 if (hid_match_one_id(hdev, id)) in hid_match_id()
1540 static bool hid_hiddev(struct hid_device *hdev) in hid_hiddev() argument
1542 return !!hid_match_id(hdev, hid_hiddev_list); in hid_hiddev()
1552 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in read_report_descriptor() local
1554 if (off >= hdev->rsize) in read_report_descriptor()
1557 if (off + count > hdev->rsize) in read_report_descriptor()
1558 count = hdev->rsize - off; in read_report_descriptor()
1560 memcpy(buf, hdev->rdesc + off, count); in read_report_descriptor()
1569 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in show_country() local
1571 return sprintf(buf, "%02x\n", hdev->country & 0xff); in show_country()
1585 int hid_connect(struct hid_device *hdev, unsigned int connect_mask) in hid_connect() argument
1597 if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE) in hid_connect()
1599 if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE) in hid_connect()
1601 if (hdev->bus != BUS_USB) in hid_connect()
1603 if (hid_hiddev(hdev)) in hid_connect()
1606 if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev, in hid_connect()
1608 hdev->claimed |= HID_CLAIMED_INPUT; in hid_connect()
1610 if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect && in hid_connect()
1611 !hdev->hiddev_connect(hdev, in hid_connect()
1613 hdev->claimed |= HID_CLAIMED_HIDDEV; in hid_connect()
1614 if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev)) in hid_connect()
1615 hdev->claimed |= HID_CLAIMED_HIDRAW; in hid_connect()
1618 hdev->claimed |= HID_CLAIMED_DRIVER; in hid_connect()
1622 if (!hdev->claimed && !hdev->driver->raw_event) { in hid_connect()
1623 hid_err(hdev, "device has no listeners, quitting\n"); in hid_connect()
1627 if ((hdev->claimed & HID_CLAIMED_INPUT) && in hid_connect()
1628 (connect_mask & HID_CONNECT_FF) && hdev->ff_init) in hid_connect()
1629 hdev->ff_init(hdev); in hid_connect()
1632 if (hdev->claimed & HID_CLAIMED_INPUT) in hid_connect()
1634 if (hdev->claimed & HID_CLAIMED_HIDDEV) in hid_connect()
1636 hdev->minor); in hid_connect()
1637 if (hdev->claimed & HID_CLAIMED_HIDRAW) in hid_connect()
1639 ((struct hidraw *)hdev->hidraw)->minor); in hid_connect()
1642 for (i = 0; i < hdev->maxcollection; i++) { in hid_connect()
1643 struct hid_collection *col = &hdev->collection[i]; in hid_connect()
1652 switch (hdev->bus) { in hid_connect()
1663 ret = device_create_file(&hdev->dev, &dev_attr_country); in hid_connect()
1665 hid_warn(hdev, in hid_connect()
1668 ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc); in hid_connect()
1670 hid_warn(hdev, in hid_connect()
1673 hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", in hid_connect()
1674 buf, bus, hdev->version >> 8, hdev->version & 0xff, in hid_connect()
1675 type, hdev->name, hdev->phys); in hid_connect()
1681 void hid_disconnect(struct hid_device *hdev) in hid_disconnect() argument
1683 device_remove_file(&hdev->dev, &dev_attr_country); in hid_disconnect()
1684 device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc); in hid_disconnect()
1685 if (hdev->claimed & HID_CLAIMED_INPUT) in hid_disconnect()
1686 hidinput_disconnect(hdev); in hid_disconnect()
1687 if (hdev->claimed & HID_CLAIMED_HIDDEV) in hid_disconnect()
1688 hdev->hiddev_disconnect(hdev); in hid_disconnect()
1689 if (hdev->claimed & HID_CLAIMED_HIDRAW) in hid_disconnect()
1690 hidraw_disconnect(hdev); in hid_disconnect()
1691 hdev->claimed = 0; in hid_disconnect()
2080 static const struct hid_device_id *hid_match_device(struct hid_device *hdev, in hid_match_device() argument
2087 if (hid_match_one_id(hdev, &dynid->id)) { in hid_match_device()
2094 return hid_match_id(hdev, hdrv->id_table); in hid_match_device()
2100 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in hid_bus_match() local
2102 return hid_match_device(hdev, hdrv) != NULL; in hid_bus_match()
2109 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in hid_device_probe() local
2113 if (down_interruptible(&hdev->driver_lock)) in hid_device_probe()
2115 if (down_interruptible(&hdev->driver_input_lock)) { in hid_device_probe()
2119 hdev->io_started = false; in hid_device_probe()
2121 if (!hdev->driver) { in hid_device_probe()
2122 id = hid_match_device(hdev, hdrv); in hid_device_probe()
2128 hdev->driver = hdrv; in hid_device_probe()
2130 ret = hdrv->probe(hdev, id); in hid_device_probe()
2132 ret = hid_open_report(hdev); in hid_device_probe()
2134 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); in hid_device_probe()
2137 hid_close_report(hdev); in hid_device_probe()
2138 hdev->driver = NULL; in hid_device_probe()
2142 if (!hdev->io_started) in hid_device_probe()
2143 up(&hdev->driver_input_lock); in hid_device_probe()
2145 up(&hdev->driver_lock); in hid_device_probe()
2151 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in hid_device_remove() local
2155 if (down_interruptible(&hdev->driver_lock)) in hid_device_remove()
2157 if (down_interruptible(&hdev->driver_input_lock)) { in hid_device_remove()
2161 hdev->io_started = false; in hid_device_remove()
2163 hdrv = hdev->driver; in hid_device_remove()
2166 hdrv->remove(hdev); in hid_device_remove()
2168 hid_hw_stop(hdev); in hid_device_remove()
2169 hid_close_report(hdev); in hid_device_remove()
2170 hdev->driver = NULL; in hid_device_remove()
2173 if (!hdev->io_started) in hid_device_remove()
2174 up(&hdev->driver_input_lock); in hid_device_remove()
2176 up(&hdev->driver_lock); in hid_device_remove()
2183 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in modalias_show() local
2187 hdev->bus, hdev->group, hdev->vendor, hdev->product); in modalias_show()
2201 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in hid_uevent() local
2204 hdev->bus, hdev->vendor, hdev->product)) in hid_uevent()
2207 if (add_uevent_var(env, "HID_NAME=%s", hdev->name)) in hid_uevent()
2210 if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys)) in hid_uevent()
2213 if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq)) in hid_uevent()
2217 hdev->bus, hdev->group, hdev->vendor, hdev->product)) in hid_uevent()
2479 bool hid_ignore(struct hid_device *hdev) in hid_ignore() argument
2481 if (hdev->quirks & HID_QUIRK_NO_IGNORE) in hid_ignore()
2483 if (hdev->quirks & HID_QUIRK_IGNORE) in hid_ignore()
2486 switch (hdev->vendor) { in hid_ignore()
2489 if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && in hid_ignore()
2490 hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) in hid_ignore()
2494 if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && in hid_ignore()
2495 hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) in hid_ignore()
2504 if (hdev->product == USB_DEVICE_ID_LOGITECH_AUDIOHUB && in hid_ignore()
2505 !strcmp(hdev->name, "HOLTEK B-LINK USB Audio ")) in hid_ignore()
2509 if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST && in hid_ignore()
2510 hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST) in hid_ignore()
2514 if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST && in hid_ignore()
2515 hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST) in hid_ignore()
2519 if (hdev->product == USB_DEVICE_ID_JESS_YUREX && in hid_ignore()
2520 hdev->type == HID_TYPE_USBNONE) in hid_ignore()
2525 if ((hdev->product >= USB_DEVICE_ID_VELLEMAN_K8055_FIRST && in hid_ignore()
2526 hdev->product <= USB_DEVICE_ID_VELLEMAN_K8055_LAST) || in hid_ignore()
2527 (hdev->product >= USB_DEVICE_ID_VELLEMAN_K8061_FIRST && in hid_ignore()
2528 hdev->product <= USB_DEVICE_ID_VELLEMAN_K8061_LAST)) in hid_ignore()
2538 if (hdev->product == USB_DEVICE_ID_ATMEL_V_USB && in hid_ignore()
2539 hdev->bus == BUS_USB && in hid_ignore()
2540 strncmp(hdev->name, "www.masterkit.ru MA901", 22) == 0) in hid_ignore()
2545 if (hdev->type == HID_TYPE_USBMOUSE && in hid_ignore()
2546 hid_match_id(hdev, hid_mouse_ignore_list)) in hid_ignore()
2549 return !!hid_match_id(hdev, hid_ignore_list); in hid_ignore()
2553 int hid_add_device(struct hid_device *hdev) in hid_add_device() argument
2558 if (WARN_ON(hdev->status & HID_STAT_ADDED)) in hid_add_device()
2563 if (hid_ignore(hdev)) in hid_add_device()
2569 if (!hdev->ll_driver->raw_request) { in hid_add_device()
2570 hid_err(hdev, "transport driver missing .raw_request()\n"); in hid_add_device()
2578 ret = hdev->ll_driver->parse(hdev); in hid_add_device()
2581 if (!hdev->dev_rdesc) in hid_add_device()
2588 hdev->group = HID_GROUP_GENERIC; in hid_add_device()
2589 } else if (!hdev->group && in hid_add_device()
2590 !hid_match_id(hdev, hid_have_special_driver)) { in hid_add_device()
2591 ret = hid_scan_report(hdev); in hid_add_device()
2593 hid_warn(hdev, "bad device descriptor (%d)\n", ret); in hid_add_device()
2598 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, in hid_add_device()
2599 hdev->vendor, hdev->product, atomic_inc_return(&id)); in hid_add_device()
2601 hid_debug_register(hdev, dev_name(&hdev->dev)); in hid_add_device()
2602 ret = device_add(&hdev->dev); in hid_add_device()
2604 hdev->status |= HID_STAT_ADDED; in hid_add_device()
2606 hid_debug_unregister(hdev); in hid_add_device()
2623 struct hid_device *hdev; in hid_allocate_device() local
2626 hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); in hid_allocate_device()
2627 if (hdev == NULL) in hid_allocate_device()
2630 device_initialize(&hdev->dev); in hid_allocate_device()
2631 hdev->dev.release = hid_device_release; in hid_allocate_device()
2632 hdev->dev.bus = &hid_bus_type; in hid_allocate_device()
2634 hid_close_report(hdev); in hid_allocate_device()
2636 init_waitqueue_head(&hdev->debug_wait); in hid_allocate_device()
2637 INIT_LIST_HEAD(&hdev->debug_list); in hid_allocate_device()
2638 spin_lock_init(&hdev->debug_list_lock); in hid_allocate_device()
2639 sema_init(&hdev->driver_lock, 1); in hid_allocate_device()
2640 sema_init(&hdev->driver_input_lock, 1); in hid_allocate_device()
2642 return hdev; in hid_allocate_device()
2646 static void hid_remove_device(struct hid_device *hdev) in hid_remove_device() argument
2648 if (hdev->status & HID_STAT_ADDED) { in hid_remove_device()
2649 device_del(&hdev->dev); in hid_remove_device()
2650 hid_debug_unregister(hdev); in hid_remove_device()
2651 hdev->status &= ~HID_STAT_ADDED; in hid_remove_device()
2653 kfree(hdev->dev_rdesc); in hid_remove_device()
2654 hdev->dev_rdesc = NULL; in hid_remove_device()
2655 hdev->dev_rsize = 0; in hid_remove_device()
2666 void hid_destroy_device(struct hid_device *hdev) in hid_destroy_device() argument
2668 hid_remove_device(hdev); in hid_destroy_device()
2669 put_device(&hdev->dev); in hid_destroy_device()