diff options
author | Daniel Mierswa <impulze@impulze.org> | 2009-08-30 23:58:57 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-08-30 23:58:57 +0200 |
commit | 959e8b5decb32fda0a8c8be21aff8bc17382586d (patch) | |
tree | 25b419d0fab9c616e52a3552f8bc8e3644ab637b /extras/scsi_id | |
parent | c45e22151313878dcce33c788f9eebbd93842008 (diff) |
use nanosleep() instead of usleep()
POSIX.1-2001 declares usleep() function obsolete and POSIX.1-2008
removes it.
[Kay Sievers]
- include time.h
- use const for timespec
- scsi_id: drop rand() in retry loop
- modem-probe: rename msuspend() to msleep()
Diffstat (limited to 'extras/scsi_id')
-rw-r--r-- | extras/scsi_id/scsi_serial.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/extras/scsi_id/scsi_serial.c b/extras/scsi_id/scsi_serial.c index 0f883dc02f..2e9168f941 100644 --- a/extras/scsi_id/scsi_serial.c +++ b/extras/scsi_id/scsi_serial.c @@ -23,6 +23,7 @@ #include <stdlib.h> #include <unistd.h> #include <syslog.h> +#include <time.h> #include <inttypes.h> #include <scsi/scsi.h> #include <scsi/sg.h> @@ -846,13 +847,15 @@ int scsi_get_serial(struct udev *udev, memset(dev_scsi->serial, 0, len); dbg(udev, "opening %s\n", devname); while (--cnt) { + const struct timespec duration = { 0, 500 * 1000 * 1000 }; + fd = open(devname, O_RDONLY | O_NONBLOCK); if (fd >= 0) break; info(udev, "%s: cannot open %s: %s\n", dev_scsi->kernel, devname, strerror(errno)); if (errno != EBUSY) break; - usleep(500000 + (rand() % 100000) ); + nanosleep(&duration, NULL); } if (fd < 0) return 1; |