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: 13636105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 486B1C04FFE for ; Fri, 19 Apr 2024 09:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4VXJ/I4UqIFJQ+L/GAN8Yr2YsCdr0ClGHjaqRT6+yeU=; b=fjTx8/kH/MTJWC dFFnw5ldMLczZRXK6uQ7jGrCgHyFQRgENLcEpUSbmzXpRqiVgSxezEY5ncLRKS82AKay6YUmLZ/QW r6yZ/Vx6OsigLmSDtNSdPB8lR2+lb2DDoUxPZdXxTjIWK+5aoN6O+IrzYMUMFo/MhFyYYXv39QE75 O0DXWPlGe4CeK+aM2S1BHa57q0QeaGfKv3xGPvg/++McUOWqj3ZJeBeDCyA3Q91ncv/GCbN3MG23Y vH0GD+YMtyL7KWkJQsOgfBVpWB94u5Q9GgD3lZHXrRdAKr19/Iv5jMba/Ud2I+vh2hJLK9KGojiPI W05qo9XsvLu05Pt8sLyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkw2-00000005BMK-3PaL; Fri, 19 Apr 2024 09:53:34 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksH-0000000593v-32iA for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Cc:To:In-Reply-To:References:Message-Id :Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender :Reply-To:Content-ID:Content-Description; bh=0jv41cPIK92ur4lysOBbsHOVURXwH8FRVBK0KQUkRX8=; b=jl8srcobhefH6jIdtQuaGpZ9Yy WmTgBDN0Gy9mcw7u639J53Gy2awIOSRha4+FsSbNrY+Yl67UvqAURKbt1gnm9GYCllQKHEAWQcK6F GNGXJq945K2RI17Hs04eKq43WcUPGzmokifbD9q7UOui23J7ox1+TptGMUnJBTkvp5WzJBMzi3ShQ gHrD4KRlUgA6+JkR/yDY/o0g+UXJTvFRzRFchcV8zoivJOUrZrYYXRaW9dF+dP5cHY1EYtZmrIrBe Gu+TwpvDBmWLiEvSL4eAFN5HD7L90lIo81XAZDGWDClMT5c2CCNIcE9k0TxX5i5UUknMoZBxzGdA8 4pGZbv0A==; Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksD-00000007Nf2-3joF for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:40 +0000 Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-78f05afc8d6so120960685a.3 for ; Fri, 19 Apr 2024 02:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520174; x=1714124974; darn=lists.infradead.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=MLb31SWBp4JDBt/WljrDKfo3cxGfLFvCz/Pk4vEqBaKn4np3qKhvQ8G/wSXrqiAnL7 jF5Qh85ywla7lpp9McxU66YLQ1VW+ou8X4Q08v67zGT/3S7b6SO5AHG20TGbWXZOOjq2 rcvGiJveg5v+GsRMGK/d1APhcOhIhZLeA1zQE= 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=usNiq6Zod5IcuNgrOx6pm7wfipWpkX13yWT173NRWbBW7rMAh3SGMAYv3sXJRgQXaz XwJe/zPZ86wtx3iMGDWHqHYSf/NZwIXQ1qp4mof3sZKlU2z5t3FBPqKaq2C1sISU83Sz 8RyjAKgQrqhBjQ9hQ/AwUjDomNZ53EsVgapkCm7A79TN67oVq1K9U56am3s8NCuw+p9v 9CxWM5wc5fLi1GAz7Mh/mVLb8PiK618gIst1RmHbWdAs3nOeDtjECZYqZqBpfZyH6+WA zhgJXg2DtLJe3kQa5Y3XPOjTTNxblI5YrOxSmZhFYfXOc9ZPEMueV2o4V2/oLjW1psj/ O6PA== X-Forwarded-Encrypted: i=1; AJvYcCWRTm4vZnB0y94CAfoatVmnxPEk5oaW+w5oddF1t7ze3p0PdSw3CrWdqdDT9ESc9beXCX5zEHpHJmyCcQJlIRhGDHf3lh6WcbMyEtnlEut7oShpsls= X-Gm-Message-State: AOJu0YwhIee3X/5jV7Pgq9hWQqezdwCao1XEtQ4ZAW+r4L823WLof/p2 RDB+VW1vsmk55dmK5l/i1GLKSxWMHrEzzs3wwc7ON+LB/s+btDParaez6sOd5w== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104938_066421_37811B2F X-CRM114-Status: GOOD ( 12.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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)