From: Hans de Goede Date: Fri, 5 Mar 2021 11:20:52 +0000 (+0100) Subject: ply-device-manager: add a verify_add_or_change() helper X-Git-Tag: 22.02.122~21^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc8dc20b2685d09c68b4f90a1a34f0f9cc024a74;p=thirdparty%2Fplymouth.git 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 --- 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); }