MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / create_device_info_for_device

Function create_device_info_for_device

lib/hidapi/linux/hid.c:568–769  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

566
567
568static struct hid_device_info * create_device_info_for_device(struct udev_device *raw_dev)
569{
570 struct hid_device_info *root = NULL;
571 struct hid_device_info *cur_dev = NULL;
572
573 const char *sysfs_path;
574 const char *dev_path;
575 const char *str;
576 struct udev_device *hid_dev; /* The device's HID udev node. */
577 struct udev_device *usb_dev; /* The device's USB udev node. */
578 struct udev_device *intf_dev; /* The device's interface (in the USB sense). */
579 unsigned short dev_vid;
580 unsigned short dev_pid;
581 char *serial_number_utf8 = NULL;
582 char *product_name_utf8 = NULL;
583 unsigned bus_type;
584 int result;
585 struct hidraw_report_descriptor report_desc;
586
587 sysfs_path = udev_device_get_syspath(raw_dev);
588 dev_path = udev_device_get_devnode(raw_dev);
589
590 hid_dev = udev_device_get_parent_with_subsystem_devtype(
591 raw_dev,
592 "hid",
593 NULL);
594
595 if (!hid_dev) {
596 /* Unable to find parent hid device. */
597 goto end;
598 }
599
600 result = parse_uevent_info(
601 udev_device_get_sysattr_value(hid_dev, "uevent"),
602 &bus_type,
603 &dev_vid,
604 &dev_pid,
605 &serial_number_utf8,
606 &product_name_utf8);
607
608 if (!result) {
609 /* parse_uevent_info() failed for at least one field. */
610 goto end;
611 }
612
613 /* Filter out unhandled devices right away */
614 switch (bus_type) {
615 case BUS_BLUETOOTH:
616 case BUS_I2C:
617 case BUS_USB:
618 case BUS_SPI:
619 break;
620
621 default:
622 goto end;
623 }
624
625 /* Create the record. */

Callers 2

hid_enumerateFunction · 0.70

Calls 5

parse_uevent_infoFunction · 0.85
copy_udev_stringFunction · 0.85
get_next_hid_usageFunction · 0.85
utf8_to_wchar_tFunction · 0.70

Tested by

no test coverage detected