]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
ply-device-manager: add a verify_add_or_change() helper
authorHans de Goede <hdegoede@redhat.com>
Fri, 5 Mar 2021 11:20:52 +0000 (12:20 +0100)
committerHans de Goede <hdegoede@redhat.com>
Sat, 6 Mar 2021 09:57:05 +0000 (10:57 +0100)
Add a verify_add_or_change() helper function. This is a preparation
patch for coalescing multiple change events on the same card together
to speed up probing of the drm connectors.

Note this causes the action == "add" || action == "change" check to
be done twice. This double checking goes away in the next patch.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
src/libply-splash-core/ply-device-manager.c

index 9e6fb97c8a47d2ca04fffc080ecb5be0ff58e7ce..322a6f4e65297fa19b557ea1ed80d2d2d3f32361 100644 (file)
@@ -400,6 +400,32 @@ on_drm_udev_add_or_change (ply_device_manager_t *manager,
         }
 }
 
+static bool
+verify_add_or_change (ply_device_manager_t *manager,
+                      const char           *action,
+                      const char           *device_path,
+                      struct udev_device   *device)
+{
+        const char *subsystem = udev_device_get_subsystem (device);
+
+        if (strcmp (action, "add") && strcmp (action, "change"))
+                return false;
+
+        subsystem = udev_device_get_subsystem (device);
+
+        if (strcmp (subsystem, SUBSYSTEM_DRM) == 0) {
+                if (manager->local_console_managed && manager->local_console_is_text) {
+                        ply_trace ("ignoring since we're already using text splash for local console");
+                        return false;
+                }
+        } else {
+                ply_trace ("ignoring since we only handle subsystem %s devices after timeout", subsystem);
+                return false;
+        }
+
+        return true;
+}
+
 static void
 on_udev_event (ply_device_manager_t *manager)
 {
@@ -420,18 +446,8 @@ on_udev_event (ply_device_manager_t *manager)
         ply_trace ("got %s event for device %s", action, device_path);
 
         if (strcmp (action, "add") == 0 || strcmp (action, "change") == 0) {
-                const char *subsystem;
-
-                subsystem = udev_device_get_subsystem (device);
-
-                if (strcmp (subsystem, SUBSYSTEM_DRM) == 0) {
-                        if (manager->local_console_managed && manager->local_console_is_text)
-                                ply_trace ("ignoring since we're already using text splash for local console");
-                        else
-                                on_drm_udev_add_or_change (manager, action, device_path, device);
-                } else {
-                        ply_trace ("ignoring since we only handle subsystem %s devices after timeout", subsystem);
-                }
+                if (verify_add_or_change (manager, action, device_path, device))
+                        on_drm_udev_add_or_change (manager, action, device_path, device);
         } else if (strcmp (action, "remove") == 0) {
                 free_devices_from_device_path (manager, device_path, true);
         }