media: platform: samsung: s5p-jpeg: replace ternary operator with max()
authorGuo Zhengkui <guozhengkui@vivo.com>
Wed, 18 May 2022 12:08:36 +0000 (13:08 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Mon, 20 Jun 2022 09:30:31 +0000 (10:30 +0100)
Fix the following coccicheck warning:

drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c:1712:24-25:
WARNING opportunity for max()

max() macro is defined in include/linux/minmax.h. It avoids multiple
evaluations of the arguments when non-constant and performs strict
type-checking.

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c

index 456287186ad8e8a7793f5fbf9c4a9c0e9af99299..55814041b8d8f3f6578c9a25bce1f588d94af184 100644 (file)
@@ -1709,7 +1709,7 @@ static int exynos3250_jpeg_try_downscale(struct s5p_jpeg_ctx *ctx,
        w_ratio = ctx->out_q.w / r->width;
        h_ratio = ctx->out_q.h / r->height;
 
-       scale_factor = w_ratio > h_ratio ? w_ratio : h_ratio;
+       scale_factor = max(w_ratio, h_ratio);
        scale_factor = clamp_val(scale_factor, 1, 8);
 
        /* Align scale ratio to the nearest power of 2 */