- r = sd_device_monitor_filter_add_match_subsystem_devtype(monitor, subsystem, NULL);
- if (r < 0)
- return log_error_errno(r, "Failed to add %s subsystem match to monitor: %m", subsystem);
+ if (!subsystem) {
+ r = sd_device_get_subsystem(device, &subsystem);
+ if (r < 0 && r != -ENOENT)
+ return log_device_error_errno(device, r, "Failed to get subsystem: %m");
+ }
+
+ if (subsystem) {
+ r = sd_device_monitor_filter_add_match_subsystem_devtype(monitor, subsystem, NULL);
+ if (r < 0)
+ return log_error_errno(r, "Failed to add %s subsystem match to monitor: %m", subsystem);
+ }