POSIX.1-2001 declares usleep() function obsolete and POSIX.1-2008 removes it. Converted the calls to nanosleep(). Signed-off-by: Daniel Mierswa <impulze@xxxxxxxxxxx> --- extras/modem-modeswitch/ma8280p_us.c | 335 +++++++++++++++++----------------- extras/scsi_id/scsi_serial.c | 8 +- udev/udev-event.c | 9 +- udev/udev-rules.c | 9 +- udev/udevadm-settle.c | 8 +- 5 files changed, 202 insertions(+), 167 deletions(-)
diff --git a/extras/modem-modeswitch/ma8280p_us.c b/extras/modem-modeswitch/ma8280p_us.c index 13d1116..7069ccb 100644 --- a/extras/modem-modeswitch/ma8280p_us.c +++ b/extras/modem-modeswitch/ma8280p_us.c @@ -88,10 +88,19 @@ #include <signal.h> #include <ctype.h> #include <usb.h> +#include <time.h> /* nanosleep() */ #include "utils.h" #include "ma8280p_us.h" +int nsleep(useconds_t usec) +{ + struct timespec time; + time.tv_sec = usec / 1000000; + time.tv_nsec = (usec - (time.tv_sec * 1000000)) * 1000; + return nanosleep(&time, NULL); +} + int ma8280p_switch (struct usb_dev_handle *devh, struct usb_device *dev) { int ret = 1; @@ -104,11 +113,11 @@ int ma8280p_switch (struct usb_dev_handle *devh, struct usb_device *dev) } ret = usb_get_descriptor(devh, 0x0000001, 0x0000000, buf, 0x0000012); - usleep(6*1000); + nsleep(6*1000); ret = usb_get_descriptor(devh, 0x0000001, 0x0000000, buf, 0x0000012); - usleep(6*1000); + nsleep(6*1000); ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000400); - usleep(10*1000); + nsleep(10*1000); ret = usb_release_interface(devh, 0); if (ret != 0) debug ("%s: failed to release interface before set_configuration: %d", dev->filename, ret); @@ -117,335 +126,335 @@ int ma8280p_switch (struct usb_dev_handle *devh, struct usb_device *dev) if (ret != 0) debug ("%s: claim after set_configuration failed with error %d", dev->filename, ret); //ret = usb_set_altinterface(devh, 0); - //usleep(33*1000); + //nsleep(33*1000); ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE + USB_ENDPOINT_IN, 0x0000001, 0x0000300, 0x0000000, buf, 0x0000008, 1000); - usleep(5*1000); + nsleep(5*1000); memcpy(buf, "\xb0\x04\x00\x00\x02\x90\x26\x86", 0x0000008); ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x0000009, 0x0000300, 0x0000000, buf, 0x0000008, 1000); - usleep(4*1000); + nsleep(4*1000); memcpy(buf, "\xb0\x04\x00\x00\x02\x90\x26\x86", 0x0000008); ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x0000009, 0x0000300, 0x0000000, buf, 0x0000008, 1000); - usleep(4*1000); + nsleep(4*1000); - usleep(4*1000); + nsleep(4*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(6*1000); + nsleep(6*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + nsleep(1*1000); //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT skipped - usleep(4*1000); + nsleep(4*1000); memcpy(buf, "\x37\x01\xfe\xdb\xc1\x33\x1f\x83", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(3*1000); + nsleep(3*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + nsleep(1*1000); memcpy(buf, "\x37\x0e\xb5\x9d\x3b\x8a\x91\x51", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(7*1000); + nsleep(7*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + nsleep(1*1000); memcpy(buf, "\x34\x87\xba\x0d\xfc\x8a\x91\x51", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(7*1000); + nsleep(7*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(2*1000); + nsleep(2*1000); //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT skipped - usleep(4*1000); + nsleep(4*1000); memcpy(buf, "\x37\x01\xfe\xdb\xc1\x33\x1f\x83", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(2*1000); + nsleep(2*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + nsleep(1*1000); memcpy(buf, "\x37\x0e\xb5\x9d\x3b\x8a\x91\x51", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(7*1000); + nsleep(7*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + nsleep(1*1000); memcpy(buf, "\x34\x87\xba\x0d\xfc\x8a\x91\x51", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(7*1000); + nsleep(7*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(8*1000); + nsleep(8*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + nsleep(1*1000); //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT skipped - usleep(4*1000); + nsleep(4*1000); memcpy(buf, "\x33\x04\xfe\x00\xf4\x6c\x1f\xf0", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(3*1000); + nsleep(3*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); - usleep(1*1000); + nsleep(1*1000); //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT skipped - usleep(4*1000); + nsleep(4*1000); memcpy(buf, "\x32\x07\xfe\xf0\x29\xb9\x3a\xf0", 0x0000008); ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000); - usleep(3*1000); + nsleep(3*1000); ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000); if (buf) diff --git a/extras/scsi_id/scsi_serial.c b/extras/scsi_id/scsi_serial.c index 0f883dc..3f4e27a 100644 --- a/extras/scsi_id/scsi_serial.c +++ b/extras/scsi_id/scsi_serial.c @@ -27,6 +27,7 @@ #include <scsi/scsi.h> #include <scsi/sg.h> #include <linux/types.h> +#include <time.h> /* nanosleep() */ /* #include <linux/bsg.h> */ #include "bsg.h" @@ -846,13 +847,18 @@ int scsi_get_serial(struct udev *udev, memset(dev_scsi->serial, 0, len); dbg(udev, "opening %s\n", devname); while (--cnt) { + struct timespec time; + 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) ); + + time.tv_sec = 0; + time.tv_nsec = 500000000 + (rand() % 100000000); + nanosleep(&time, NULL); } if (fd < 0) return 1; diff --git a/udev/udev-event.c b/udev/udev-event.c index f3c2bd2..0ec2573 100644 --- a/udev/udev-event.c +++ b/udev/udev-event.c @@ -27,6 +27,7 @@ #include <sys/socket.h> #include <net/if.h> #include <linux/sockios.h> +#include <time.h> /* nanosleep() */ #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--) { + struct timespec time; + err = ioctl(sk, SIOCSIFNAME, &ifr); if (err == 0) { rename_netif_kernel_log(ifr); @@ -518,7 +521,11 @@ 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); + + time.tv_sec = 0; + time.tv_nsec = 1000 * 1000 * 1000 / 20; + + nanosleep(&time, NULL); } } exit: diff --git a/udev/udev-rules.c b/udev/udev-rules.c index 53baa18..13c98e5 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> /* nanosleep() */ #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) { + struct timespec time; + /* 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,11 @@ 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); + + time.tv_sec = 0; + time.tv_nsec = 1000 * 1000 * 1000 / WAIT_LOOP_PER_SECOND; + + nanosleep(&time, NULL); } info(udev, "waiting for '%s' failed\n", file); return -1; diff --git a/udev/udevadm-settle.c b/udev/udevadm-settle.c index 6828192..a58f4f7 100644 --- a/udev/udevadm-settle.c +++ b/udev/udevadm-settle.c @@ -30,6 +30,7 @@ #include <signal.h> #include <sys/stat.h> #include <sys/types.h> +#include <time.h> /* nanosleep() */ #include "udev.h" @@ -162,6 +163,7 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[]) /* guarantee that the udev daemon isn't pre-processing */ if (getuid() == 0) { struct udev_ctrl *uctrl; + struct timespec time; uctrl = udev_ctrl_new_from_socket(udev, UDEV_CTRL_SOCK_PATH); if (uctrl != NULL) { @@ -180,6 +182,7 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[]) while (1) { struct stat statbuf; + struct timespec time; if (exists != NULL && stat(exists, &statbuf) == 0) { rc = 0; @@ -203,7 +206,10 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[]) if (is_timeout) break; - usleep(1000 * 1000 / LOOP_PER_SECOND); + time.tv_sec = 0; + time.tv_nsec = 1000 * 1000 * 1000 / LOOP_PER_SECOND; + + nanosleep(&time, NULL); } /* if we reached the timeout, print the list of remaining events */