Lines Matching defs:hdev

2098 bool hid_match_one_id(const struct hid_device *hdev,
2101 return (id->bus == HID_BUS_ANY || id->bus == hdev->bus) &&
2102 (id->group == HID_GROUP_ANY || id->group == hdev->group) &&
2103 (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) &&
2104 (id->product == HID_ANY_ID || id->product == hdev->product);
2107 const struct hid_device_id *hid_match_id(const struct hid_device *hdev,
2111 if (hid_match_one_id(hdev, id))
2124 static bool hid_hiddev(struct hid_device *hdev)
2126 return !!hid_match_id(hdev, hid_hiddev_list);
2136 struct hid_device *hdev = to_hid_device(dev);
2138 if (off >= hdev->rsize)
2141 if (off + count > hdev->rsize)
2142 count = hdev->rsize - off;
2144 memcpy(buf, hdev->rdesc + off, count);
2153 struct hid_device *hdev = to_hid_device(dev);
2155 return sprintf(buf, "%02x\n", hdev->country & 0xff);
2169 int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
2181 ret = hid_bpf_connect_device(hdev);
2185 if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE)
2187 if (hdev->quirks & HID_QUIRK_HIDINPUT_FORCE)
2189 if (hdev->bus != BUS_USB)
2191 if (hid_hiddev(hdev))
2194 if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev,
2196 hdev->claimed |= HID_CLAIMED_INPUT;
2198 if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect &&
2199 !hdev->hiddev_connect(hdev,
2201 hdev->claimed |= HID_CLAIMED_HIDDEV;
2202 if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev))
2203 hdev->claimed |= HID_CLAIMED_HIDRAW;
2206 hdev->claimed |= HID_CLAIMED_DRIVER;
2210 if (!hdev->claimed && !hdev->driver->raw_event) {
2211 hid_err(hdev, "device has no listeners, quitting\n");
2215 hid_process_ordering(hdev);
2217 if ((hdev->claimed & HID_CLAIMED_INPUT) &&
2218 (connect_mask & HID_CONNECT_FF) && hdev->ff_init)
2219 hdev->ff_init(hdev);
2222 if (hdev->claimed & HID_CLAIMED_INPUT)
2224 if (hdev->claimed & HID_CLAIMED_HIDDEV)
2226 ((struct hiddev *)hdev->hiddev)->minor);
2227 if (hdev->claimed & HID_CLAIMED_HIDRAW)
2229 ((struct hidraw *)hdev->hidraw)->minor);
2232 for (i = 0; i < hdev->maxcollection; i++) {
2233 struct hid_collection *col = &hdev->collection[i];
2242 switch (hdev->bus) {
2263 ret = device_create_file(&hdev->dev, &dev_attr_country);
2265 hid_warn(hdev,
2268 hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
2269 buf, bus, hdev->version >> 8, hdev->version & 0xff,
2270 type, hdev->name, hdev->phys);
2276 void hid_disconnect(struct hid_device *hdev)
2278 device_remove_file(&hdev->dev, &dev_attr_country);
2279 if (hdev->claimed & HID_CLAIMED_INPUT)
2280 hidinput_disconnect(hdev);
2281 if (hdev->claimed & HID_CLAIMED_HIDDEV)
2282 hdev->hiddev_disconnect(hdev);
2283 if (hdev->claimed & HID_CLAIMED_HIDRAW)
2284 hidraw_disconnect(hdev);
2285 hdev->claimed = 0;
2287 hid_bpf_disconnect_device(hdev);
2293 * @hdev: hid device
2300 int hid_hw_start(struct hid_device *hdev, unsigned int connect_mask)
2304 error = hdev->ll_driver->start(hdev);
2309 error = hid_connect(hdev, connect_mask);
2311 hdev->ll_driver->stop(hdev);
2322 * @hdev: hid device
2327 void hid_hw_stop(struct hid_device *hdev)
2329 hid_disconnect(hdev);
2330 hdev->ll_driver->stop(hdev);
2336 * @hdev: hid device
2342 int hid_hw_open(struct hid_device *hdev)
2346 ret = mutex_lock_killable(&hdev->ll_open_lock);
2350 if (!hdev->ll_open_count++) {
2351 ret = hdev->ll_driver->open(hdev);
2353 hdev->ll_open_count--;
2356 mutex_unlock(&hdev->ll_open_lock);
2364 * @hdev: hid device
2370 void hid_hw_close(struct hid_device *hdev)
2372 mutex_lock(&hdev->ll_open_lock);
2373 if (!--hdev->ll_open_count)
2374 hdev->ll_driver->close(hdev);
2375 mutex_unlock(&hdev->ll_open_lock);
2382 * @hdev: hid device
2386 void hid_hw_request(struct hid_device *hdev,
2389 if (hdev->ll_driver->request)
2390 return hdev->ll_driver->request(hdev, report, reqtype);
2392 __hid_request(hdev, report, reqtype);
2399 * @hdev: hid device
2410 int hid_hw_raw_request(struct hid_device *hdev,
2416 if (hdev->ll_driver->max_buffer_size)
2417 max_buffer_size = hdev->ll_driver->max_buffer_size;
2422 return hdev->ll_driver->raw_request(hdev, reportnum, buf, len,
2430 * @hdev: hid device
2436 int hid_hw_output_report(struct hid_device *hdev, __u8 *buf, size_t len)
2440 if (hdev->ll_driver->max_buffer_size)
2441 max_buffer_size = hdev->ll_driver->max_buffer_size;
2446 if (hdev->ll_driver->output_report)
2447 return hdev->ll_driver->output_report(hdev, buf, len);
2454 int hid_driver_suspend(struct hid_device *hdev, pm_message_t state)
2456 if (hdev->driver && hdev->driver->suspend)
2457 return hdev->driver->suspend(hdev, state);
2463 int hid_driver_reset_resume(struct hid_device *hdev)
2465 if (hdev->driver && hdev->driver->reset_resume)
2466 return hdev->driver->reset_resume(hdev);
2472 int hid_driver_resume(struct hid_device *hdev)
2474 if (hdev->driver && hdev->driver->resume)
2475 return hdev->driver->resume(hdev);
2548 const struct hid_device_id *hid_match_device(struct hid_device *hdev,
2555 if (hid_match_one_id(hdev, &dynid->id)) {
2562 return hid_match_id(hdev, hdrv->id_table);
2569 struct hid_device *hdev = to_hid_device(dev);
2571 return hid_match_device(hdev, hdrv) != NULL;
2597 static bool hid_check_device_match(struct hid_device *hdev,
2601 *id = hid_match_device(hdev, hdrv);
2606 return hdrv->match(hdev, hid_ignore_special_drivers);
2616 static int __hid_device_probe(struct hid_device *hdev, struct hid_driver *hdrv)
2621 if (!hid_check_device_match(hdev, hdrv, &id))
2624 hdev->devres_group_id = devres_open_group(&hdev->dev, NULL, GFP_KERNEL);
2625 if (!hdev->devres_group_id)
2629 hdev->quirks = hid_lookup_quirk(hdev);
2630 hdev->driver = hdrv;
2633 ret = hdrv->probe(hdev, id);
2635 ret = hid_open_report(hdev);
2637 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
2649 devres_release_group(&hdev->dev, hdev->devres_group_id);
2650 hid_close_report(hdev);
2651 hdev->driver = NULL;
2659 struct hid_device *hdev = to_hid_device(dev);
2663 if (down_interruptible(&hdev->driver_input_lock))
2666 hdev->io_started = false;
2667 clear_bit(ffs(HID_STAT_REPROBED), &hdev->status);
2669 if (!hdev->driver)
2670 ret = __hid_device_probe(hdev, hdrv);
2672 if (!hdev->io_started)
2673 up(&hdev->driver_input_lock);
2680 struct hid_device *hdev = to_hid_device(dev);
2683 down(&hdev->driver_input_lock);
2684 hdev->io_started = false;
2686 hdrv = hdev->driver;
2689 hdrv->remove(hdev);
2691 hid_hw_stop(hdev);
2694 devres_release_group(&hdev->dev, hdev->devres_group_id);
2696 hid_close_report(hdev);
2697 hdev->driver = NULL;
2700 if (!hdev->io_started)
2701 up(&hdev->driver_input_lock);
2707 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
2710 hdev->bus, hdev->group, hdev->vendor, hdev->product);
2730 const struct hid_device *hdev = to_hid_device(dev);
2733 hdev->bus, hdev->vendor, hdev->product))
2736 if (add_uevent_var(env, "HID_NAME=%s", hdev->name))
2739 if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys))
2742 if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq))
2746 hdev->bus, hdev->group, hdev->vendor, hdev->product))
2763 int hid_add_device(struct hid_device *hdev)
2768 if (WARN_ON(hdev->status & HID_STAT_ADDED))
2771 hdev->quirks = hid_lookup_quirk(hdev);
2775 if (hid_ignore(hdev))
2781 if (!hdev->ll_driver->raw_request) {
2782 hid_err(hdev, "transport driver missing .raw_request()\n");
2790 ret = hdev->ll_driver->parse(hdev);
2793 if (!hdev->dev_rdesc)
2800 hdev->group = HID_GROUP_GENERIC;
2801 } else if (!hdev->group &&
2802 !(hdev->quirks & HID_QUIRK_HAVE_SPECIAL_DRIVER)) {
2803 ret = hid_scan_report(hdev);
2805 hid_warn(hdev, "bad device descriptor (%d)\n", ret);
2808 hdev->id = atomic_inc_return(&id);
2812 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
2813 hdev->vendor, hdev->product, hdev->id);
2815 hid_debug_register(hdev, dev_name(&hdev->dev));
2816 ret = device_add(&hdev->dev);
2818 hdev->status |= HID_STAT_ADDED;
2820 hid_debug_unregister(hdev);
2837 struct hid_device *hdev;
2840 hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
2841 if (hdev == NULL)
2844 device_initialize(&hdev->dev);
2845 hdev->dev.release = hid_device_release;
2846 hdev->dev.bus = &hid_bus_type;
2847 device_enable_async_suspend(&hdev->dev);
2849 hid_close_report(hdev);
2851 init_waitqueue_head(&hdev->debug_wait);
2852 INIT_LIST_HEAD(&hdev->debug_list);
2853 spin_lock_init(&hdev->debug_list_lock);
2854 sema_init(&hdev->driver_input_lock, 1);
2855 mutex_init(&hdev->ll_open_lock);
2856 kref_init(&hdev->ref);
2858 hid_bpf_device_init(hdev);
2860 return hdev;
2864 static void hid_remove_device(struct hid_device *hdev)
2866 if (hdev->status & HID_STAT_ADDED) {
2867 device_del(&hdev->dev);
2868 hid_debug_unregister(hdev);
2869 hdev->status &= ~HID_STAT_ADDED;
2871 kfree(hdev->dev_rdesc);
2872 hdev->dev_rdesc = NULL;
2873 hdev->dev_rsize = 0;
2879 * @hdev: hid device
2884 void hid_destroy_device(struct hid_device *hdev)
2886 hid_bpf_destroy_device(hdev);
2887 hid_remove_device(hdev);
2888 put_device(&hdev->dev);
2896 struct hid_device *hdev = to_hid_device(dev);
2898 if (hdev->driver == hdrv &&
2899 !hdrv->match(hdev, hid_ignore_special_drivers) &&
2900 !test_and_set_bit(ffs(HID_STAT_REPROBED), &hdev->status))