aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ivtv/ivtv-mailbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/ivtv/ivtv-mailbox.c')
-rw-r--r--drivers/media/video/ivtv/ivtv-mailbox.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/media/video/ivtv/ivtv-mailbox.c b/drivers/media/video/ivtv/ivtv-mailbox.c
index 13a6c374d2d..1b5c0ac09a8 100644
--- a/drivers/media/video/ivtv/ivtv-mailbox.c
+++ b/drivers/media/video/ivtv/ivtv-mailbox.c
@@ -177,7 +177,8 @@ static int get_mailbox(struct ivtv *itv, struct ivtv_mailbox_data *mbdata, int f
177 177
178 /* Sleep before a retry, if not atomic */ 178 /* Sleep before a retry, if not atomic */
179 if (!(flags & API_NO_WAIT_MB)) { 179 if (!(flags & API_NO_WAIT_MB)) {
180 if (jiffies - then > msecs_to_jiffies(10*retries)) 180 if (time_after(jiffies,
181 then + msecs_to_jiffies(10*retries)))
181 break; 182 break;
182 ivtv_msleep_timeout(10, 0); 183 ivtv_msleep_timeout(10, 0);
183 } 184 }
@@ -244,7 +245,9 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
244 data, then just return 0 as there is no need to issue this command again. 245 data, then just return 0 as there is no need to issue this command again.
245 Just an optimization to prevent unnecessary use of mailboxes. */ 246 Just an optimization to prevent unnecessary use of mailboxes. */
246 if (itv->api_cache[cmd].last_jiffies && 247 if (itv->api_cache[cmd].last_jiffies &&
247 jiffies - itv->api_cache[cmd].last_jiffies < msecs_to_jiffies(1800000) && 248 time_before(jiffies,
249 itv->api_cache[cmd].last_jiffies +
250 msecs_to_jiffies(1800000)) &&
248 !memcmp(data, itv->api_cache[cmd].data, sizeof(itv->api_cache[cmd].data))) { 251 !memcmp(data, itv->api_cache[cmd].data, sizeof(itv->api_cache[cmd].data))) {
249 itv->api_cache[cmd].last_jiffies = jiffies; 252 itv->api_cache[cmd].last_jiffies = jiffies;
250 return 0; 253 return 0;
@@ -299,7 +302,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
299 } 302 }
300 } 303 }
301 while (!(readl(&mbox->flags) & IVTV_MBOX_FIRMWARE_DONE)) { 304 while (!(readl(&mbox->flags) & IVTV_MBOX_FIRMWARE_DONE)) {
302 if (jiffies - then > api_timeout) { 305 if (time_after(jiffies, then + api_timeout)) {
303 IVTV_DEBUG_WARN("Could not get result (%s)\n", api_info[cmd].name); 306 IVTV_DEBUG_WARN("Could not get result (%s)\n", api_info[cmd].name);
304 /* reset the mailbox, but it is likely too late already */ 307 /* reset the mailbox, but it is likely too late already */
305 write_sync(0, &mbox->flags); 308 write_sync(0, &mbox->flags);
@@ -311,7 +314,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
311 else 314 else
312 ivtv_msleep_timeout(1, 0); 315 ivtv_msleep_timeout(1, 0);
313 } 316 }
314 if (jiffies - then > msecs_to_jiffies(100)) 317 if (time_after(jiffies, then + msecs_to_jiffies(100)))
315 IVTV_DEBUG_WARN("%s took %u jiffies\n", 318 IVTV_DEBUG_WARN("%s took %u jiffies\n",
316 api_info[cmd].name, 319 api_info[cmd].name,
317 jiffies_to_msecs(jiffies - then)); 320 jiffies_to_msecs(jiffies - then));