Lines Matching refs:device

21 #include "sd-device.h"
24 #include "device-enumerator-private.h"
25 #include "device-util.h"
89 sd_device *device;
91 while ((device = prioq_pop(enumerator->devices)))
92 sd_device_unref(device);
288 /* For sound cards the control device must be enumerated last to
289 * make sure it's the final device node that gets ACLs applied.
328 int device_enumerator_add_device(sd_device_enumerator *enumerator, sd_device *device) {
332 assert_return(device, -EINVAL);
338 r = prioq_put(enumerator->devices, device, NULL);
342 sd_device_ref(device);
347 static bool match_sysattr_value(sd_device *device, const char *sysattr, const char *match_value) {
351 assert(device);
354 r = sd_device_get_sysattr_value(device, sysattr, &value);
367 static bool match_sysattr(sd_device_enumerator *enumerator, sd_device *device) {
373 assert(device);
376 if (match_sysattr_value(device, sysattr, value))
380 if (!match_sysattr_value(device, sysattr, value))
386 static bool match_property(sd_device_enumerator *enumerator, sd_device *device) {
392 assert(device);
400 FOREACH_DEVICE_PROPERTY(device, property_dev, value_dev) {
418 static bool match_tag(sd_device_enumerator *enumerator, sd_device *device) {
423 assert(device);
426 if (!sd_device_has_tag(device, tag))
432 static bool match_parent(sd_device_enumerator *enumerator, sd_device *device) {
437 assert(device);
445 r = sd_device_get_devpath(device, &devpath_dev);
490 _cleanup_(sd_device_unrefp) sd_device *device = NULL;
503 k = sd_device_new_from_syspath(&device, syspath);
512 k = sd_device_get_devnum(device, &devnum);
518 k = sd_device_get_ifindex(device, &ifindex);
524 k = sd_device_get_is_initialized(device, &initialized);
531 * All devices with a device node or network interfaces
532 * possibly need udev to adjust the device node permission
545 if (!match_parent(enumerator, device))
548 if (!match_tag(enumerator, device))
551 if (!match_property(enumerator, device))
554 if (!match_sysattr(enumerator, device))
557 k = device_enumerator_add_device(enumerator, device);
600 log_debug(" device-enumerator: scanning %s", path);
635 log_error("sd-device-enumerator: could not open tags directory %s: %m", path);
643 _cleanup_(sd_device_unrefp) sd_device *device = NULL;
650 k = sd_device_new_from_device_id(&device, dent->d_name);
659 k = sd_device_get_subsystem(device, &subsystem);
668 k = sd_device_get_sysname(device, &sysname);
677 if (!match_parent(enumerator, device))
680 if (!match_property(enumerator, device))
683 if (!match_sysattr(enumerator, device))
686 k = device_enumerator_add_device(enumerator, device);
713 _cleanup_(sd_device_unrefp) sd_device *device = NULL;
717 r = sd_device_new_from_syspath(&device, path);
724 r = sd_device_get_subsystem(device, &subsystem);
733 r = sd_device_get_sysname(device, &sysname);
740 if (!match_property(enumerator, device))
743 if (!match_sysattr(enumerator, device))
746 r = device_enumerator_add_device(enumerator, device);
760 log_debug("sd-device-enumerate: could not open parent directory %s: %m", path);
785 log_debug("device-enumerate: max depth reached, %s: ignoring devices", child);
813 log_debug("device-enumerator: scan all dirs");
819 return log_debug_errno(r, "device-enumerator: failed to scan /sys/subsystem: %m");
825 log_debug_errno(k, "device-enumerator: failed to scan /sys/bus: %m");
831 log_debug_errno(k, "device-enumerator: failed to scan /sys/class: %m");
840 sd_device *device;
849 while ((device = prioq_pop(enumerator->devices)))
850 sd_device_unref(device);
898 sd_device *device;
908 while ((device = prioq_pop(enumerator->devices)))
909 sd_device_unref(device);
915 log_debug_errno(k, "device-enumerator: failed to scan modules: %m");
929 log_debug_errno(k, "device-enumerator: failed to scan subsystems: %m");
938 log_debug_errno(k, "device-enumerator: failed to scan drivers: %m");