diff options
author | Julia Lawall <julia@diku.dk> | 2008-04-16 15:13:15 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 13:09:40 -0400 |
commit | 168c626cb8f85df17585af99e14403904641c7ac (patch) | |
tree | b3b899a507b76afc2923d4f7d6c1ed995957a4fc /drivers/media/video/ivtv | |
parent | 9e05c0f0d84c25f7f576ebc22a9a3a2cf962cc58 (diff) |
V4L/DVB (7591): drivers/media/video: use time_before, time_before_eq, etc
The functions time_before, time_before_eq, time_after, and time_after_eq
are more robust for comparing jiffies against other values.
A simplified version of the semantic patch making this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@ change_compare_np @
expression E;
@@
(
- jiffies <= E
+ time_before_eq(jiffies,E)
|
- jiffies >= E
+ time_after_eq(jiffies,E)
|
- jiffies < E
+ time_before(jiffies,E)
|
- jiffies > E
+ time_after(jiffies,E)
)
@ include depends on change_compare_np @
@@
@ no_include depends on !include && change_compare_np @
@@
#include <linux/...>
+ #include <linux/jiffies.h>
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/ivtv')
-rw-r--r-- | drivers/media/video/ivtv/ivtv-fileops.c | 4 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-mailbox.c | 11 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-streams.c | 3 |
3 files changed, 12 insertions, 6 deletions
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c index d949a81339d5..a7640c49f1d8 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.c +++ b/drivers/media/video/ivtv/ivtv-fileops.c | |||
@@ -219,7 +219,9 @@ static struct ivtv_buffer *ivtv_get_buffer(struct ivtv_stream *s, int non_block, | |||
219 | /* Process pending program info updates and pending VBI data */ | 219 | /* Process pending program info updates and pending VBI data */ |
220 | ivtv_update_pgm_info(itv); | 220 | ivtv_update_pgm_info(itv); |
221 | 221 | ||
222 | if (jiffies - itv->dualwatch_jiffies > msecs_to_jiffies(1000)) { | 222 | if (time_after(jiffies, |
223 | itv->dualwatch_jiffies + | ||
224 | msecs_to_jiffies(1000))) { | ||
223 | itv->dualwatch_jiffies = jiffies; | 225 | itv->dualwatch_jiffies = jiffies; |
224 | ivtv_dualwatch(itv); | 226 | ivtv_dualwatch(itv); |
225 | } | 227 | } |
diff --git a/drivers/media/video/ivtv/ivtv-mailbox.c b/drivers/media/video/ivtv/ivtv-mailbox.c index 13a6c374d2db..1b5c0ac09a85 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)); |
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c index 24d98ecf35ad..4ab8d36831ba 100644 --- a/drivers/media/video/ivtv/ivtv-streams.c +++ b/drivers/media/video/ivtv/ivtv-streams.c | |||
@@ -768,7 +768,8 @@ int ivtv_stop_v4l2_encode_stream(struct ivtv_stream *s, int gop_end) | |||
768 | 768 | ||
769 | /* wait 2s for EOS interrupt */ | 769 | /* wait 2s for EOS interrupt */ |
770 | while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) && | 770 | while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) && |
771 | jiffies < then + msecs_to_jiffies (2000)) { | 771 | time_before(jiffies, |
772 | then + msecs_to_jiffies(2000))) { | ||
772 | schedule_timeout(msecs_to_jiffies(10)); | 773 | schedule_timeout(msecs_to_jiffies(10)); |
773 | } | 774 | } |
774 | 775 | ||