Lines Matching refs:hdev
1538 static bool hid_match_one_id(struct hid_device *hdev, in hid_match_one_id() argument
1541 return (id->bus == HID_BUS_ANY || id->bus == hdev->bus) && in hid_match_one_id()
1542 (id->group == HID_GROUP_ANY || id->group == hdev->group) && in hid_match_one_id()
1543 (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && in hid_match_one_id()
1544 (id->product == HID_ANY_ID || id->product == hdev->product); in hid_match_one_id()
1547 const struct hid_device_id *hid_match_id(struct hid_device *hdev, in hid_match_id() argument
1551 if (hid_match_one_id(hdev, id)) in hid_match_id()
1563 static bool hid_hiddev(struct hid_device *hdev) in hid_hiddev() argument
1565 return !!hid_match_id(hdev, hid_hiddev_list); in hid_hiddev()
1575 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in read_report_descriptor() local
1577 if (off >= hdev->rsize) in read_report_descriptor()
1580 if (off + count > hdev->rsize) in read_report_descriptor()
1581 count = hdev->rsize - off; in read_report_descriptor()
1583 memcpy(buf, hdev->rdesc + off, count); in read_report_descriptor()
1592 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in show_country() local
1594 return sprintf(buf, "%02x\n", hdev->country & 0xff); in show_country()
1608 int hid_connect(struct hid_device *hdev, unsigned int connect_mask) in hid_connect() argument
1620 if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE) in hid_connect()
1622 if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE) in hid_connect()
1624 if (hdev->bus != BUS_USB) in hid_connect()
1626 if (hid_hiddev(hdev)) in hid_connect()
1629 if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev, in hid_connect()
1631 hdev->claimed |= HID_CLAIMED_INPUT; in hid_connect()
1633 if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect && in hid_connect()
1634 !hdev->hiddev_connect(hdev, in hid_connect()
1636 hdev->claimed |= HID_CLAIMED_HIDDEV; in hid_connect()
1637 if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev)) in hid_connect()
1638 hdev->claimed |= HID_CLAIMED_HIDRAW; in hid_connect()
1641 hdev->claimed |= HID_CLAIMED_DRIVER; in hid_connect()
1645 if (!hdev->claimed && !hdev->driver->raw_event) { in hid_connect()
1646 hid_err(hdev, "device has no listeners, quitting\n"); in hid_connect()
1650 if ((hdev->claimed & HID_CLAIMED_INPUT) && in hid_connect()
1651 (connect_mask & HID_CONNECT_FF) && hdev->ff_init) in hid_connect()
1652 hdev->ff_init(hdev); in hid_connect()
1655 if (hdev->claimed & HID_CLAIMED_INPUT) in hid_connect()
1657 if (hdev->claimed & HID_CLAIMED_HIDDEV) in hid_connect()
1659 hdev->minor); in hid_connect()
1660 if (hdev->claimed & HID_CLAIMED_HIDRAW) in hid_connect()
1662 ((struct hidraw *)hdev->hidraw)->minor); in hid_connect()
1665 for (i = 0; i < hdev->maxcollection; i++) { in hid_connect()
1666 struct hid_collection *col = &hdev->collection[i]; in hid_connect()
1675 switch (hdev->bus) { in hid_connect()
1689 ret = device_create_file(&hdev->dev, &dev_attr_country); in hid_connect()
1691 hid_warn(hdev, in hid_connect()
1694 ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc); in hid_connect()
1696 hid_warn(hdev, in hid_connect()
1699 hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", in hid_connect()
1700 buf, bus, hdev->version >> 8, hdev->version & 0xff, in hid_connect()
1701 type, hdev->name, hdev->phys); in hid_connect()
1707 void hid_disconnect(struct hid_device *hdev) in hid_disconnect() argument
1709 device_remove_file(&hdev->dev, &dev_attr_country); in hid_disconnect()
1710 device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc); in hid_disconnect()
1711 if (hdev->claimed & HID_CLAIMED_INPUT) in hid_disconnect()
1712 hidinput_disconnect(hdev); in hid_disconnect()
1713 if (hdev->claimed & HID_CLAIMED_HIDDEV) in hid_disconnect()
1714 hdev->hiddev_disconnect(hdev); in hid_disconnect()
1715 if (hdev->claimed & HID_CLAIMED_HIDRAW) in hid_disconnect()
1716 hidraw_disconnect(hdev); in hid_disconnect()
1717 hdev->claimed = 0; in hid_disconnect()
2123 static const struct hid_device_id *hid_match_device(struct hid_device *hdev, in hid_match_device() argument
2130 if (hid_match_one_id(hdev, &dynid->id)) { in hid_match_device()
2137 return hid_match_id(hdev, hdrv->id_table); in hid_match_device()
2143 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in hid_bus_match() local
2145 return hid_match_device(hdev, hdrv) != NULL; in hid_bus_match()
2152 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in hid_device_probe() local
2156 if (down_interruptible(&hdev->driver_lock)) in hid_device_probe()
2158 if (down_interruptible(&hdev->driver_input_lock)) { in hid_device_probe()
2162 hdev->io_started = false; in hid_device_probe()
2164 if (!hdev->driver) { in hid_device_probe()
2165 id = hid_match_device(hdev, hdrv); in hid_device_probe()
2171 hdev->driver = hdrv; in hid_device_probe()
2173 ret = hdrv->probe(hdev, id); in hid_device_probe()
2175 ret = hid_open_report(hdev); in hid_device_probe()
2177 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); in hid_device_probe()
2180 hid_close_report(hdev); in hid_device_probe()
2181 hdev->driver = NULL; in hid_device_probe()
2185 if (!hdev->io_started) in hid_device_probe()
2186 up(&hdev->driver_input_lock); in hid_device_probe()
2188 up(&hdev->driver_lock); in hid_device_probe()
2194 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in hid_device_remove() local
2198 if (down_interruptible(&hdev->driver_lock)) in hid_device_remove()
2200 if (down_interruptible(&hdev->driver_input_lock)) { in hid_device_remove()
2204 hdev->io_started = false; in hid_device_remove()
2206 hdrv = hdev->driver; in hid_device_remove()
2209 hdrv->remove(hdev); in hid_device_remove()
2211 hid_hw_stop(hdev); in hid_device_remove()
2212 hid_close_report(hdev); in hid_device_remove()
2213 hdev->driver = NULL; in hid_device_remove()
2216 if (!hdev->io_started) in hid_device_remove()
2217 up(&hdev->driver_input_lock); in hid_device_remove()
2219 up(&hdev->driver_lock); in hid_device_remove()
2226 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in modalias_show() local
2230 hdev->bus, hdev->group, hdev->vendor, hdev->product); in modalias_show()
2244 struct hid_device *hdev = container_of(dev, struct hid_device, dev); in hid_uevent() local
2247 hdev->bus, hdev->vendor, hdev->product)) in hid_uevent()
2250 if (add_uevent_var(env, "HID_NAME=%s", hdev->name)) in hid_uevent()
2253 if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys)) in hid_uevent()
2256 if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq)) in hid_uevent()
2260 hdev->bus, hdev->group, hdev->vendor, hdev->product)) in hid_uevent()
2511 bool hid_ignore(struct hid_device *hdev) in hid_ignore() argument
2513 if (hdev->quirks & HID_QUIRK_NO_IGNORE) in hid_ignore()
2515 if (hdev->quirks & HID_QUIRK_IGNORE) in hid_ignore()
2518 switch (hdev->vendor) { in hid_ignore()
2521 if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && in hid_ignore()
2522 hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) in hid_ignore()
2526 if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && in hid_ignore()
2527 hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) in hid_ignore()
2536 if (hdev->product == USB_DEVICE_ID_LOGITECH_AUDIOHUB && in hid_ignore()
2537 !strcmp(hdev->name, "HOLTEK B-LINK USB Audio ")) in hid_ignore()
2541 if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST && in hid_ignore()
2542 hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST) in hid_ignore()
2546 if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST && in hid_ignore()
2547 hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST) in hid_ignore()
2551 if (hdev->product == USB_DEVICE_ID_JESS_YUREX && in hid_ignore()
2552 hdev->type == HID_TYPE_USBNONE) in hid_ignore()
2557 if ((hdev->product >= USB_DEVICE_ID_VELLEMAN_K8055_FIRST && in hid_ignore()
2558 hdev->product <= USB_DEVICE_ID_VELLEMAN_K8055_LAST) || in hid_ignore()
2559 (hdev->product >= USB_DEVICE_ID_VELLEMAN_K8061_FIRST && in hid_ignore()
2560 hdev->product <= USB_DEVICE_ID_VELLEMAN_K8061_LAST)) in hid_ignore()
2570 if (hdev->product == USB_DEVICE_ID_ATMEL_V_USB && in hid_ignore()
2571 hdev->bus == BUS_USB && in hid_ignore()
2572 strncmp(hdev->name, "www.masterkit.ru MA901", 22) == 0) in hid_ignore()
2577 if (hdev->type == HID_TYPE_USBMOUSE && in hid_ignore()
2578 hid_match_id(hdev, hid_mouse_ignore_list)) in hid_ignore()
2581 return !!hid_match_id(hdev, hid_ignore_list); in hid_ignore()
2585 int hid_add_device(struct hid_device *hdev) in hid_add_device() argument
2590 if (WARN_ON(hdev->status & HID_STAT_ADDED)) in hid_add_device()
2595 if (hid_ignore(hdev)) in hid_add_device()
2601 if (!hdev->ll_driver->raw_request) { in hid_add_device()
2602 hid_err(hdev, "transport driver missing .raw_request()\n"); in hid_add_device()
2610 ret = hdev->ll_driver->parse(hdev); in hid_add_device()
2613 if (!hdev->dev_rdesc) in hid_add_device()
2620 hdev->group = HID_GROUP_GENERIC; in hid_add_device()
2621 } else if (!hdev->group && in hid_add_device()
2622 !hid_match_id(hdev, hid_have_special_driver)) { in hid_add_device()
2623 ret = hid_scan_report(hdev); in hid_add_device()
2625 hid_warn(hdev, "bad device descriptor (%d)\n", ret); in hid_add_device()
2630 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, in hid_add_device()
2631 hdev->vendor, hdev->product, atomic_inc_return(&id)); in hid_add_device()
2633 hid_debug_register(hdev, dev_name(&hdev->dev)); in hid_add_device()
2634 ret = device_add(&hdev->dev); in hid_add_device()
2636 hdev->status |= HID_STAT_ADDED; in hid_add_device()
2638 hid_debug_unregister(hdev); in hid_add_device()
2655 struct hid_device *hdev; in hid_allocate_device() local
2658 hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); in hid_allocate_device()
2659 if (hdev == NULL) in hid_allocate_device()
2662 device_initialize(&hdev->dev); in hid_allocate_device()
2663 hdev->dev.release = hid_device_release; in hid_allocate_device()
2664 hdev->dev.bus = &hid_bus_type; in hid_allocate_device()
2666 hid_close_report(hdev); in hid_allocate_device()
2668 init_waitqueue_head(&hdev->debug_wait); in hid_allocate_device()
2669 INIT_LIST_HEAD(&hdev->debug_list); in hid_allocate_device()
2670 spin_lock_init(&hdev->debug_list_lock); in hid_allocate_device()
2671 sema_init(&hdev->driver_lock, 1); in hid_allocate_device()
2672 sema_init(&hdev->driver_input_lock, 1); in hid_allocate_device()
2674 return hdev; in hid_allocate_device()
2678 static void hid_remove_device(struct hid_device *hdev) in hid_remove_device() argument
2680 if (hdev->status & HID_STAT_ADDED) { in hid_remove_device()
2681 device_del(&hdev->dev); in hid_remove_device()
2682 hid_debug_unregister(hdev); in hid_remove_device()
2683 hdev->status &= ~HID_STAT_ADDED; in hid_remove_device()
2685 kfree(hdev->dev_rdesc); in hid_remove_device()
2686 hdev->dev_rdesc = NULL; in hid_remove_device()
2687 hdev->dev_rsize = 0; in hid_remove_device()
2698 void hid_destroy_device(struct hid_device *hdev) in hid_destroy_device() argument
2700 hid_remove_device(hdev); in hid_destroy_device()
2701 put_device(&hdev->dev); in hid_destroy_device()