static int udev_builtin_hwdb_search(struct udev_device *dev, struct udev_device *srcdev, const char *subsystem, const char *prefix, const char *filter, bool test) { struct udev_device *d; char s[16]; bool last = false; int r = 0; assert(dev); if (!srcdev) srcdev = dev; for (d = srcdev; d && !last; d = udev_device_get_parent(d)) { const char *dsubsys; const char *modalias = NULL; dsubsys = udev_device_get_subsystem(d); if (!dsubsys) continue; /* look only at devices of a specific subsystem */ if (subsystem && !streq(dsubsys, subsystem)) continue; modalias = udev_device_get_property_value(d, "MODALIAS"); if (streq(dsubsys, "usb") && streq_ptr(udev_device_get_devtype(d), "usb_device")) { /* if the usb_device does not have a modalias, compose one */ if (!modalias) modalias = modalias_usb(d, s, sizeof(s)); /* avoid looking at any parent device, they are usually just a USB hub */ last = true; } if (!modalias) continue; r = udev_builtin_hwdb_lookup(dev, prefix, modalias, filter, test); if (r > 0) break; } return r; }
static int udev_builtin_hwdb_search(struct udev_device *dev, struct udev_device *srcdev, const char *subsystem, const char *prefix, const char *filter, bool test) { struct udev_device *d; char s[16]; int n = 0; for (d = srcdev; d; d = udev_device_get_parent(d)) { const char *dsubsys; const char *modalias = NULL; dsubsys = udev_device_get_subsystem(d); if (!dsubsys) continue; /* look only at devices of a specific subsystem */ if (subsystem && !streq(dsubsys, subsystem)) continue; /* the usb_device does not have a modalias, compose one */ if (streq(dsubsys, "usb")) modalias = modalias_usb(d, s, sizeof(s)); if (!modalias) modalias = udev_device_get_property_value(d, "MODALIAS"); if (!modalias) continue; n = udev_builtin_hwdb_lookup(dev, prefix, modalias, filter, test); if (n > 0) break; } return n; }