scsi_serial: convert from nanosleep() to usleep_safe()

This commit is contained in:
Lennart Poettering
2023-09-20 12:07:28 +02:00
parent b401efe5d2
commit 8fcacaf046
+2 -5
View File
@@ -793,14 +793,11 @@ int scsi_get_serial(struct scsi_id_device *dev_scsi, const char *devname,
memzero(dev_scsi->serial, len);
for (cnt = 20; cnt > 0; cnt--) {
struct timespec duration;
fd = open(devname, O_RDONLY | O_NONBLOCK | O_CLOEXEC | O_NOCTTY);
if (fd >= 0 || errno != EBUSY)
break;
duration.tv_sec = 0;
duration.tv_nsec = (200 * 1000 * 1000) + (random_u32() % 100 * 1000 * 1000);
nanosleep(&duration, NULL);
usleep_safe(200U*USEC_PER_MSEC + random_u64_range(100U*USEC_PER_MSEC));
}
if (fd < 0)
return 1;