usleep_range() is perfect for this.
Showing the changes to drivers/staging/media/lirc (1 of 1 file). Show all
Unified · Split
| @@ -76,21 +76,6 @@ static inline void soutp(int offset, int value) · 75 unmodified lines | |||
| 76 | outb(value, io + offset); | 76 | outb(value, io + offset); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | #ifndef MAX_UDELAY_MS | ||
| 80 | #define MAX_UDELAY_US 5000 | ||
| 81 | #else | ||
| 82 | #define MAX_UDELAY_US (MAX_UDELAY_MS * 1000) | ||
| 83 | #endif | ||
| 84 | |||
| 85 | static void safe_udelay(unsigned long usecs) | ||
| 86 | { | ||
| 87 | while (usecs > MAX_UDELAY_US) { | ||
| 88 | udelay(MAX_UDELAY_US); | ||
| 89 | usecs -= MAX_UDELAY_US; | ||
| 90 | } | ||
| 91 | udelay(usecs); | ||
| 92 | } | ||
| 93 | |||
| 94 | /* SECTION: Communication with user-space */ | 79 | /* SECTION: Communication with user-space */ |
| 95 | static int sir_tx_ir(struct rc_dev *dev, unsigned int *tx_buf, | 80 | static int sir_tx_ir(struct rc_dev *dev, unsigned int *tx_buf, |
| 96 | unsigned int count) | 81 | unsigned int count) |
| @@ -281,7 +266,7 @@ static irqreturn_t sir_interrupt(int irq, void *dev_id) · 184 unmodified lines | |||
| 281 | 266 | ||
| 282 | static void send_space(unsigned long len) | 267 | static void send_space(unsigned long len) |
| 283 | { | 268 | { |
| 284 | safe_udelay(len); | 269 | usleep_range(len, len + 25); |
| 285 | } | 270 | } |
| 286 | 271 | ||
| 287 | static void send_pulse(unsigned long len) | 272 | static void send_pulse(unsigned long len) |