diff options
author | Hans de Goede <hdegoede@redhat.com> | 2021-03-05 12:20:52 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2021-03-06 10:57:05 +0100 |
commit | dc8dc20b2685d09c68b4f90a1a34f0f9cc024a74 (patch) | |
tree | 6c432a1e02257985b07861eb4f365017f745f1ea /src/libply-splash-core | |
parent | a649b551084e66282693065ef84b5cb640d24f38 (diff) |
ply-device-manager: add a verify_add_or_change() helper
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>
Diffstat (limited to 'src/libply-splash-core')
-rw-r--r-- | src/libply-splash-core/ply-device-manager.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c index 9e6fb97c..322a6f4e 100644 --- a/src/libply-splash-core/ply-device-manager.c +++ b/src/libply-splash-core/ply-device-manager.c @@ -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); } |