chiark / gitweb /
libudev: device - remove udev_device_get_parent_with_subsystem
[elogind.git] / extras / usb_id / usb_id.c
index 00d8a4c139e7353d37940ea092c3ec87c46fd602..9ee4e6ece34a248025f29e67e3225147d4bb7891 100644 (file)
@@ -54,28 +54,40 @@ static void set_usb_iftype(char *to, int if_class_num, size_t len)
        case 1:
                type = "audio";
                break;
+       case 2: /* CDC-Control */
+               break;
        case 3:
                type = "hid";
                break;
+       case 5: /* Physical */
+               break;
+       case 6:
+               type = "image";
+               break;
        case 7:
                type = "printer";
                break;
        case 8:
                type = "storage";
                break;
-       case 2: /* CDC-Control */
-       case 5: /* Physical */
-       case 6: /* Image */
-       case 9: /* HUB */
+       case 9:
+               type = "hub";
+               break;
        case 0x0a: /* CDC-Data */
+               break;
        case 0x0b: /* Chip/Smart Card */
+               break;
        case 0x0d: /* Content Security */
+               break;
        case 0x0e:
                type = "video";
                break;
        case 0xdc: /* Diagnostic Device */
+               break;
        case 0xe0: /* Wireless Controller */
-       case 0xf2: /* Application-specific */
+               break;
+       case 0xfe: /* Application-specific */
+               break;
        case 0xff: /* Vendor-specific */
                break;
        default:
@@ -180,7 +192,7 @@ static int usb_id(struct udev_device *dev)
        dbg(udev, "syspath %s\n", udev_device_get_syspath(dev));
 
        /* usb interface directory */
-       dev_interface = udev_device_get_parent_with_subsystem(dev, "usb");
+       dev_interface = udev_device_get_parent_with_subsystem_devtype(dev, "usb", NULL);
        if (dev_interface == NULL) {
                info(udev, "unable to access usb_interface device of '%s'\n",
                     udev_device_get_syspath(dev));
@@ -206,7 +218,7 @@ static int usb_id(struct udev_device *dev)
             udev_device_get_syspath(dev_interface), if_class_num, protocol);
 
        /* usb device directory */
-       dev_usb = udev_device_get_parent_with_subsystem(dev_interface, "usb");
+       dev_usb = udev_device_get_parent_with_subsystem_devtype(dev_interface, "usb", NULL);
        if (!dev_usb) {
                info(udev, "unable to find parent 'usb' device of '%s'\n",
                     udev_device_get_syspath(dev));
@@ -220,7 +232,7 @@ static int usb_id(struct udev_device *dev)
                int host, bus, target, lun;
 
                /* get scsi device */
-               dev_scsi = udev_device_get_parent_with_subsystem(dev, "scsi");
+               dev_scsi = udev_device_get_parent_with_subsystem_devtype(dev, "scsi", NULL);
                if (dev_scsi == NULL) {
                        info(udev, "unable to find parent 'scsi' device of '%s'\n",
                             udev_device_get_syspath(dev));
@@ -239,6 +251,7 @@ static int usb_id(struct udev_device *dev)
                        goto fallback;
                }
                udev_util_replace_whitespace(scsi_vendor, vendor_str, sizeof(vendor_str)-1);
+               udev_util_replace_chars(vendor_str, NULL);
 
                scsi_model = udev_device_get_sysattr_value(dev_scsi, "model");
                if (!scsi_model) {
@@ -247,6 +260,7 @@ static int usb_id(struct udev_device *dev)
                        goto fallback;
                }
                udev_util_replace_whitespace(scsi_model, model_str, sizeof(model_str)-1);
+               udev_util_replace_chars(model_str, NULL);
 
                scsi_type = udev_device_get_sysattr_value(dev_scsi, "type");
                if (!scsi_type) {
@@ -263,6 +277,7 @@ static int usb_id(struct udev_device *dev)
                        goto fallback;
                }
                udev_util_replace_whitespace(scsi_rev, revision_str, sizeof(revision_str)-1);
+               udev_util_replace_chars(revision_str, NULL);
 
                /*
                 * some broken devices have the same identifiers
@@ -287,6 +302,7 @@ fallback:
                        return 1;
                }
                udev_util_replace_whitespace(usb_vendor, vendor_str, sizeof(vendor_str)-1);
+               udev_util_replace_chars(vendor_str, NULL);
        }
 
        if (model_str[0] == '\0') {
@@ -303,22 +319,27 @@ fallback:
                        return 1;
                }
                udev_util_replace_whitespace(usb_model, model_str, sizeof(model_str)-1);
+               udev_util_replace_chars(model_str, NULL);
        }
 
        if (revision_str[0] == '\0') {
                const char *usb_rev;
 
                usb_rev = udev_device_get_sysattr_value(dev_usb, "bcdDevice");
-               if (usb_rev)
+               if (usb_rev) {
                        udev_util_replace_whitespace(usb_rev, revision_str, sizeof(revision_str)-1);
+                       udev_util_replace_chars(revision_str, NULL);
+               }
        }
 
        if (serial_str[0] == '\0') {
                const char *usb_serial;
 
                usb_serial = udev_device_get_sysattr_value(dev_usb, "serial");
-               if (usb_serial)
+               if (usb_serial) {
                        udev_util_replace_whitespace(usb_serial, serial_str, sizeof(serial_str)-1);
+                       udev_util_replace_chars(serial_str, NULL);
+               }
        }
        return 0;
 }