]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (7591): drivers/media/video: use time_before, time_before_eq, etc
authorJulia Lawall <julia@diku.dk>
Wed, 16 Apr 2008 19:13:15 +0000 (16:13 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Thu, 24 Apr 2008 17:09:40 +0000 (14:09 -0300)
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>
drivers/media/video/c-qcam.c
drivers/media/video/ivtv/ivtv-fileops.c
drivers/media/video/ivtv/ivtv-mailbox.c
drivers/media/video/ivtv/ivtv-streams.c

index 2c85ced6115064a225b26fa102d2bb97514ba60d..fe1e67bb1ca860b6a946afb0ed6804654c8bf4ce 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/videodev.h>
 #include <media/v4l2-common.h>
 #include <linux/mutex.h>
+#include <linux/jiffies.h>
 
 #include <asm/uaccess.h>
 
@@ -95,7 +96,8 @@ static unsigned int qcam_await_ready1(struct qcam_device *qcam,
        unsigned long oldjiffies = jiffies;
        unsigned int i;
 
-       for (oldjiffies = jiffies; (jiffies - oldjiffies) < msecs_to_jiffies(40); )
+       for (oldjiffies = jiffies;
+            time_before(jiffies, oldjiffies + msecs_to_jiffies(40)); )
                if (qcam_ready1(qcam) == value)
                        return 0;
 
@@ -120,7 +122,8 @@ static unsigned int qcam_await_ready2(struct qcam_device *qcam, int value)
        unsigned long oldjiffies = jiffies;
        unsigned int i;
 
-       for (oldjiffies = jiffies; (jiffies - oldjiffies) < msecs_to_jiffies(40); )
+       for (oldjiffies = jiffies;
+            time_before(jiffies, oldjiffies + msecs_to_jiffies(40)); )
                if (qcam_ready2(qcam) == value)
                        return 0;
 
index d949a81339d5b7fa363111389c9cce037c660873..a7640c49f1d84aa6f89e8f81e67b291d62a67350 100644 (file)
@@ -219,7 +219,9 @@ static struct ivtv_buffer *ivtv_get_buffer(struct ivtv_stream *s, int non_block,
                        /* Process pending program info updates and pending VBI data */
                        ivtv_update_pgm_info(itv);
 
-                       if (jiffies - itv->dualwatch_jiffies > msecs_to_jiffies(1000)) {
+                       if (time_after(jiffies,
+                                      itv->dualwatch_jiffies +
+                                      msecs_to_jiffies(1000))) {
                                itv->dualwatch_jiffies = jiffies;
                                ivtv_dualwatch(itv);
                        }
index 13a6c374d2dbf0833108ff3e0367cbcca7e40f8e..1b5c0ac09a8552cb0c71db7a31fed5cb2a4124ef 100644 (file)
@@ -177,7 +177,8 @@ static int get_mailbox(struct ivtv *itv, struct ivtv_mailbox_data *mbdata, int f
 
                /* Sleep before a retry, if not atomic */
                if (!(flags & API_NO_WAIT_MB)) {
-                       if (jiffies - then > msecs_to_jiffies(10*retries))
+                       if (time_after(jiffies,
+                                      then + msecs_to_jiffies(10*retries)))
                               break;
                        ivtv_msleep_timeout(10, 0);
                }
@@ -244,7 +245,9 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
           data, then just return 0 as there is no need to issue this command again.
           Just an optimization to prevent unnecessary use of mailboxes. */
        if (itv->api_cache[cmd].last_jiffies &&
-           jiffies - itv->api_cache[cmd].last_jiffies < msecs_to_jiffies(1800000) &&
+           time_before(jiffies,
+                       itv->api_cache[cmd].last_jiffies +
+                       msecs_to_jiffies(1800000)) &&
            !memcmp(data, itv->api_cache[cmd].data, sizeof(itv->api_cache[cmd].data))) {
                itv->api_cache[cmd].last_jiffies = jiffies;
                return 0;
@@ -299,7 +302,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
                }
        }
        while (!(readl(&mbox->flags) & IVTV_MBOX_FIRMWARE_DONE)) {
-               if (jiffies - then > api_timeout) {
+               if (time_after(jiffies, then + api_timeout)) {
                        IVTV_DEBUG_WARN("Could not get result (%s)\n", api_info[cmd].name);
                        /* reset the mailbox, but it is likely too late already */
                        write_sync(0, &mbox->flags);
@@ -311,7 +314,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
                else
                        ivtv_msleep_timeout(1, 0);
        }
-       if (jiffies - then > msecs_to_jiffies(100))
+       if (time_after(jiffies, then + msecs_to_jiffies(100)))
                IVTV_DEBUG_WARN("%s took %u jiffies\n",
                                api_info[cmd].name,
                                jiffies_to_msecs(jiffies - then));
index 24d98ecf35ad13de77f4d2457de6c8ba09c9c584..4ab8d36831ba427e477e984b457d967824493443 100644 (file)
@@ -768,7 +768,8 @@ int ivtv_stop_v4l2_encode_stream(struct ivtv_stream *s, int gop_end)
 
                        /* wait 2s for EOS interrupt */
                        while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) &&
-                               jiffies < then + msecs_to_jiffies (2000)) {
+                               time_before(jiffies,
+                                           then + msecs_to_jiffies(2000))) {
                                schedule_timeout(msecs_to_jiffies(10));
                        }