From: Lennart Poettering Date: Wed, 28 Apr 2021 07:51:55 +0000 (+0200) Subject: dissect-image: use sd_device_trigger() API X-Git-Tag: v249-rc1~334^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b64c4ece747a65e12f06311bb322f9e0f121a56a;p=thirdparty%2Fsystemd.git dissect-image: use sd_device_trigger() API Let's use the new API here too. --- diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 05301ef16d1..fe3186db990 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -432,7 +432,6 @@ static int device_wait_for_initialization_harder( usec_t deadline, sd_device **ret) { - _cleanup_free_ char *uevent = NULL; usec_t start, left, retrigger_timeout; int r; @@ -444,7 +443,8 @@ static int device_wait_for_initialization_harder( const char *sn = NULL; (void) sd_device_get_sysname(device, &sn); - log_debug("Waiting for device '%s' to initialize for %s.", strna(sn), format_timespan(buf, sizeof(buf), left, 0)); + log_device_debug(device, + "Waiting for device '%s' to initialize for %s.", strna(sn), format_timespan(buf, sizeof(buf), left, 0)); } if (left != USEC_INFINITY) @@ -475,33 +475,24 @@ static int device_wait_for_initialization_harder( const char *sn = NULL; (void) sd_device_get_sysname(device, &sn); - log_debug("Successfully waited for device '%s' to initialize for %s.", strna(sn), format_timespan(buf, sizeof(buf), usec_sub_unsigned(now(CLOCK_MONOTONIC), start), 0)); + log_device_debug(device, + "Successfully waited for device '%s' to initialize for %s.", + strna(sn), + format_timespan(buf, sizeof(buf), usec_sub_unsigned(now(CLOCK_MONOTONIC), start), 0)); } if (r != -ETIMEDOUT || last_try) return r; - if (!uevent) { - const char *syspath; - - r = sd_device_get_syspath(device, &syspath); - if (r < 0) - return r; - - uevent = path_join(syspath, "uevent"); - if (!uevent) - return -ENOMEM; - } - if (DEBUG_LOGGING) { char buf[FORMAT_TIMESPAN_MAX]; - log_debug("Device didn't initialize within %s, assuming lost event. Retriggering device through %s.", - format_timespan(buf, sizeof(buf), usec_sub_unsigned(now(CLOCK_MONOTONIC), start), 0), - uevent); + log_device_debug(device, + "Device didn't initialize within %s, assuming lost event. Retriggering device.", + format_timespan(buf, sizeof(buf), usec_sub_unsigned(now(CLOCK_MONOTONIC), start), 0)); } - r = write_string_file(uevent, "change", WRITE_STRING_FILE_DISABLE_BUFFER); + r = sd_device_trigger(device, SD_DEVICE_CHANGE); if (r < 0) return r; }