]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
[media] bdisp-debug: don't try to divide by s64
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Wed, 10 Jun 2015 17:37:16 +0000 (14:37 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 11 Jun 2015 10:34:30 +0000 (07:34 -0300)
There are several warnings there, on some architectures, related
to dividing a s32 by a s64 value:

drivers/media/platform/sti/bdisp/bdisp-debug.c:594: warning: comparison of distinct pointer types lacks a cast
drivers/media/platform/sti/bdisp/bdisp-debug.c:594: warning: right shift count >= width of type
drivers/media/platform/sti/bdisp/bdisp-debug.c:594: warning: passing argument 1 of '__div64_32' from incompatible pointer type
drivers/media/platform/sti/bdisp/bdisp-debug.c:595: warning: comparison of distinct pointer types lacks a cast
drivers/media/platform/sti/bdisp/bdisp-debug.c:595: warning: right shift count >= width of type
drivers/media/platform/sti/bdisp/bdisp-debug.c:595: warning: passing argument 1 of '__div64_32' from incompatible pointer type  CC [M]  drivers/media/tuners/mt2060.o
drivers/media/platform/sti/bdisp/bdisp-debug.c:596: warning: comparison of distinct pointer types lacks a cast
drivers/media/platform/sti/bdisp/bdisp-debug.c:596: warning: right shift count >= width of type
drivers/media/platform/sti/bdisp/bdisp-debug.c:596: warning: passing argument 1 of '__div64_32' from incompatible pointer type
drivers/media/platform/sti/bdisp/bdisp-debug.c:597: warning: comparison of distinct pointer types lacks a cast
drivers/media/platform/sti/bdisp/bdisp-debug.c:597: warning: right shift count >= width of type
drivers/media/platform/sti/bdisp/bdisp-debug.c:597: warning: passing argument 1 of '__div64_32' from incompatible pointer type

That doesn't make much sense. What the driver is actually trying
to do is to divide one second by a value. So, check the range
before dividing. That warrants the right result and will remove
the warnings on non-64 bits archs.

Also fixes this warning:
drivers/media/platform/sti/bdisp/bdisp-debug.c:588: warning: comparison of distinct pointer types lacks a cast

by using div64_s64() instead of calling do_div() directly.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/sti/bdisp/bdisp-debug.c

index 7c3a632746ba40b8780e1ae8c6e3c2646e797f5a..18282a0f80c975ac25dd86d92b575ac66d09f755 100644 (file)
@@ -572,6 +572,8 @@ static int bdisp_dbg_regs(struct seq_file *s, void *data)
        return 0;
 }
 
+#define SECOND 1000000
+
 static int bdisp_dbg_perf(struct seq_file *s, void *data)
 {
        struct bdisp_dev *bdisp = s->private;
@@ -584,17 +586,26 @@ static int bdisp_dbg_perf(struct seq_file *s, void *data)
                return 0;
        }
 
-       avg_time_us = bdisp->dbg.tot_duration;
-       do_div(avg_time_us, request->nb_req);
-
-       avg_fps = 1000000;
-       min_fps = 1000000;
-       max_fps = 1000000;
-       last_fps = 1000000;
-       do_div(avg_fps, avg_time_us);
-       do_div(min_fps, bdisp->dbg.min_duration);
-       do_div(max_fps, bdisp->dbg.max_duration);
-       do_div(last_fps, bdisp->dbg.last_duration);
+       avg_time_us = div64_s64(bdisp->dbg.tot_duration, request->nb_req);
+       if (avg_time_us > SECOND)
+               avg_fps = 0;
+       else
+               avg_fps = SECOND / (s32)avg_time_us;
+
+       if (bdisp->dbg.min_duration > SECOND)
+               min_fps = 0;
+       else
+               min_fps = SECOND / (s32)bdisp->dbg.min_duration;
+
+       if (bdisp->dbg.max_duration > SECOND)
+               max_fps = 0;
+       else
+               max_fps = SECOND / (s32)bdisp->dbg.max_duration;
+
+       if (bdisp->dbg.last_duration > SECOND)
+               last_fps = 0;
+       else
+               last_fps = SECOND / (s32)bdisp->dbg.last_duration;
 
        seq_printf(s, "HW processing (%d requests):\n", request->nb_req);
        seq_printf(s, " Average: %5lld us  (%3d fps)\n",