Commit 27210585 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: staging: atomisp: fix number conversion

smatch says that there's an issue with number
conversion:

   drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_params.c:4154 sh_css_params_write_to_ddr_internal() warn: '((-(1 << ((14 - 1)))))' 4294959104 can't fit into 32767 'converted_macc_table.data[idx]'
   drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_params.c:4157 sh_css_params_write_to_ddr_internal() warn: '((-(1 << ((14 - 1)))))' 4294959104 can't fit into 32767 'converted_macc_table.data[idx + 1]'
   drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_params.c:4160 sh_css_params_write_to_ddr_internal() warn: '((-(1 << ((14 - 1)))))' 4294959104 can't fit into 32767 'converted_macc_table.data[idx + 2]'
   drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_params.c:4163 sh_css_params_write_to_ddr_internal() warn: '((-(1 << ((14 - 1)))))' 4294959104 can't fit into 32767 'converted_macc_table.data[idx + 3]'
   drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/eed1_8/ia_css_eed1_8.host.c:168 ia_css_eed1_8_vmem_encode() warn: assigning (-8192) to unsigned variable 'to->e_dew_enh_a[0][base + j]'

That's probably because min() and max() definition used there
are really poor ones. So, replace by the in-kernel macro.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent b1011a33
...@@ -160,17 +160,25 @@ ia_css_eed1_8_vmem_encode( ...@@ -160,17 +160,25 @@ ia_css_eed1_8_vmem_encode(
base = shuffle_block * i; base = shuffle_block * i;
for (j = 0; j < IA_CSS_NUMBER_OF_DEW_ENHANCE_SEGMENTS; j++) { for (j = 0; j < IA_CSS_NUMBER_OF_DEW_ENHANCE_SEGMENTS; j++) {
to->e_dew_enh_x[0][base + j] = min(max(from->dew_enhance_seg_x[j], 0), 8191); to->e_dew_enh_x[0][base + j] = min_t(int, max_t(int,
to->e_dew_enh_y[0][base + j] = min(max(from->dew_enhance_seg_y[j], -8192), 8191); from->dew_enhance_seg_x[j], 0),
8191);
to->e_dew_enh_y[0][base + j] = min_t(int, max_t(int,
from->dew_enhance_seg_y[j], -8192),
8191);
} }
for (j = 0; j < (IA_CSS_NUMBER_OF_DEW_ENHANCE_SEGMENTS - 1); j++) { for (j = 0; j < (IA_CSS_NUMBER_OF_DEW_ENHANCE_SEGMENTS - 1); j++) {
to->e_dew_enh_a[0][base + j] = min(max(from->dew_enhance_seg_slope[j], -8192), 8191); to->e_dew_enh_a[0][base + j] = min_t(int, max_t(int,
from->dew_enhance_seg_slope[j],
-8192), 8191);
/* Convert dew_enhance_seg_exp to flag: /* Convert dew_enhance_seg_exp to flag:
* 0 -> 0 * 0 -> 0
* 1...13 -> 1 * 1...13 -> 1
*/ */
to->e_dew_enh_f[0][base + j] = (min(max(from->dew_enhance_seg_exp[j], 0), 13) > 0); to->e_dew_enh_f[0][base + j] = (min_t(int, max_t(int,
from->dew_enhance_seg_exp[j],
0), 13) > 0);
} }
/* Hard-coded to 0, in order to be able to handle out of /* Hard-coded to 0, in order to be able to handle out of
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
/* a:fraction bits for 16bit precision, b:fraction bits for ISP precision */ /* a:fraction bits for 16bit precision, b:fraction bits for ISP precision */
#define sDIGIT_FITTING(v, a, b) \ #define sDIGIT_FITTING(v, a, b) \
min(max((((v)>>sSHIFT) >> max(sFRACTION_BITS_FITTING(a)-(b), 0)), \ min_t(int, max_t(int, (((v)>>sSHIFT) >> max(sFRACTION_BITS_FITTING(a)-(b), 0)), \
sISP_VAL_MIN), sISP_VAL_MAX) sISP_VAL_MIN), sISP_VAL_MAX)
#define uDIGIT_FITTING(v, a, b) \ #define uDIGIT_FITTING(v, a, b) \
min((unsigned)max((unsigned)(((v)>>uSHIFT) \ min((unsigned)max((unsigned)(((v)>>uSHIFT) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment