diff options
author | Jason Liu <r64343@freescale.com> | 2013-04-03 13:45:39 +0800 |
---|---|---|
committer | Jason Liu <r64343@freescale.com> | 2013-04-03 18:24:21 +0800 |
commit | 790715dfbc95afe64521f9d7ef60ef85c4a33849 (patch) | |
tree | 1048f750e5267c5e90caf63d7cab6bbbd8710010 | |
parent | e71d3d328a886113c7edbd52573ea20a79ac613f (diff) |
ENGR00255518 ipu/ipu3: using the kernel common help function div_u64
We don't need invent the wheel to implement the wrap for the _do_div,
we can use the kernel common helper function for the u64 divide with
div_u64() function call
This also fix the build break when CONFIG_DEBUG_SECTION_MISMATCH=y with
GCC4.6.3 cross-compile toolchain.
CC init/version.o
LD init/built-in.o
LD .tmp_vmlinux1
drivers/built-in.o: In function `_do_div.part.1':
clkdev.c:(.text+0x15c23c): undefined reference to `__aeabi_uldivmod'
clkdev.c:(.text+0x15c25c): undefined reference to `__aeabi_uldivmod'
clkdev.c:(.text+0x15c2bc): undefined reference to `__aeabi_uldivmod'
clkdev.c:(.text+0x15c3ac): undefined reference to `__aeabi_uldivmod'
clkdev.c:(.text+0x15c3d0): undefined reference to `__aeabi_uldivmod'
This issue is caused by the wrongly optimized code produced by GCC,
See the bug report here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48783
The similar build break issue report at:
http://lists.infradead.org/pipermail/linux-mtd/2012-May/041677.html
Signed-off-by: Jason Liu <r64343@freescale.com>
-rw-r--r-- | drivers/mxc/ipu/ipu_calc_stripes_sizes.c | 42 | ||||
-rw-r--r-- | drivers/mxc/ipu3/ipu_calc_stripes_sizes.c | 42 |
2 files changed, 34 insertions, 50 deletions
diff --git a/drivers/mxc/ipu/ipu_calc_stripes_sizes.c b/drivers/mxc/ipu/ipu_calc_stripes_sizes.c index b6230e819503..0700b941a387 100644 --- a/drivers/mxc/ipu/ipu_calc_stripes_sizes.c +++ b/drivers/mxc/ipu/ipu_calc_stripes_sizes.c @@ -1,5 +1,5 @@ /* - * Copyright 2009-2011 Freescale Semiconductor, Inc. All Rights Reserved. + * Copyright 2009-2013 Freescale Semiconductor, Inc. All Rights Reserved. */ /* @@ -21,7 +21,7 @@ #include <linux/module.h> #include <linux/ipu.h> -#include <asm/div64.h> +#include <linux/math64.h> #define BPP_32 0 #define BPP_16 3 @@ -30,21 +30,13 @@ #define BPP_12 4 #define BPP_18 2 -static u64 _do_div(u64 a, u32 b) -{ - u64 div; - div = a; - do_div(div, b); - return div; -} - static u32 truncate(u32 up, /* 0: down; else: up */ u64 a, /* must be non-negative */ u32 b) { u32 d; u64 div; - div = _do_div(a, b); + div = div_u64(a, b); d = b * (div >> 32); if (up && (a > (((u64)d) << 32))) return d+b; @@ -227,9 +219,9 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, || (output_frame_width < 4)) return 1; - irr_opt = _do_div((((u64)(input_frame_width - 1)) << 32), + irr_opt = div_u64((((u64)(input_frame_width - 1)) << 32), (output_frame_width - 1)); - rr_opt = _do_div((((u64)(output_frame_width - 1)) << 32), + rr_opt = div_u64((((u64)(output_frame_width - 1)) << 32), (input_frame_width - 1)); if ((input_m == 0) || (output_m == 0) || (input_f == 0) || (output_f == 0) @@ -262,7 +254,7 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, left->output_width = right->output_width = right->output_column = output_frame_width >> 1; left->input_column = right->input_column = 0; - div = _do_div(((((u64)irr_steps) << 32) * + div = div_u64(((((u64)irr_steps) << 32) * (right->input_width - 1)), (right->output_width - 1)); left->irr = right->irr = truncate(0, div, 1); } else { /* with overlap */ @@ -272,7 +264,7 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, /* this is the maximal inw which allows the same resizing ratio */ /* in both stripes */ onw = truncate(1, (inw * rr_opt), output_f); - div = _do_div((((u64)(irr_steps * inw)) << + div = div_u64((((u64)(irr_steps * inw)) << 32), onw); left->irr = right->irr = truncate(0, div, 1); left->output_width = right->output_width = @@ -280,14 +272,14 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, /* These are valid assignments for output_width, */ /* assuming output_f is a multiple of output_m */ div = (((u64)(left->output_width-1) * (left->irr)) << 32); - div = (((u64)1) << 32) + _do_div(div, irr_steps); + div = (((u64)1) << 32) + div_u64(div, irr_steps); left->input_width = right->input_width = truncate(1, div, input_m); - div = _do_div((((u64)((right->output_width - 1) * right->irr)) << + div = div_u64((((u64)((right->output_width - 1) * right->irr)) << 32), irr_steps); difwr = (((u64)(input_frame_width - 1 - inw)) << 32) - div; - div = _do_div((difwr + (((u64)input_f) << 32)), 2); + div = div_u64((difwr + (((u64)input_f) << 32)), 2); left->input_column = truncate(0, div, input_f); @@ -312,13 +304,13 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, /* in both stripes */ onw = truncate(1, inw * rr_opt, output_f); do { - div = _do_div((((u64)(irr_steps * inw)) << 32), onw); + div = div_u64((((u64)(irr_steps * inw)) << 32), onw); left->irr = truncate(0, div, 1); - div = _do_div((((u64)(onw * left->irr)) << 32), + div = div_u64((((u64)(onw * left->irr)) << 32), irr_steps); dinw = (((u64)inw) << 32) - div; - div = _do_div((((u64)((output_frame_width - 1 - onw) * left->irr)) << + div = div_u64((((u64)((output_frame_width - 1 - onw) * left->irr)) << 32), irr_steps); difwl = (((u64)(input_frame_width - 1 - inw)) << 32) - div; @@ -338,7 +330,7 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, inw = inw_best; onw = truncate(1, inw * rr_opt, output_f); - div = _do_div((((u64)(irr_steps * inw)) << 32), onw); + div = div_u64((((u64)(irr_steps * inw)) << 32), onw); left->irr = truncate(0, div, 1); left->output_width = onw; @@ -349,18 +341,18 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, right->input_width = truncate(1, ((u64)(input_frame_width - inw)) << 32, input_m); - div = _do_div((((u64)(irr_steps * (input_frame_width - 1 - inw))) << + div = div_u64((((u64)(irr_steps * (input_frame_width - 1 - inw))) << 32), (right->output_width - 1)); right->irr = truncate(0, div, 1); temp = truncate(0, ((u64)left->irr) * ((((u64)1) << 32) + dirr), 1); if (temp < right->irr) right->irr = temp; - div = _do_div(((u64)((right->output_width - 1) * right->irr) << + div = div_u64(((u64)((right->output_width - 1) * right->irr) << 32), irr_steps); difwr = (u64)(input_frame_width - 1 - inw) - div; - div = _do_div((difwr + (((u64)input_f) << 32)), 2); + div = div_u64((difwr + (((u64)input_f) << 32)), 2); left->input_column = truncate(0, div, input_f); /* This splits the truncated input columns evenly */ diff --git a/drivers/mxc/ipu3/ipu_calc_stripes_sizes.c b/drivers/mxc/ipu3/ipu_calc_stripes_sizes.c index 4cee1df5cbf8..3a27195bbc3d 100644 --- a/drivers/mxc/ipu3/ipu_calc_stripes_sizes.c +++ b/drivers/mxc/ipu3/ipu_calc_stripes_sizes.c @@ -1,5 +1,5 @@ /* - * Copyright 2009-2012 Freescale Semiconductor, Inc. All Rights Reserved. + * Copyright 2009-2013 Freescale Semiconductor, Inc. All Rights Reserved. */ /* @@ -21,7 +21,7 @@ #include <linux/module.h> #include <mach/ipu-v3.h> -#include <asm/div64.h> +#include <linux/math64.h> #define BPP_32 0 #define BPP_16 3 @@ -30,21 +30,13 @@ #define BPP_12 4 #define BPP_18 2 -static u64 _do_div(u64 a, u32 b) -{ - u64 div; - div = a; - do_div(div, b); - return div; -} - static u32 truncate(u32 up, /* 0: down; else: up */ u64 a, /* must be non-negative */ u32 b) { u32 d; u64 div; - div = _do_div(a, b); + div = div_u64(a, b); d = b * (div >> 32); if (up && (a > (((u64)d) << 32))) return d+b; @@ -229,9 +221,9 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, if ((input_frame_width < 4) || (output_frame_width < 4)) return 1; - irr_opt = _do_div((((u64)(input_frame_width - 1)) << 32), + irr_opt = div_u64((((u64)(input_frame_width - 1)) << 32), (output_frame_width - 1)); - rr_opt = _do_div((((u64)(output_frame_width - 1)) << 32), + rr_opt = div_u64((((u64)(output_frame_width - 1)) << 32), (input_frame_width - 1)); if ((input_m == 0) || (output_m == 0) || (input_f == 0) || (output_f == 0) @@ -265,7 +257,7 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, output_frame_width >> 1; left->input_column = 0; left->output_column = 0; - div = _do_div(((((u64)irr_steps) << 32) * + div = div_u64(((((u64)irr_steps) << 32) * (right->input_width - 1)), (right->output_width - 1)); left->irr = right->irr = truncate(0, div, 1); } else { /* with overlap */ @@ -275,7 +267,7 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, /* this is the maximal inw which allows the same resizing ratio */ /* in both stripes */ onw = truncate(1, (inw * rr_opt), output_f); - div = _do_div((((u64)(irr_steps * inw)) << + div = div_u64((((u64)(irr_steps * inw)) << 32), onw); left->irr = right->irr = truncate(0, div, 1); left->output_width = right->output_width = @@ -283,14 +275,14 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, /* These are valid assignments for output_width, */ /* assuming output_f is a multiple of output_m */ div = (((u64)(left->output_width-1) * (left->irr)) << 32); - div = (((u64)1) << 32) + _do_div(div, irr_steps); + div = (((u64)1) << 32) + div_u64(div, irr_steps); left->input_width = right->input_width = truncate(1, div, input_m); - div = _do_div((((u64)((right->output_width - 1) * right->irr)) << + div = div_u64((((u64)((right->output_width - 1) * right->irr)) << 32), irr_steps); difwr = (((u64)(input_frame_width - 1 - inw)) << 32) - div; - div = _do_div((difwr + (((u64)input_f) << 32)), 2); + div = div_u64((difwr + (((u64)input_f) << 32)), 2); left->input_column = truncate(0, div, input_f); @@ -315,13 +307,13 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, /* in both stripes */ onw = truncate(1, inw * rr_opt, output_f); do { - div = _do_div((((u64)(irr_steps * inw)) << 32), onw); + div = div_u64((((u64)(irr_steps * inw)) << 32), onw); left->irr = truncate(0, div, 1); - div = _do_div((((u64)(onw * left->irr)) << 32), + div = div_u64((((u64)(onw * left->irr)) << 32), irr_steps); dinw = (((u64)inw) << 32) - div; - div = _do_div((((u64)((output_frame_width - 1 - onw) * left->irr)) << + div = div_u64((((u64)((output_frame_width - 1 - onw) * left->irr)) << 32), irr_steps); difwl = (((u64)(input_frame_width - 1 - inw)) << 32) - div; @@ -341,7 +333,7 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, inw = inw_best; onw = truncate(1, inw * rr_opt, output_f); - div = _do_div((((u64)(irr_steps * inw)) << 32), onw); + div = div_u64((((u64)(irr_steps * inw)) << 32), onw); left->irr = truncate(0, div, 1); left->output_width = onw; @@ -352,18 +344,18 @@ int ipu_calc_stripes_sizes(const unsigned int input_frame_width, right->input_width = truncate(1, ((u64)(input_frame_width - inw)) << 32, input_m); - div = _do_div((((u64)(irr_steps * (input_frame_width - 1 - inw))) << + div = div_u64((((u64)(irr_steps * (input_frame_width - 1 - inw))) << 32), (right->output_width - 1)); right->irr = truncate(0, div, 1); temp = truncate(0, ((u64)left->irr) * ((((u64)1) << 32) + dirr), 1); if (temp < right->irr) right->irr = temp; - div = _do_div(((u64)((right->output_width - 1) * right->irr) << + div = div_u64(((u64)((right->output_width - 1) * right->irr) << 32), irr_steps); difwr = (u64)(input_frame_width - 1 - inw) - div; - div = _do_div((difwr + (((u64)input_f) << 32)), 2); + div = div_u64((difwr + (((u64)input_f) << 32)), 2); left->input_column = truncate(0, div, input_f); /* This splits the truncated input columns evenly */ |