From patchwork Fri Apr 19 09:47:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 790299 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CAA38624B for ; Fri, 19 Apr 2024 09:49:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713520178; cv=none; b=ByUnvHG3CUMLR1aPsF89gcturEJ+XEkQhumAaAO2iP3NMrkPoH7ypUHy6Rc0v9vEPJnY4mgs/HqQAHfSvVwJkpo2WNxTab3BX4c+tI+yHMdaRlIXHcC4/VluERbrLegVEsXN1rpYkYnUcxQdTC8/LXMf6HhG89Z5g9DmyuQ5WIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713520178; c=relaxed/simple; bh=0VmWOq0FNED2TWNE7G/mZoZRSR2zskQMt81gS2SxLNQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KdkjlwKvWVr9MLrmaUUcH5C0DXCkqPZ1Ddq3WRbv2DDgLHVxKIEE0Rjx/KqpOClzGOvQ77cAx1UOBgs2uEM1A6sx8ErO1L2t4bmnNk16zSMzX0yFXqiCNRP28H0xMbSJKwR6HXbkU7LXZ8K8aybxn1vqfAs0Aj5k1pM3V3KZoYc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=eIZu+n3k; arc=none smtp.client-ip=209.85.222.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="eIZu+n3k" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-78f056f928eso115331085a.0 for ; Fri, 19 Apr 2024 02:49:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520174; x=1714124974; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0jv41cPIK92ur4lysOBbsHOVURXwH8FRVBK0KQUkRX8=; b=eIZu+n3kqnN5hXJRWz93UrTIokn6sMlXNWwbhawXi2uyaqyDOwpG/WKlT3vgtWx/XU rXqQ9jItl3g1MrrNa9vK20rtrkt+RO55CCgvaNrnwGzCkw6c1Ste0HiwvHt2LFrfMF/Q o79fAzEvHZTy+v/1BZR+n6eFRXim+VlEUxu6Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520174; x=1714124974; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0jv41cPIK92ur4lysOBbsHOVURXwH8FRVBK0KQUkRX8=; b=VbnziSyTvUMLdMwjXluO1BusJJmu76woFAlzTF7H1yeeHUuA2tg0Ci2i743kL9DUYr YWNRBcSwwCs4chQ+tZiWGpfjTyjUsMtnrgIi65CVLOs3lcmrqgDEUanCO2+gTjWjrFc5 X9rocjo4M3yxbTMhzIIbrypLww6yovlgNsZnEftuCcnAfFcmc/eeNOatxj51qEuANiGy RDIDAka9jULq5PVegv+j+wSHBuALzFITUMIexa4h6uGde4MQ+3CzV4ahSkTAyMdBbjqw s0DHWuaaLv8lW9eYkuzSpeDxCcxRPpwznro3ZoVBT0Z3XgOIdMnCE3kLcGYhFdEJwh8U l56A== X-Forwarded-Encrypted: i=1; AJvYcCWFObbPV5+eiTjFNQvVPi/AXWK6iS+0409F7UIARNUJoNeJQRhZSpWnp50LtNTUP70z/zlQH/9sIjSpzUGXcz0Ia/2Yn511cvbAc8w06w== X-Gm-Message-State: AOJu0YyUnhzo556FVSK3KngIozgGqHlsX8suDY3nyOBtIw30kDEr5OwO gPBUCDw0d59QFRzgqKLhhoAvne+ZYmmKfJsx/u6cTrNPxqXHRm1nAHzThEr6Pw== X-Google-Smtp-Source: AGHT+IETv5IUoGgWksFs9Z+Dm4pcXtdl0bT854ihOygqGrbXzgeian082aGVpKk3VnS1RI+F74x9Bg== X-Received: by 2002:a05:620a:4694:b0:78e:d2ff:a108 with SMTP id bq20-20020a05620a469400b0078ed2ffa108mr2287614qkb.0.1713520174478; Fri, 19 Apr 2024 02:49:34 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:34 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:59 +0000 Subject: [PATCH v2 13/26] media: common: saa7146: Use min macro Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-13-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 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() Signed-off-by: Ricardo Ribalda --- drivers/media/common/saa7146/saa7146_hlp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_hlp.c b/drivers/media/common/saa7146/saa7146_hlp.c index 7569d8cdd4d8..fe3348af543e 100644 --- a/drivers/media/common/saa7146/saa7146_hlp.c +++ b/drivers/media/common/saa7146/saa7146_hlp.c @@ -122,7 +122,7 @@ static int calculate_h_scale_registers(struct saa7146_dev *dev, xacm = 0; /* set horizontal filter parameters (CXY = CXUV) */ - cxy = hps_h_coeff_tab[( (xpsc - 1) < 63 ? (xpsc - 1) : 63 )].hps_coeff; + cxy = hps_h_coeff_tab[min(xpsc - 1, 63)].hps_coeff; cxuv = cxy; /* calculate and set horizontal fine scale (xsci) */ @@ -151,7 +151,7 @@ static int calculate_h_scale_registers(struct saa7146_dev *dev, xacm = 0; /* get best match in the table of attenuations for horizontal scaling */ - h_atten = hps_h_coeff_tab[( (xpsc - 1) < 63 ? (xpsc - 1) : 63 )].weight_sum; + h_atten = hps_h_coeff_tab[min(xpsc - 1, 63)].weight_sum; for (i = 0; h_attenuation[i] != 0; i++) { if (h_attenuation[i] >= h_atten) @@ -283,10 +283,10 @@ static int calculate_v_scale_registers(struct saa7146_dev *dev, enum v4l2_field } /* get filter coefficients for cya, cyb from table hps_v_coeff_tab */ - cya_cyb = hps_v_coeff_tab[ (yacl < 63 ? yacl : 63 ) ].hps_coeff; + cya_cyb = hps_v_coeff_tab[min(yacl, 63)].hps_coeff; /* get best match in the table of attenuations for vertical scaling */ - v_atten = hps_v_coeff_tab[ (yacl < 63 ? yacl : 63 ) ].weight_sum; + v_atten = hps_v_coeff_tab[min(yacl, 63)].weight_sum; for (i = 0; v_attenuation[i] != 0; i++) { if (v_attenuation[i] >= v_atten)