Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: common: saa7146: Use min macro

Simplifies the code. Found by cocci:

drivers/media/common/saa7146/saa7146_hlp.c:125:36-37: WARNING opportunity for min()
drivers/media/common/saa7146/saa7146_hlp.c:154:41-42: WARNING opportunity for min()
drivers/media/common/saa7146/saa7146_hlp.c:286:35-36: WARNING opportunity for min()
drivers/media/common/saa7146/saa7146_hlp.c:289:35-36: WARNING opportunity for min()

Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-13-3c4865f5a4b0@chromium.org
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Ricardo Ribalda and committed by
Mauro Carvalho Chehab
2998b976 7aa9066e

+4 -4
+4 -4
drivers/media/common/saa7146/saa7146_hlp.c
··· 122 122 xacm = 0; 123 123 124 124 /* set horizontal filter parameters (CXY = CXUV) */ 125 - cxy = hps_h_coeff_tab[( (xpsc - 1) < 63 ? (xpsc - 1) : 63 )].hps_coeff; 125 + cxy = hps_h_coeff_tab[min(xpsc - 1, 63)].hps_coeff; 126 126 cxuv = cxy; 127 127 128 128 /* calculate and set horizontal fine scale (xsci) */ ··· 151 151 xacm = 0; 152 152 /* get best match in the table of attenuations 153 153 for horizontal scaling */ 154 - h_atten = hps_h_coeff_tab[( (xpsc - 1) < 63 ? (xpsc - 1) : 63 )].weight_sum; 154 + h_atten = hps_h_coeff_tab[min(xpsc - 1, 63)].weight_sum; 155 155 156 156 for (i = 0; h_attenuation[i] != 0; i++) { 157 157 if (h_attenuation[i] >= h_atten) ··· 283 283 } 284 284 285 285 /* get filter coefficients for cya, cyb from table hps_v_coeff_tab */ 286 - cya_cyb = hps_v_coeff_tab[ (yacl < 63 ? yacl : 63 ) ].hps_coeff; 286 + cya_cyb = hps_v_coeff_tab[min(yacl, 63)].hps_coeff; 287 287 288 288 /* get best match in the table of attenuations for vertical scaling */ 289 - v_atten = hps_v_coeff_tab[ (yacl < 63 ? yacl : 63 ) ].weight_sum; 289 + v_atten = hps_v_coeff_tab[min(yacl, 63)].weight_sum; 290 290 291 291 for (i = 0; v_attenuation[i] != 0; i++) { 292 292 if (v_attenuation[i] >= v_atten)