Skip to content

Commit 2998b97

Browse files
ribaldamchehab
authored andcommitted
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/[email protected] Reviewed-by: Bryan O'Donoghue <[email protected]> Signed-off-by: Ricardo Ribalda <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 7aa9066 commit 2998b97

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/media/common/saa7146/saa7146_hlp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static int calculate_h_scale_registers(struct saa7146_dev *dev,
122122
xacm = 0;
123123

124124
/* 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;
126126
cxuv = cxy;
127127

128128
/* calculate and set horizontal fine scale (xsci) */
@@ -151,7 +151,7 @@ static int calculate_h_scale_registers(struct saa7146_dev *dev,
151151
xacm = 0;
152152
/* get best match in the table of attenuations
153153
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;
155155

156156
for (i = 0; h_attenuation[i] != 0; i++) {
157157
if (h_attenuation[i] >= h_atten)
@@ -283,10 +283,10 @@ static int calculate_v_scale_registers(struct saa7146_dev *dev, enum v4l2_field
283283
}
284284

285285
/* 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;
287287

288288
/* 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;
290290

291291
for (i = 0; v_attenuation[i] != 0; i++) {
292292
if (v_attenuation[i] >= v_atten)

0 commit comments

Comments
 (0)