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 /udev | |
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 'udev')
-rw-r--r-- | udev/udev-event.c | 7 | ||||
-rw-r--r-- | udev/udev-rules.c | 5 | ||||
-rw-r--r-- | udev/udevadm-settle.c | 4 |
3 files changed, 12 insertions, 4 deletions
diff --git a/udev/udev-event.c b/udev/udev-event.c index 3a6c71abe9..8183793e5f 100644 --- a/udev/udev-event.c +++ b/udev/udev-event.c @@ -23,9 +23,10 @@ #include <errno.h> #include <ctype.h> #include <string.h> +#include <time.h> +#include <net/if.h> #include <sys/ioctl.h> #include <sys/socket.h> -#include <net/if.h> #include <linux/sockios.h> #include "udev.h" @@ -505,6 +506,8 @@ static int rename_netif(struct udev_event *event) util_strscpy(ifr.ifr_newname, IFNAMSIZ, event->name); loop = 90 * 20; while (loop--) { + const struct timespec duration = { 0, 1000 * 1000 * 1000 / 20 }; + err = ioctl(sk, SIOCSIFNAME, &ifr); if (err == 0) { rename_netif_kernel_log(ifr); @@ -518,7 +521,7 @@ static int rename_netif(struct udev_event *event) } dbg(event->udev, "wait for netif '%s' to become free, loop=%i\n", event->name, (90 * 20) - loop); - usleep(1000 * 1000 / 20); + nanosleep(&duration, NULL); } } exit: diff --git a/udev/udev-rules.c b/udev/udev-rules.c index eeb71bc87b..a45a8138f5 100644 --- a/udev/udev-rules.c +++ b/udev/udev-rules.c @@ -27,6 +27,7 @@ #include <errno.h> #include <dirent.h> #include <fnmatch.h> +#include <time.h> #include "udev.h" @@ -814,6 +815,8 @@ static int wait_for_file(struct udev_device *dev, const char *file, int timeout) dbg(udev, "will wait %i sec for '%s'\n", timeout, file); while (--loop) { + const struct timespec duration = { 0, 1000 * 1000 * 1000 / WAIT_LOOP_PER_SECOND }; + /* lookup file */ if (stat(file, &stats) == 0) { info(udev, "file '%s' appeared after %i loops\n", file, (timeout * WAIT_LOOP_PER_SECOND) - loop-1); @@ -825,7 +828,7 @@ static int wait_for_file(struct udev_device *dev, const char *file, int timeout) return -2; } info(udev, "wait for '%s' for %i mseconds\n", file, 1000 / WAIT_LOOP_PER_SECOND); - usleep(1000 * 1000 / WAIT_LOOP_PER_SECOND); + nanosleep(&duration, NULL); } info(udev, "waiting for '%s' failed\n", file); return -1; diff --git a/udev/udevadm-settle.c b/udev/udevadm-settle.c index 682819201e..124c59698c 100644 --- a/udev/udevadm-settle.c +++ b/udev/udevadm-settle.c @@ -28,6 +28,7 @@ #include <syslog.h> #include <getopt.h> #include <signal.h> +#include <time.h> #include <sys/stat.h> #include <sys/types.h> @@ -180,6 +181,7 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[]) while (1) { struct stat statbuf; + const struct timespec duration = { 0 , 1000 * 1000 * 1000 / LOOP_PER_SECOND }; if (exists != NULL && stat(exists, &statbuf) == 0) { rc = 0; @@ -203,7 +205,7 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[]) if (is_timeout) break; - usleep(1000 * 1000 / LOOP_PER_SECOND); + nanosleep(&duration, NULL); } /* if we reached the timeout, print the list of remaining events */ |