From patchwork Mon Apr 29 15:04:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647152 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 2D4DFC4345F for ; Mon, 29 Apr 2024 15:05:05 +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=aatYulGL8/eR7YNKB85r75E0V2GzEEcGJEWMjCQnyEo=; b=wWzT8jyNVrMwUc 14p5KXtamutTg67yWDmebUFfHZNrrxb01wQxcE93MDDmIiMRkshrTow1YBmqKCaCrNrV30mvpuY5w l9HnJXclwCOQaSoLpWeaXbQZzgChK7fIBGL4OzX5rDIcEPuQTFOTTFmP+D/v3S7I3uk7k8CEA0F6c 0SZqjTOqlZdVPs9WHLfiCsN+hzUhzMPWvl5o0eOV2Ta1oof+Gcvj0zTvXgu4Gbhn60Y+fxr7e8jGQ rgDlj0RoyxTB8Eg2mCTjLoU6HlxQqoWJLkFCr2QSpoeQU924ZsT+w2JjBN2fla5rELx7ZkAezJodF Uqk2VKiZlpj+JwmFqCcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYk-00000003FKE-2kck; Mon, 29 Apr 2024 15:04:50 +0000 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYf-00000003FFq-26Kc for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:04:47 +0000 Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-790605809cbso420801785a.3 for ; Mon, 29 Apr 2024 08:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403084; x=1715007884; 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=cX0Nt2WjhKwJC/tEnFmYRvlB1MfFk2LmbDG81TIdFVM=; b=VG+osiId90CMFXtEbs7eadJ8eYRfgWhvNm8QugtxWw8aRGwc7vM82Xlg72LxLrV9VB TTgkGJdHRgv694N/9W2c3L0CEbR9oQfNeHFzRSl/9GTogpdrv4XGJfQkCDu5lP6BG1TV bdO5tZdW8Y+ygR7uj7w8ZlDeFr6MU9a/64Krk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403084; x=1715007884; 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=cX0Nt2WjhKwJC/tEnFmYRvlB1MfFk2LmbDG81TIdFVM=; b=BUViHF9ewFS47CFaMGrEQkHxlQ91esQW921YJaUYCVaXmzjyL8IDQrcXWfyNJZ8yXo q9kRHa1F5OQ2u7GvBn7A8ltLgR+vplHsxdxWoegXByoRl8onNU5glx7n5r/M8Wy3L8lL P4oIKfY1v6IUuPQMhPGgQqypWHwl0d0KO+9pUcyGhe/ydkzrG3lzi+G9IB9k3MorSe36 94OZ4fBHjhxgHabCdqWJxfKJ6HDS7uDTMRUy6OkPHZSa6aXb1In48UlAHhNdNqFSUMh+ CPzDHt/Q5Vk9pSpqgrgJlF+IYRwSVLiKhz3NvrDWWkWJS/Y3pnXLM88RLtKLPm2tFOwh 08iw== X-Forwarded-Encrypted: i=1; AJvYcCXF3qatFaJQB+6ZIDrmXR9/a9rkpRZpI2s0ZUqxb3CpERVpe0HvCAYyGUyw27f0wFB3ceUgangJ48PaxROGpLceo9DQG0oRwaHzHuLT8qyhx15uJCo= X-Gm-Message-State: AOJu0YwmMfVgXdikMXQ6ARXzNnwAA96gxXZfpg6+bQLwujz+ur6yfkzG pxKBWYK+Y3nFj6P1JfjZXLnqZkyBzhwWZ5PndQKlmmfYkCqEij2AcujLXRtncA== X-Google-Smtp-Source: AGHT+IHWuK1oddmDBavr6+ksLu5/g3HWffeblwIQsTBH58X6jA8tyFIvmLIj97Bf7YP3AKSemxlfBQ== X-Received: by 2002:a05:620a:4eb:b0:790:8e96:7841 with SMTP id b11-20020a05620a04eb00b007908e967841mr10130143qkh.60.1714403083799; Mon, 29 Apr 2024 08:04:43 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:43 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:40 +0000 Subject: [PATCH v3 01/26] media: pci: mgb4: Refactor struct resources MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-1-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080445_575438_88EB166B X-CRM114-Status: GOOD ( 16.06 ) 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 The struct resource end field signifies the end address not the relative offset from the start field i.e size == (end - start) + 1. Amend the .end field to specify the end address not the relative size from the offset as is currently given. Fixes cocci check: drivers/media/pci/mgb4/mgb4_regs.c:13:22-25: WARNING: Suspicious code. resource_size is maybe missing with res Reviewed-by: Martin Tůma Reviewed-by: Bryan O'Donoghue Signed-off-by: Ricardo Ribalda --- drivers/media/pci/mgb4/mgb4_core.c | 4 ++-- drivers/media/pci/mgb4/mgb4_regs.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/pci/mgb4/mgb4_core.c b/drivers/media/pci/mgb4/mgb4_core.c index 9bcf10a77fd3..60498a5abebf 100644 --- a/drivers/media/pci/mgb4/mgb4_core.c +++ b/drivers/media/pci/mgb4/mgb4_core.c @@ -493,13 +493,13 @@ static int mgb4_probe(struct pci_dev *pdev, const struct pci_device_id *id) struct mgb4_dev *mgbdev; struct resource video = { .start = 0x0, - .end = 0x100, + .end = 0xff, .flags = IORESOURCE_MEM, .name = "mgb4-video", }; struct resource cmt = { .start = 0x1000, - .end = 0x1800, + .end = 0x17ff, .flags = IORESOURCE_MEM, .name = "mgb4-cmt", }; diff --git a/drivers/media/pci/mgb4/mgb4_regs.c b/drivers/media/pci/mgb4/mgb4_regs.c index 53d4e4503a74..31befd722d72 100644 --- a/drivers/media/pci/mgb4/mgb4_regs.c +++ b/drivers/media/pci/mgb4/mgb4_regs.c @@ -10,7 +10,7 @@ int mgb4_regs_map(struct resource *res, struct mgb4_regs *regs) { regs->mapbase = res->start; - regs->mapsize = res->end - res->start; + regs->mapsize = resource_size(res); if (!request_mem_region(regs->mapbase, regs->mapsize, res->name)) return -EINVAL; From patchwork Mon Apr 29 15:04:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647160 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 7752EC04FFE for ; Mon, 29 Apr 2024 15:07:26 +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=La16rb8Xsw17w93p59QmXX9L8mPNU1DwO29FShZXixA=; b=IwCEiCi8C3XPaf JGzjQvCzsxjD5hYoQKLdwHsp8/SMMirhz2wT/AItepp6rb/mlx7Id1B3cs9DF8Go63k+x/JZvz5aI Jwat5Vxq7X0K8QpnPVIoSCgKlSbazQ6NDiK5E68aeorj8+8zSbYq+9bxc9X+o2+4fFFTkcllKhJ1k dMIeYi5w1xU9CSeRicd7nGiFPW8l8uCS7c+nrfaTL23tKhWMCEQBOwtTRtiFxlpfHn2pthgVwN0vK SJQ8UZZ4XxoGE/7RUQwqxF7pVujvBsU0PQx2+Nvsj4h/3YbhLKPsYTqGFHBG8gP/bdtzFENf1Vp5e t0aAQGFBrkHJgdQACVOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sb0-00000003Gjx-2ves; Mon, 29 Apr 2024 15:07:10 +0000 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYg-00000003FGg-2Ncz for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:04:48 +0000 Received: by mail-qk1-x735.google.com with SMTP id af79cd13be357-78efd533a00so336950285a.0 for ; Mon, 29 Apr 2024 08:04:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403085; x=1715007885; 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=TBoYdFZFpJunUvgv52P8o/805oLnG0rRdaJVdgyqfIE=; b=apj6f4HkyXAe/Luid6AcPeHWc0tcedOq0qVH6fEg1uGZBeOL+Zdv4CSBtm7rbyZYS2 A4hta82IL3vvS99Uq1d3EYzVcPCqt40CA13Ix1syJowdiXBRC48gJMcNrBKL9cINtOD/ vEA00d8nz04oFAhK40zG/5m6pzKM5YYQk/EPs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403085; x=1715007885; 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=TBoYdFZFpJunUvgv52P8o/805oLnG0rRdaJVdgyqfIE=; b=DVRt0rlkMlksZ/mWYZq9vMvazrD9/CxdVAjRk9CmHHtBz+E+yGe7OPM+SAtIP4gXwE pcFg9N6l5CQMIGLyIfQSYyPgf2CoadJYzOizLE/l+NVCqQkfmn3d/zYgj9bgWbbePN9w 7Y4b5xX8qIgo3dCv4Lp/nFCSO8/eDFsRuLzWXWbQkrtnjoWCQaEPpBDnzbmBk0vdy8Bf wD2Pp5r33nZxDoqATchQzz530HMxKXlYV3ZNL40LpSY6zI65grauftzELkwQv5sZX0L4 0P2B98E50wRyLej6pm/gSC/xYJ3NnV+WcWkxk/eeY1dmFgsHEfyt4/aMMX+LYgULiIy3 SJwA== X-Forwarded-Encrypted: i=1; AJvYcCXIYpzNsw3aEAl/Awye5nueXWOXNwd9lJpOVQm6McL6c0agptb/9oEcQtwCu4FFRDG3MS7AZi8NNjwkQMLa3O9VXKQ/SvjXVBM0z4Tjbq3hGoR6cOY= X-Gm-Message-State: AOJu0YxRqdTJry5LXTw2WEHATNfV+TRglEvfDRvsu6qZVQ1HR2ac3GJY wOOOlgs4QUAzNu4mecOm2TX3dcWhydmy6CIuCnaU+rfm43/MwnK+2kgRtxwEkg== X-Google-Smtp-Source: AGHT+IF+chYPShGmmjcrkgz/giMi8LlMh1kKDt+AWNRJgL6Fjthaoaa54O+J4vw4mx2W4IdeglySVQ== X-Received: by 2002:a05:620a:39d:b0:790:944d:65b3 with SMTP id q29-20020a05620a039d00b00790944d65b3mr8124237qkm.62.1714403084821; Mon, 29 Apr 2024 08:04:44 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:44 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:41 +0000 Subject: [PATCH v3 02/26] media: stb0899: Simplify check MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-2-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080446_708164_CE297746 X-CRM114-Status: GOOD ( 13.68 ) 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 chip_id is an unsigned number, it can never be < 0 Fixes cocci check: drivers/media/dvb-frontends/stb0899_drv.c:1280:8-15: WARNING: Unsigned expression compared with zero: chip_id > 0 Reviewed-by: Bryan O'Donoghue Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-frontends/stb0899_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/stb0899_drv.c b/drivers/media/dvb-frontends/stb0899_drv.c index 2f4d8fb400cd..35634f9a8ab5 100644 --- a/drivers/media/dvb-frontends/stb0899_drv.c +++ b/drivers/media/dvb-frontends/stb0899_drv.c @@ -1277,7 +1277,7 @@ static int stb0899_get_dev_id(struct stb0899_state *state) dprintk(state->verbose, FE_ERROR, 1, "Demodulator Core ID=[%s], Version=[%d]", (char *) &demod_str, demod_ver); CONVERT32(STB0899_READ_S2REG(STB0899_S2FEC, FEC_CORE_ID_REG), (char *)&fec_str); fec_ver = STB0899_READ_S2REG(STB0899_S2FEC, FEC_VER_ID_REG); - if (! (chip_id > 0)) { + if (!chip_id) { dprintk(state->verbose, FE_ERROR, 1, "couldn't find a STB 0899"); return -ENODEV; From patchwork Mon Apr 29 15:04:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647159 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 D956CC4345F for ; Mon, 29 Apr 2024 15:07:24 +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=HeTD/7iIAPDUvFZ3CgPvb8ATZhcJFMvGYnV+kt5zFNY=; b=y3EuLnU87ukohX jwDFaU3AorbePi6zU/Cww/FGlOn5gm55bzhgxhNM4n7FeHcGjA3Zn9Ka4jDn+SQYE0l76hyf1yqYC ISIfgvyxyo35M4QjsaNMS54uTjrmg439wPgEaufMBFRzt2HSr4W1exiDRiI0Q7piMbXR2y+V9jfII lgpuNApWDPF81X4TGpFzZ9HfE0Dv8NkXDwDaNsjIVlBFaphZZqrSyr4FJk6v6bDSJnwOBTB4pDXC5 7U8hKJFpBFy/L/bYZ7fcKdXJhgVLpfQXGQul7+gZdtKFCfeLkUr180zE73Elg+RlfTrRk7ZgRt2fn Vqdmu4Cxj1qx/o7fad7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sb1-00000003Gks-2aGE; Mon, 29 Apr 2024 15:07:11 +0000 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYh-00000003FHP-1zCj for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:04:49 +0000 Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-78f049fefd5so305400285a.1 for ; Mon, 29 Apr 2024 08:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403086; x=1715007886; 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=fm7JWuSLrjUxnTtxzzsVfK/l2tiOhulSLLxdjSxChR4=; b=Rc/d39xP1ubGi2H0soNfv0+G54l+7BURYCJYYCbuNXydNWXxZpgoGIYzkvBgl3MZoo XPmi9w9ZWV2RiF39o5eH6TK76ZOjCP3fu43G85feWtN4LyepXQVs+tCbn1RdycdnWtn9 ay570QlQpmd8yVH6SBr3BHnYcAE+faX3g3BGI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403086; x=1715007886; 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=fm7JWuSLrjUxnTtxzzsVfK/l2tiOhulSLLxdjSxChR4=; b=gEHJrgkxxdcpUlCWNNz2toLXsasGCnZ3AZ+sY9/IqRJMzDFRTxU+AjUowE7eX3Km7Q nHkrrdAqquxao/q5lL2tCJiUweYRQWe7QSwr46sWp5FWyAbcW/mDt7mwjThYdACkaet2 JyuoLcSeAxb/pzVwAGCgkPVwBlmttUnzM2NDtGk7s5CxGAHCfwLlvlo7QcXyUbK6pzcu 4Fp4vZBkfFV0E7WC/J8+tRcBKknd0Iw2jCEps9CGp5eq0mN662Fdw5lIj1a4S5UWJRY9 J/Ly9fDXhHdQcXs63Z/QhVhTy8dr8wTzLpWfUOUJ6FSCNcGEtfP+pX9WMPracBPaZ+JI XQoQ== X-Forwarded-Encrypted: i=1; AJvYcCVnwc/sFH99jT9FyZ/bK0naPzPLDVw4T69IftlmlhaqJ1tdVdUIKWxh3XZ2jk7ZFeNhWE8Tf6PXqSIui9NUTPVERiN1z4gPjJLI03AtkqHbqq/T54w= X-Gm-Message-State: AOJu0Yy7fVj+Up/atSMrDo8cBO2ZrRrj700fwT6BrggXe+PoY7TMnggS U+dmwGdzCeLIedDFSHmnefPYzbNGa7h+4aVxoKjTrDFXaOkRmBOGeI8MANde3g== X-Google-Smtp-Source: AGHT+IGYSDsYF7fAd+WjRxR8fXXmBkGXpeoZ1JSQ7zAf0MZgzOcQzU6WrlcwakVFv0Bl8su7Ntb5Aw== X-Received: by 2002:a05:620a:448b:b0:790:f6ba:4976 with SMTP id x11-20020a05620a448b00b00790f6ba4976mr3869599qkp.71.1714403085870; Mon, 29 Apr 2024 08:04:45 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:45 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:42 +0000 Subject: [PATCH v3 03/26] media: uvcvideo: Refactor iterators MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-3-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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 , Sergey Senozhatsky X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_080447_561176_A4FC8E31 X-CRM114-Status: GOOD ( 17.23 ) 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 Avoid using the iterators after the list_for_each() constructs. This patch should be a NOP, but makes cocci, happier: drivers/media/usb/uvc/uvc_ctrl.c:1861:44-50: ERROR: invalid reference to the index variable of the iterator on line 1850 drivers/media/usb/uvc/uvc_ctrl.c:2195:17-23: ERROR: invalid reference to the index variable of the iterator on line 2179 Reviewed-by: Sergey Senozhatsky Reviewed-by: Laurent Pinchart Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index e59a463c2761..a4a987913430 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -1850,16 +1850,18 @@ int __uvc_ctrl_commit(struct uvc_fh *handle, int rollback, list_for_each_entry(entity, &chain->entities, chain) { ret = uvc_ctrl_commit_entity(chain->dev, entity, rollback, &err_ctrl); - if (ret < 0) + if (ret < 0) { + if (ctrls) + ctrls->error_idx = + uvc_ctrl_find_ctrl_idx(entity, ctrls, + err_ctrl); goto done; + } } if (!rollback) uvc_ctrl_send_events(handle, ctrls->controls, ctrls->count); done: - if (ret < 0 && ctrls) - ctrls->error_idx = uvc_ctrl_find_ctrl_idx(entity, ctrls, - err_ctrl); mutex_unlock(&chain->ctrl_mutex); return ret; } @@ -2165,7 +2167,7 @@ static int uvc_ctrl_init_xu_ctrl(struct uvc_device *dev, int uvc_xu_ctrl_query(struct uvc_video_chain *chain, struct uvc_xu_control_query *xqry) { - struct uvc_entity *entity; + struct uvc_entity *entity, *iter; struct uvc_control *ctrl; unsigned int i; bool found; @@ -2175,16 +2177,16 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain, int ret; /* Find the extension unit. */ - found = false; - list_for_each_entry(entity, &chain->entities, chain) { - if (UVC_ENTITY_TYPE(entity) == UVC_VC_EXTENSION_UNIT && - entity->id == xqry->unit) { - found = true; + entity = NULL; + list_for_each_entry(iter, &chain->entities, chain) { + if (UVC_ENTITY_TYPE(iter) == UVC_VC_EXTENSION_UNIT && + iter->id == xqry->unit) { + entity = iter; break; } } - if (!found) { + if (!entity) { uvc_dbg(chain->dev, CONTROL, "Extension unit %u not found\n", xqry->unit); return -ENOENT; From patchwork Mon Apr 29 15:04:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647154 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 8CC13C4345F for ; Mon, 29 Apr 2024 15:05:55 +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=f9PfJLA/RjPqF/RaRea16xpMTEWBs0fSYxEHCTYu0JI=; b=Cx0KG6oaBasQ/v XSkBjN/7/BrujA14Q+eTt+eSIyfXzHY+gcV3sD+zO+TSRhAhEBz3nWYYkBtw+9DGbv4KF+9GLeMC9 h2MXvty3KONefJOUYv2kWwLHwIe6CzQLsYuutzRDlRyGqaYN1E2aNgTIH+zwd1Ix/mKpfFpcH/2aR dSVSLfnzjkXllSX0usreeVnPzyytsIE9951PeXw2Q3kSX5LLrDzaFtbwgrmV3jooa2CFnBUbyz4Dm DTIpgWKjWrvTqSCFDPHilzsAOnwp6qCSLHBPs0jxfam/mOSLwS9Ae2iLVlJncpUMccnWnGgj+mtvo VY3NtE7w99+1ofydPSJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZY-00000003Fsx-1NDw; Mon, 29 Apr 2024 15:05:40 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYi-00000003FI1-2sba for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:04:50 +0000 Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-78f049ddd7dso369241685a.1 for ; Mon, 29 Apr 2024 08:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403087; x=1715007887; 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=2ANA0Ymw4Lt0Uz9R7FMbv4c7Ba86EanvWiJ79X90fJk=; b=e5lVo1YPRMe5wRSofk+aF1JjaKu1RV9Lqovo/n5bTx0ChOYT4uyhgRpPRvAiJrM5wR NBIJlJyFFXae/QZbqVxXi/L/hc26KCHlud/hpbsgB9uHfs6yKnehcx+v3+6aW4A1Lta3 5FLo5KvXybijZgEW5cJjpzRLiBlXnNB99JqhU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403087; x=1715007887; 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=2ANA0Ymw4Lt0Uz9R7FMbv4c7Ba86EanvWiJ79X90fJk=; b=kZQpXED8BrYdRYY+H07HqXJra8OqTobWJ23Y0xQvdJ/+WWG+IOgg77trn09NV23h18 s0+AguNVmDeIDmadrsvvUfz6iVkQFNkr2G6Xi7H6UPK1pH/SYvCgYvn229PRlgp3nkHM uKGiBefe8E8gf8qOGmlGwk2h+q3wVNB4QHGHDewk+J1d5fO8CXL2qg8qUQrSKMNQZemm w39fNsLUH7ntBV5kJqCJFxhVxj4m3zgCcpm/1jE6juPr1UlFnSFm4Q5YTLFJ9AegmG7g sTLZfemfJ/9OEGtnp5YOM7Ze21DaoocLuEJvSqEZd2G7Po3+JMY6J8RkzJdDVzEkzget y8dg== X-Forwarded-Encrypted: i=1; AJvYcCWsQlBXHnKYXZdAEWzIhsLPzRPI0S3epWWUqpjo5VSQEOTDp4JODIjoooBpOA2xvqUJk9/eL1jr/GLwn5aX4k/d/2/tYhsw0K1g29/PZ155ndiug40= X-Gm-Message-State: AOJu0YxpULpjGhOsGpKlxw5hSKOxgTgkcXltd1qz+H8Oa0kLfe+NmjlL 0Ns/VCucmXnKL4HPpE8xSnU09KkCw3ZkeHT80M/jliEPk9StQ3JBsp0pZxDJCA== X-Google-Smtp-Source: AGHT+IEnQjn3WLm+y+PPKHAe/yfoK7DsUlbFKzqXGLCHhSBuNgNTvG4+ilDw6HzfNC7wT8W0tTtiYw== X-Received: by 2002:a37:c449:0:b0:790:98ba:67c5 with SMTP id h9-20020a37c449000000b0079098ba67c5mr11283245qkm.33.1714403087305; Mon, 29 Apr 2024 08:04:47 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:47 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:43 +0000 Subject: [PATCH v3 04/26] media: uvcvideo: Use max() macro MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-4-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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 , Sergey Senozhatsky , Kieran Bingham X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_080449_213124_1D0ADA53 X-CRM114-Status: GOOD ( 12.48 ) 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 It makes the code slightly more clear and makes cocci incredibly happy: drivers/media/usb/uvc/uvc_ctrl.c:839:22-23: WARNING opportunity for max() Reviewed-by: Sergey Senozhatsky Reviewed-by: Kieran Bingham Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index a4a987913430..4b685f883e4d 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -836,7 +836,7 @@ static s32 uvc_get_le_value(struct uvc_control_mapping *mapping, while (1) { u8 byte = *data & mask; value |= offset > 0 ? (byte >> offset) : (byte << (-offset)); - bits -= 8 - (offset > 0 ? offset : 0); + bits -= 8 - max(offset, 0); if (bits <= 0) break; From patchwork Mon Apr 29 15:04:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647231 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 1CE5BC4345F for ; Mon, 29 Apr 2024 15:14:15 +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=auH+/0ybVJ5itT50s/yXGGXADv5D4BAQIlqMGr+r+Xk=; b=FMz1OweIHOrwUO 590B6jtVSQFfSoedU+Oze96pCkxtPQ7CvpPzdKiajVfJc3l+YFTRSl1mibmR6UOo9Pc8VQx5wcfVd pv9hsrOB5QaUllQWKy0bSO7o55UdHPMtzowcJJmoyGxyjWCUCLFQ0dh9AZnd5sAr2+TB1onHZ2nnL PNFWAfglCjH9ac/PARF17SLKSzXP9jsw9dqc9KzOyYJZ1XMNbjho9yb7plSIzu8h9YijP+MfC2/zr tanp7lM90/lbhxcqhHgeZWYXVcwPJq1tI2Lt3FogNVLWbiudncOcaAP2ahHMBIKWUmSTmO+qKaDiW 5n29SxJsjZZBXXhgnJzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Shh-00000003L55-2r9E; Mon, 29 Apr 2024 15:14:05 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1ShM-00000003Ktg-0FMP for linux-arm-kernel@bombadil.infradead.org; Mon, 29 Apr 2024 15:13:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=S/QHDINTXxaHfJymmPQd1ntNOyaEtGJ2b8ypDUwyIXI=; b=eZv8ka6jzumsKwXyW8idQSILSH iBJDkL0bqH2coViQOSaUTkxPfoD7qiXj9w07oz/52EHVmVYxttjQkgpXVYgA2BiZFOzAR1+Kod8vJ CQG1vws6obJl+4cafIfJQQ0s9f5H4n306/X5UadKhgCy7fIXJTimZuAiMaIqijbR2I5sQPlS9T5Mv qMH2vFS7EK+pSy8xJEc2pFIfRXX8qxjLAmLPEucvhuYxdI6L4jWRiTmhu364rZBIenwvxDZMa7p3p z/enwLXnKTR3ylzJS2OquQsyruFUWBRspdrPLon+gDIYrdWqH3vmol7CsjTAlg0xiieCB4/Y3/s5O E6cEBY/g==; Received: from [2607:f8b0:4864:20::72e] (helo=mail-qk1-x72e.google.com) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sd9-0000000GYLz-433H for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:13:31 +0000 Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-78f043eaee9so279808285a.3 for ; Mon, 29 Apr 2024 08:05:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403088; x=1715007888; 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=S/QHDINTXxaHfJymmPQd1ntNOyaEtGJ2b8ypDUwyIXI=; b=YAb06H5zh4iyWP9ItzNUWSzBjekxbhUVPnZ+MLCbM26ADVSRF12v1vsA7fM3FLeakZ SsrKZys1Tp06zaoVe1KxVtYj7o09iZweod309GNRJ1ravlzFbtRzZEoFwAu/his3DY3a xdWICO8ZuI2teAtYlnGKzljFTfTWYc7y9NaYA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403088; x=1715007888; 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=S/QHDINTXxaHfJymmPQd1ntNOyaEtGJ2b8ypDUwyIXI=; b=fOW8MM27105SLMoZJk1bSW54uXH5dKvYvA2e7tDQGKQgxcc+KT4UtlMNSe7Vf6u5Hs AVpIQOHEeHWjUS8CtVhDcDVYlM5z0GeBsX0C69AjUiNM3ZKcGljKXI4g/e2R7CeAiLWC +qWHNoEJOWdloUQLj5K9sgHEdD4fB6Y2dCx0H7cEVMFox/6y8GzwRJAikj+J0GQS4P8C cw//ancwht2LkBZoD0W1raJBhK9Wh6Fab18hBozJbag5AqTh94HAwQXMLUqFrYYWakCe g6f3NtszX1eHFcnXaM1Zb9LwkYUvn4SCY2JSoCg963ZpzQ9yLTkr6KcUYoZnM2cDiQOL zRAQ== X-Forwarded-Encrypted: i=1; AJvYcCUB47VI2m2G0k8i0dopjuMzCDeCpAOX4yqy8FJZvMs56whJjIwX6/K3zDQuMocCDvemm3x6TE3glps1FiRxA26GFyl062p/CdAUpNCbcANiAYMQ4u0= X-Gm-Message-State: AOJu0Yz4OGcHxkIJxSAd/GMbqWe++qbnOfQP/t4c9f1Lt2ygZfItQcXK QfjegKcbzC1akkRXeVKW6kX5ANwMBgMGUmEDSairZkzC1RGDbAz7qQiHPTpiUA== X-Google-Smtp-Source: AGHT+IEZLuGKR7d7W/XG/sq8LQdtDnaq4FWL5zvJstwztGqQFStkjBLrDGAeQqjGLBaD6vVb0xh5nw== X-Received: by 2002:a05:620a:21d8:b0:790:81e5:5f30 with SMTP id h24-20020a05620a21d800b0079081e55f30mr12924542qka.70.1714403088208; Mon, 29 Apr 2024 08:04:48 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:47 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:44 +0000 Subject: [PATCH v3 05/26] media: go7007: Use min and max macros MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-5-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_161118_550657_C5E3A47A X-CRM114-Status: GOOD ( 12.30 ) 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 Replace ternary inline selection of f1 and f2 min max values with min() and max() helper functions for the sake of readability and to make coccinelle happier drivers/media/usb/go7007/go7007-fw.c:1292:14-15: WARNING opportunity for max() drivers/media/usb/go7007/go7007-fw.c:1293:14-15: WARNING opportunity for min() Reviewed-by: Bryan O'Donoghue Signed-off-by: Ricardo Ribalda --- drivers/media/usb/go7007/go7007-fw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/go7007/go7007-fw.c b/drivers/media/usb/go7007/go7007-fw.c index 018019ba47d4..86ce593e0c54 100644 --- a/drivers/media/usb/go7007/go7007-fw.c +++ b/drivers/media/usb/go7007/go7007-fw.c @@ -1289,8 +1289,8 @@ static int avsync_to_package(struct go7007 *go, __le16 *code, int space) 0xbf99, (u16)((-adjratio) >> 16), 0xbf92, 0, 0xbf93, 0, - 0xbff4, f1 > f2 ? f1 : f2, - 0xbff5, f1 < f2 ? f1 : f2, + 0xbff4, max(f1, f2), + 0xbff5, min(f1, f2), 0xbff6, f1 < f2 ? ratio : ratio + 1, 0xbff7, f1 > f2 ? ratio : ratio + 1, 0xbff8, 0, From patchwork Mon Apr 29 15:04:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647162 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 70332C4345F for ; Mon, 29 Apr 2024 15:07:28 +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=SY4yxp1sLkVlU43t8elKp+3jiiXSJ+OvPTBS+KF3tAQ=; b=wHr7NIHb+5FoPf yJT/LtPuWdYlY6sz+EoKgkHQ4+Z9NyfLqe3j99fV4B+IWTyQLgnxHlUE94VcX5n8qfYnpC1RFjsNN QPDHrUSVXMty+dSt0akAbAmZWX3yZlqLvxXaGKMKhEdYYsBSvVy8ws+jTYM0NDQJwLBwclqj0icS+ SlAjvaWX93lLkqoeQwA8gHd5rB7MXtrmaGPNfwowkgk6KbBcRonG2ejIGRbweiYOD/k4yNPU1K8MB AddF29o99+T5TP5ccD+pcUfAluUaFThLjfxj3uvKzGZtqRVM/+lpsOsHDZFNa7tjM7bE60CCI4E3C P9VsOynN8FAaORBuU2yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sb2-00000003GlR-1uoi; Mon, 29 Apr 2024 15:07:12 +0000 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYk-00000003FJN-2wcU for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:04:52 +0000 Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-790f91b834cso71791585a.0 for ; Mon, 29 Apr 2024 08:04:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403089; x=1715007889; 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=AThUs0uZjFFwmlw5yFatMODeeCPF6NJNDOtB7Vvi1Co=; b=gJxGuY5wirGJZPlkNNAgLVYbscbkk2DtPubr4NUmrvaUuDViLMuwS3m+SNEKPKVoOY 5KIb2Ber3/hb2bqYAs7s31or6hW9V+gAqOONXkuUJ5De3ljSioPaaOqOYMK0u9Bnray8 KEaY4AH5+0d1nt0rZfwUQ5cf14LUSXQOlVQzQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403089; x=1715007889; 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=AThUs0uZjFFwmlw5yFatMODeeCPF6NJNDOtB7Vvi1Co=; b=Oty7aGCS7ltrGxMskDdvg40dT9SXD37ciY3JI8kTj5fOWARtKASUrFOmJWcroLWh0E B5TjUeSujils8P1KvrHL4nHblkyH8+8TVxAowDuzyzXP9t/sr6ZU24L9UR8HNUWT2UNS HRkbLFpZNhmN50xwnhXuaBOflL5q4aIOefNgGTXmnYIPGEQgsTkKFbkHyZ2W6JeEqG10 qa0wRp3d3XcR5SvKQJr11G19zhcSjP4rjS9TnSGFPLRMfV+5FE2ZqXWpnAPX/IGINrKP l7ILH6ycTnuU6MhXO+q/Iu8ehNBeaKEkFpEgv0NZGqcb0WH7xWw1gbd+9U0n28T+S9lk f+GQ== X-Forwarded-Encrypted: i=1; AJvYcCU8cVEylfQBzBO5eMB55lkgSpLyNjIODIZ6HJ+210TYqBYc9N/l5PGBmN24inOQMnIQEzH4CrY+R2mgsOi3CYO3Ba495claJbxA+ddW0WOwSjI9vhk= X-Gm-Message-State: AOJu0YyIhaFRcHduO1kh8EBKTHy/mG0EPpMNAr2PIUJtFyiPt+Kj5bVi GXvGJRPHEYEm2mOls1jlw2Bl3aGjg8X/rCHHcCyHiPehb4bbMgxl6l1hz8gPjA== X-Google-Smtp-Source: AGHT+IGBuMWlT8BGDJs/bsSnyVE6ctAfT7ka0JR0PlzLBPx7ju98o6D15U4PhJiULbsFLxQvf+DlVA== X-Received: by 2002:a05:620a:4094:b0:790:f4dc:ba36 with SMTP id f20-20020a05620a409400b00790f4dcba36mr4480887qko.33.1714403089247; Mon, 29 Apr 2024 08:04:49 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:48 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:45 +0000 Subject: [PATCH v3 06/26] media: stm32-dcmipp: Remove redundant printk MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-6-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080450_935812_EB5BF09A X-CRM114-Status: GOOD ( 14.21 ) 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 platform_get_irq() already prints an error message. Also platform_get_irq() can never return 0, so lets fix the condition now that we are at it. Found by cocci: drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c:444:3-10: line 444 is redundant because platform_get_irq() already prints an error Signed-off-by: Ricardo Ribalda --- drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c index bce821eb71ce..4acc3b90d03a 100644 --- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c +++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c @@ -439,11 +439,8 @@ static int dcmipp_probe(struct platform_device *pdev) "Could not get reset control\n"); irq = platform_get_irq(pdev, 0); - if (irq <= 0) { - if (irq != -EPROBE_DEFER) - dev_err(&pdev->dev, "Could not get irq\n"); - return irq ? irq : -ENXIO; - } + if (irq < 0) + return irq; dcmipp->regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); if (IS_ERR(dcmipp->regs)) { From patchwork Mon Apr 29 15:04:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647155 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 A9AE3C4345F for ; Mon, 29 Apr 2024 15:06:15 +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=7Ofaw8FZbR6I9NiBS36Ui1LvKvQTx1m85Ae/gd1OsEI=; b=f+bqqDA4CDmSb6 UTCXPy4V3WSWvmaF0O99XBrzydSWWP7Mjd3louI7BoI2FyC2aCvvie3S1vzD+MwOmww7Xlt7qaCAC yyIQVh3ghkvNthaz8t8xw7e18F46/0YnRXltcSbV6AJPO/gPWvcDI6rwaJPwf5OCGRGuP4ewa6y0p juw3XTa4fNznuBb8nr1qhr4ghyV4oIxtKR1dqGtGnMf5Q6Xfmrs5qxKtM1MHbOfG8pdkS+91tIVR4 GjNrL5czEbw6MOBEEnK/UgnMuXp+QrK6r5unRfILTpf6vYa9jx/6wnnEs4YyWC0JT/SWyH7WPd3Rg 59Vp9ACpMmD/L7ldBF7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZs-00000003G2Z-1Lgc; Mon, 29 Apr 2024 15:06:00 +0000 Received: from mail-qk1-x731.google.com ([2607:f8b0:4864:20::731]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYl-00000003FKO-1Dpg for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:04:53 +0000 Received: by mail-qk1-x731.google.com with SMTP id af79cd13be357-790f4650f93so114834685a.2 for ; Mon, 29 Apr 2024 08:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403090; x=1715007890; 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=/qUCWhD1zt8bKcdbs6yESnMSEdigGZ2fB7xO4uH5zQE=; b=PLIi0Cj56Q3LqJnD9UFb8RVKb4xjk66YKjTMUbPqVZ3Hhui/VPbAgdDT6hIg+76yMT aSjvAeV4twSIjC1ZgdkxfpGFmNeRrqvxrBW+m9Ado+DlepEiRQ6JdsieguxJvZkl3roE cx7HOK6M7YtBOvFX7couxpV7FK4x3vbrcI0eM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403090; x=1715007890; 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=/qUCWhD1zt8bKcdbs6yESnMSEdigGZ2fB7xO4uH5zQE=; b=XbWvXq7oYv5sUTLfLW1kE5LEM1Wt6epbC5SWtuEKrXWR/t5yN6TjCfWTEcQbX6rA5u zGWXi19/Ksk16RP35aiDDiFPt+9SNidGPcB+A+ghn7xJYXYbHfLcFiuITzxeWC1pCgUE BoweprGwbGRNSxZQUyO4NyUOI+2uwj3FE0eS1sNw5A1slKr4l/1Grigt2wqko8cMnnO/ xu6bAt5aHoeKuzBkFGjYhimxKwhbuyiXG83QI7bLKg9/R49+L+KqaOf7OuaMpqAlTOc/ 0d9x3K9F1YDEgaRI2eDB7MzGH+yvx4Uxjct0GKBLKRftA4qrDadmUmR9uCkKKrfJA/yW LQWw== X-Forwarded-Encrypted: i=1; AJvYcCUhZEENB0ObOU4RBDUDFCcDKIIGWEs+qjbhtwlXylETBY/cCNMFlLsiPFqq9gYlYDQ9Wk4TwvZLCoSd5Kdl8lcxq253nix294x75gYC+hiOHP3vQ6s= X-Gm-Message-State: AOJu0YxAaxakIXxW/P2j81fdLVRssBiuREZY9r1L/omLH6b5/PxJ+q76 0qibTNJOA8Rb8kHAe1Pm/BiYrEaRinw9nIzqd7ph0apPW/WqzuUE/z997k341w== X-Google-Smtp-Source: AGHT+IHHKi7cqnMpYwnQDIZ9akhXG6vV1AIqNbLdBOwmjaLKTCEqbKtGqVQAHlyIVFw/U88/GLAn3g== X-Received: by 2002:a05:620a:4591:b0:790:fc14:60ac with SMTP id bp17-20020a05620a459100b00790fc1460acmr2298793qkb.0.1714403090344; Mon, 29 Apr 2024 08:04:50 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:50 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:46 +0000 Subject: [PATCH v3 07/26] media: staging: sun6i-isp: Remove redundant printk MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-7-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080451_483507_D230387E X-CRM114-Status: GOOD ( 12.82 ) 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 platform_get_irq() already prints an error for us. Found by cocci: drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c:389:2-9: line 389 is redundant because platform_get_irq() already prints an error Acked-by: Jernej Skrabec Signed-off-by: Ricardo Ribalda --- drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c index 5c0a45394cba..58f8ae92320d 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c @@ -386,8 +386,7 @@ static int sun6i_isp_resources_setup(struct sun6i_isp_device *isp_dev, irq = platform_get_irq(platform_dev, 0); if (irq < 0) { - dev_err(dev, "failed to get interrupt\n"); - ret = -ENXIO; + ret = irq; goto error_clock_rate_exclusive; } From patchwork Mon Apr 29 15:04:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647156 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 365F3C04FFE for ; Mon, 29 Apr 2024 15:06:30 +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=YMcsnzBd93Ou3WahTrZkr6ZVQ4hryPLp64xuQzJu7Ms=; b=DuQ4T/KNfvGvQV f5TfRv4i/0EdEMdSh/Kt4Bi3bypj6u+uWl7AStEKWIm5Fd2UAu6wEy926QrlyeC7FQ2K56saqcwTB mjH0N2WN6w2Zedzwd737nRtacg2ZSwFqZNAPqUY+7l7kXCESB/Q4iCUzkI91RCXN+nk12aL9p+G+W 89/RVt/5mqufHxY1hwV3CakRQfif0RBVesBkgjN0lEsPIn/CPVJfDitpfdcZrCKM3YY+6AVirsydV 12xkAU6X9vrIo1VD391wLoJ3CASYXDO3WheAsEKa/qdjmwEiQeuo7Flx5stEi8vPAzXGqWXWBz5w5 UBRmWhclYdRJwYetFgvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sa7-00000003GAw-28ZI; Mon, 29 Apr 2024 15:06:15 +0000 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYm-00000003FM9-2dyh for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:04:55 +0000 Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-790ff1fa7b3so45286385a.2 for ; Mon, 29 Apr 2024 08:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403092; x=1715007892; 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=OI4AOi/6PtgU5zRnLUWjMVWmm8Y+CckVMvMt6qKhGc0=; b=dx1iybqQ/4aokzR+fbQuOsC9+OxRzHc6i8TPA0sbt4nVwbEfkovf4PkzQTos6xRbJs P67IzcMQp9J9OjQaYmbNnOpTp+oayGC6VlvHAobipvdazY6JP4zSoI3EW2AnngAW7RY2 unAe9MXRPuUrM/jFw85/x0/yf2lSFn8TWpihU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403092; x=1715007892; 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=OI4AOi/6PtgU5zRnLUWjMVWmm8Y+CckVMvMt6qKhGc0=; b=ZhFTKiMGH4lsMdOt91QHgsv/beX9vDBbgPi7bP9wrX1AacNkaaxk85PxvVZ/RE4OAP umf2czbf97Q8Y3PdOU9xe4vVim+b/EE3R/1tDnsuyS68RzkmM8pkveqHABDk2Oh0cXi8 jtxse+h6WpzhQdvggUkr8FiPN7ufke2Ru+DJ7piOsA/JAfEjlrcs816L7tWckVaVWXkk 8dZzkFghCWauxYChskVBnVIoaSUOAt5P4cuGrrgXfRDQoLh7B5okjqAUfHxTV7RuQWpA bOvG825aKtXExq4S4gqhDBQwEPMDkd0WqxMcs5hJYEl8k7YP6AKLcjr/ojrYhyf044TX ntHA== X-Forwarded-Encrypted: i=1; AJvYcCWzEFr8S7rJPTmsAhKk31ELnIGHOAgUu9wGf1kyRhgQRDjgW6hB9b76kHD4R+wBCSbtp3T26AZb/bubWjaZBnjWF6E9CmfrvGCxiegRfmyY5y+lgSQ= X-Gm-Message-State: AOJu0YxkvnmqjnnfB6ycV+IIIkxNU0YbTu5e/X2MAqU0ak5OK15qXYMy Iw5AnJ3pQPPmsF8btDyOEF7CLpxSUX2J1HOYJl0m0ZXJFXoL76lFxqVn9Wh5PQ== X-Google-Smtp-Source: AGHT+IG3TSxma0YdxDVyjt+TwA8E2r3YjCQOsUMIKvXlCmNNngt83Fx59gwPuYEOR/mAqhiKqgMwqA== X-Received: by 2002:a05:620a:2445:b0:790:f04b:328c with SMTP id h5-20020a05620a244500b00790f04b328cmr4582245qkn.29.1714403091343; Mon, 29 Apr 2024 08:04:51 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:51 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:47 +0000 Subject: [PATCH v3 08/26] media: dvb-frontends: tda18271c2dd: Remove casting during div MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-8-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080452_989253_9406978F X-CRM114-Status: GOOD ( 13.11 ) 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 do_div() divides 64 bits by 32. We were adding a casting to the divider to 64 bits, for a number that fits perfectly in 32 bits. Remove it. Found by cocci: drivers/media/dvb-frontends/tda18271c2dd.c:355:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. drivers/media/dvb-frontends/tda18271c2dd.c:331:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-frontends/tda18271c2dd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/dvb-frontends/tda18271c2dd.c b/drivers/media/dvb-frontends/tda18271c2dd.c index a34834487943..fd928787207e 100644 --- a/drivers/media/dvb-frontends/tda18271c2dd.c +++ b/drivers/media/dvb-frontends/tda18271c2dd.c @@ -328,7 +328,7 @@ static int CalcMainPLL(struct tda_state *state, u32 freq) OscFreq = (u64) freq * (u64) Div; OscFreq *= (u64) 16384; - do_div(OscFreq, (u64)16000000); + do_div(OscFreq, 16000000); MainDiv = OscFreq; state->m_Regs[MPD] = PostDiv & 0x77; @@ -352,7 +352,7 @@ static int CalcCalPLL(struct tda_state *state, u32 freq) OscFreq = (u64)freq * (u64)Div; /* CalDiv = u32( OscFreq * 16384 / 16000000 ); */ OscFreq *= (u64)16384; - do_div(OscFreq, (u64)16000000); + do_div(OscFreq, 16000000); CalDiv = OscFreq; state->m_Regs[CPD] = PostDiv; From patchwork Mon Apr 29 15:04:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647232 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 7B092C04FFE for ; Mon, 29 Apr 2024 15:14:17 +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=4ttCVejLR8CzTLsdiI8MCbPs9RpC5Gi6oxqXvzhSje8=; b=nBkf9zIWmw0lVx RqfHXPnzvW+LN/M96CuxZxaBx33FQggIT8QcvgpE8K4BBjP30yebaKYIhFHtc4Qij1LUGc1pj1wDM gRNq2yr79KUL08Hs3wVUd41qzFJaMPoZG5jK7W1Uj403jREdXHhbzq7wc5aLv+R+o5RT9bU23feWG HpQKZgsPv7mrsJyPESrIbO6c06V0FR6kD5oBPq+dIe0efW1rC/ohO3y2uyrRfslF4Zhu2+PQVMS7H e66wh4R5cHHDQ895DlQIJCPr2nC+uLJMyxZnv35TgC+77APXRLTR8/3FV5TN/DGpn5LaELA2AwZM7 9gjl+errPyrYmkmv3mkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Shi-00000003L5T-1Zqz; Mon, 29 Apr 2024 15:14:06 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1She-00000003L3L-2MXb for linux-arm-kernel@bombadil.infradead.org; Mon, 29 Apr 2024 15:14:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=JNRsm9gIh82mFVXKJ+HUiStpAhIByx8KXG3SUDPUD70=; b=DOHSy2ldswQESG+20T44MkW9V3 GbDU+WzUPS+Gd7z2WDrAF8U639HjNk2O3HddzKskQszFYDWBBXbmf0SX1r/WAqqr4vkQtcOW4jaD2 XOIghDW5SgGLqw0hUS1BAXVTUhkqmGaiKJcAZfXIp4bXr512h96adZoCVSbDwdkH2uwxrw5bADR9K 4hl/gE6kg9PS6fxXdFVzTWvjIyrkg+W9XyKgx/N8ps7baaYxhoCgsi8VHCQ83HRyRQT3ELADc+Rz9 Ej/v27hwYXSRjjZwqNM5GnwRM9cOm7V40dTr1O3PZyW1047J+4+DxhabrGonqYpDw82t8gPqvWzJ3 FhBXL2rg==; Received: from [2001:4860:4864:20::34] (helo=mail-oa1-x34.google.com) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SdF-0000000GYM1-0wOd for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:13:31 +0000 Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-22f01274622so2545204fac.1 for ; Mon, 29 Apr 2024 08:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403092; x=1715007892; 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=JNRsm9gIh82mFVXKJ+HUiStpAhIByx8KXG3SUDPUD70=; b=hEc5++2UcZp97mqO1ECi/cGFqwIa0pZy13unj4rLqMDNCxYey3RVCahSnvXeP9f1wd QBIgMe59FJnPuPaXwa6Un6OIywAE/GoE90f6sK9Nd+oRDGdQrmcVFIMzqGo+7ptGcxY5 6saSjhmVLYcpuPgWvOFpkFpqYF+mBmur6dlNE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403092; x=1715007892; 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=JNRsm9gIh82mFVXKJ+HUiStpAhIByx8KXG3SUDPUD70=; b=u7ni00IsGBHb002zk6k64hnj9VcpppMUqBvxp9Im78Y8YqScBNhSTFs4TNjT4v53Qy s/Kx343cMTWzih+wD6cpnYleeVTuSHCmiZNUbZe4lAWHwnGDe7OIZQgSFvfkYp2X2Zz8 ucATfWi1YEgMSyE5PmZwbFMFoAIwyCONzMW+S8G65FdEA7BPAKD/Y7HNXBeOlBVdcGCA 6wKk8l+GacKFqc1R6rMg+9UqhGqvGGlzGqvkS8NkfXmyaMO3A9SEHML3NY/eFNskN8em AiqvEuf6nu2HKFSjze0sZwaFYT+D4LeU4Hg0Qg9GNhGmVLZ31lRSNwNQwchqmzbGgVOV ri/A== X-Forwarded-Encrypted: i=1; AJvYcCX0WqIxZAlqPuHeJ5nYoTl5iguV/OCS7h7NF+U0I2WpPoi62VnptblQthY2M/pVNnsSeIDVaHsLY80i0GzlaT6NVeI13tSb2wQaNOjzE7YgrnRLVAg= X-Gm-Message-State: AOJu0YzaCRNsE9QEQWwEJzyuTNk9pgMxz483M+Xpj4PCkKrZK4KkvYM7 29hmelP88tA/s+rgziaxMUzH9y1LK0ucVM/N6Eelq7HqMAQYMkukEgP+9F6hZw== X-Google-Smtp-Source: AGHT+IGXcStN+XAFfYHJlQ/BhJGSDUpZDAykPn1StedMjlrpGT2G5swu1IRQFedvTjeL4JvuXpf10g== X-Received: by 2002:a05:6871:a416:b0:233:b5ef:3bab with SMTP id vz22-20020a056871a41600b00233b5ef3babmr9216406oab.3.1714403092563; Mon, 29 Apr 2024 08:04:52 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:52 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:48 +0000 Subject: [PATCH v3 09/26] media: v4l: async: refactor v4l2_async_create_ancillary_links MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-9-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_161056_124475_01440B1C X-CRM114-Status: GOOD ( 13.04 ) 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 Return 0 without checking IS_ERR or PTR_ERR if CONFIG_MEDIA_CONTROLLER is not enabled. This makes cocci happier: drivers/media/v4l2-core/v4l2-async.c:331:23-30: ERROR: PTR_ERR applied after initialization to constant on line 319 Reviewed-by: Bryan O'Donoghue Signed-off-by: Ricardo Ribalda --- drivers/media/v4l2-core/v4l2-async.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 3a22da443a22..421b2b96bc8a 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -316,9 +316,10 @@ v4l2_async_nf_try_all_subdevs(struct v4l2_async_notifier *notifier); static int v4l2_async_create_ancillary_links(struct v4l2_async_notifier *n, struct v4l2_subdev *sd) { - struct media_link *link = NULL; + struct media_link *link; -#if IS_ENABLED(CONFIG_MEDIA_CONTROLLER) + if (!IS_ENABLED(CONFIG_MEDIA_CONTROLLER)) + return 0; if (sd->entity.function != MEDIA_ENT_F_LENS && sd->entity.function != MEDIA_ENT_F_FLASH) @@ -326,8 +327,6 @@ static int v4l2_async_create_ancillary_links(struct v4l2_async_notifier *n, link = media_create_ancillary_link(&n->sd->entity, &sd->entity); -#endif - return IS_ERR(link) ? PTR_ERR(link) : 0; } From patchwork Mon Apr 29 15:04:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647157 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 4A41FC04FFE for ; Mon, 29 Apr 2024 15:06:47 +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=3xvoe7SQrSYQ7PC5MIbVhV7yGXq9saXfO3UgIQgCivY=; b=fHzkny6E58Soka +1wG05+u+Ky32VZ9ZIs8h6ixhvtFkP4NYc6cXRDzHrRzT0MbfIwNPDyIkM2hQ621pwvSjBb32fOze GrjGPWMMbePqg3rTAGZT1/yBXx3yCj/BqId8IGy75KvidznC9u2NAtzwg8/txy71oD/AKQKKPbVmG aPIT5e7OBNTondPn19XRvUx9im+Zjq9jaNbSVI6f1RstIX1puXQ4l/wwd+WKAsZucrcmb1DbHy8f/ 65FaRnnYevU1HAsRqV1jlOkpfnURg+e+wQSkWk8dWyJtnPC4W9kxL/hmDlnqmR7poGGFSGoFU5zBQ MbJftRJXx1WQdr8CpNHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SaL-00000003GIr-2sVQ; Mon, 29 Apr 2024 15:06:29 +0000 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYp-00000003FOd-0Idd for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:04:56 +0000 Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-78f049ddd7dso369257085a.1 for ; Mon, 29 Apr 2024 08:04:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403094; x=1715007894; 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=I5MK517M661jXeUTMXVPJlov9z4l8/dISyr2IlNuzMY=; b=UwbYySCupR21ZFXjOXxaAIXCA/xOh1PfFAtxmC/YL39+YOlt7qH5HZt2RSYUvT8hS8 XDgK1M6qdXnfSbu98rBoJOyrvcB6YHLn+64dRiJeffi2LWJUIcdlMCrPj49sFcv08PZz qhg/ZOHkF7usrV6RPyffhy8U93fzETFqJzUlM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403094; x=1715007894; 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=I5MK517M661jXeUTMXVPJlov9z4l8/dISyr2IlNuzMY=; b=OE1jMeqOVgj4X7G4PJ5+zxyLql5N5nQ0qJI3ljvNkgqXvpGMfVXR6m2QCDQIPYaHmm pfRHb/PXg7E0X6qF7ranohiv24KK1K27rHfB6ZYi04+Um458aQJcDTSxJ8xtC8GUAsUI rdoK5E2Ir8TSq3bg8AEAFh8+knl3jbBK2cc4PDuIfy2Z1Rums4Gh4xAuqVbskpDn1Ihf C6ahgUbh/ZAG4McDZ+Y5HySpjQS3+L+ZVvpjaQi+B5y+zse6BB7Knq+80wdXYB/GOsUS XG4216kL5zI7zSoMml/TbBSFJSgNkAeIiradKsOnddOpTRl0eLZWRMcs42Gzwgzrq9II +LpA== X-Forwarded-Encrypted: i=1; AJvYcCV1FdC6EHfxdW4Vbu4rlUMVfJE1R9e0rl0ElGfY++bU/eU8cYA292r89mRcXW8UiBXUQ7bme03qCtiJzkWKIh9tOSSFkp8gBH6bhiOT3WccLKp6PHA= X-Gm-Message-State: AOJu0YxxxTGCpq43zeGHccHfIdAN8Pye8BaDEz29tRD4Pu4hxUB+Hzjv I/OX0BjY/bNWrhrGK6tpAbqi7/sapwkzOLR1PS83PEFJrJLR9wleMWSvye6kxw== X-Google-Smtp-Source: AGHT+IHd6ddxHUwcI+GO63TKnOLl3i4M+Xxc5o4/p3XMVcglh0UUR3rtSUQc8AjhdVbPbvMA6ElG+g== X-Received: by 2002:a37:de19:0:b0:790:9eb8:b6ec with SMTP id h25-20020a37de19000000b007909eb8b6ecmr9509923qkj.30.1714403093917; Mon, 29 Apr 2024 08:04:53 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:53 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:49 +0000 Subject: [PATCH v3 10/26] staging: media: tegra-video: Use swap macro MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-10-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080455_201928_88ADE045 X-CRM114-Status: GOOD ( 12.56 ) 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 Makes the code simpler and cocci happier: drivers/staging/media/tegra-video/tegra20.c:324:44-45: WARNING opportunity for swap() Reviewed-by: Luca Ceresoli Signed-off-by: Ricardo Ribalda --- drivers/staging/media/tegra-video/tegra20.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/tegra-video/tegra20.c b/drivers/staging/media/tegra-video/tegra20.c index 630e2ff987a3..7b8f8f810b35 100644 --- a/drivers/staging/media/tegra-video/tegra20.c +++ b/drivers/staging/media/tegra-video/tegra20.c @@ -317,13 +317,8 @@ static void tegra20_channel_queue_setup(struct tegra_vi_channel *chan) chan->addr_offset_v = chan->addr_offset_u + stride * height / 4; /* For YVU420, we swap the locations of the U and V planes. */ - if (chan->format.pixelformat == V4L2_PIX_FMT_YVU420) { - unsigned long temp; - - temp = chan->addr_offset_u; - chan->addr_offset_u = chan->addr_offset_v; - chan->addr_offset_v = temp; - } + if (chan->format.pixelformat == V4L2_PIX_FMT_YVU420) + swap(chan->addr_offset_u, chan->addr_offset_v); chan->start_offset_u = chan->addr_offset_u; chan->start_offset_v = chan->addr_offset_v; From patchwork Mon Apr 29 15:04:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647161 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 9A856C19F53 for ; Mon, 29 Apr 2024 15:07:26 +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=RQ98EmPxe6piqh+9JvNRF9MAUCVzuZ3pQbXJ+CzmRLo=; b=IS3OY4U/byf2PF hcw1KAHgobeVZjnbZ3+ENN0dZbg+J8l9IvRFKyOCzqr5xeLJHh+YOgISZ2HXuI4hdTOGZYzTLosYg zilng+zlLuxnO6n8ltTaDG9qgSi1eqNG6GmfckX6NbldoHF5VY1XjgF8ZA4wZuZkEc+yh7VIeLmWq 68nrTN8EC7tDeHr7UCPABHAyoHtM4MjXjMHFgnUSKqJS8kLA94jZSS8KkQOtYmMiKXL7hRXrZmOmE auCLBvlzAeh6JlnpYEzmqqBusGTPGGyqxbW2RaDSTCg0v/o4LWoqjjtxnawz7cpmY63/uG4peeH9t r8o31MBeJQB96/LXFf+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sb4-00000003GmP-08kZ; Mon, 29 Apr 2024 15:07:14 +0000 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYq-00000003FPM-2124 for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:04:57 +0000 Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-790f4650f93so114841985a.2 for ; Mon, 29 Apr 2024 08:04:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403095; x=1715007895; 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=M/K5Byxt1ig+CQr/X/PeYwmg4ty1EjIby+WFZ625f+g=; b=eqFaMViqzuztUD6qhJMs1PN7KAVaUKfNv53vK/8e8y/w9ObjZ8vG2N2VKeE6HDjK1f WPchHndBtOhx2sJMN4xmQ0tCo8JByKL2BhL0CS0BePy8M1eEyhlX/HNJRwvHJ6i9aiVR 3B+dNsC0s8HXNcRelIGohvq+EhIyy/qSNl/s8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403095; x=1715007895; 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=M/K5Byxt1ig+CQr/X/PeYwmg4ty1EjIby+WFZ625f+g=; b=BdfQEsDazNOoQ+NhyIY8IPGsvwkkGWxyfYuKBvR0LlDRjtzbk5v3J11qzMCEx4vYNN IX4/tfosLJsz+No8cDbaoEw6njhs23fnm1g4AzLp6j46nKa3NtZvW/G6sPeL6Nk+slre zVkWsz5FuKDTUwZ8EXWiEcgUEtcjjuSkl9uIyZAFNk2aihhg6mTcRlBhPBClS+OVxdLi 2N8Io+PjFYvzt3umv08K/pJJnaA0jMTO9q7ShauwNsDbbVI2rIC9qJ1mMLasR4IZq4J9 5NasTKhMOWP9HxmNGEG3EldZ8vBJHdzqOeXnQG0OWe/WaMnEuJUfEyvAj9aQ4A9CFoe3 UHZw== X-Forwarded-Encrypted: i=1; AJvYcCV0qrW75Q2HZiSxyfVxw73dHFUftfsn8y4/mZBcL69vcebsJypzR81K4ir6aYcMJsOkKe3GUtxZtdjpvPslMNZaBLHeAginOptOvH2Uszrjo8yueM8= X-Gm-Message-State: AOJu0YxBKox+NW2tU8NR1omr8153nu+gfuxROcij/K+q1JUhjMfaFy9Z y5Qqdcq/h2I8Le2fiY/21hmqOvNMy47+m++VkpV7D/2wFjGURRtqcNFvRkWAQQ== X-Google-Smtp-Source: AGHT+IFfkHTGOiMiEN/DumhtisfWTU2X4/tYd3muzzupABl3mh4QKavP+6J3XAW0kBG33eeQdwXV6g== X-Received: by 2002:a05:620a:298a:b0:790:f2b2:ed2e with SMTP id r10-20020a05620a298a00b00790f2b2ed2emr5311152qkp.64.1714403094908; Mon, 29 Apr 2024 08:04:54 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:54 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:50 +0000 Subject: [PATCH v3 11/26] media: s2255: Use refcount_t instead of atomic_t for num_channels MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-11-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080456_604985_141B57FB X-CRM114-Status: GOOD ( 16.53 ) 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 Use an API that resembles more the actual use of num_channels. Found by cocci: drivers/media/usb/s2255/s2255drv.c:2362:5-24: WARNING: atomic_dec_and_test variation before object free at line 2363. drivers/media/usb/s2255/s2255drv.c:1557:5-24: WARNING: atomic_dec_and_test variation before object free at line 1558. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/s2255/s2255drv.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c index 8e1de1e8bd12..a6e450181fd0 100644 --- a/drivers/media/usb/s2255/s2255drv.c +++ b/drivers/media/usb/s2255/s2255drv.c @@ -247,7 +247,7 @@ struct s2255_vc { struct s2255_dev { struct s2255_vc vc[MAX_CHANNELS]; struct v4l2_device v4l2_dev; - atomic_t num_channels; + refcount_t num_channels; int frames; struct mutex lock; /* channels[].vdev.lock */ struct mutex cmdlock; /* protects cmdbuf */ @@ -1550,11 +1550,11 @@ static void s2255_video_device_release(struct video_device *vdev) container_of(vdev, struct s2255_vc, vdev); dprintk(dev, 4, "%s, chnls: %d\n", __func__, - atomic_read(&dev->num_channels)); + refcount_read(&dev->num_channels)); v4l2_ctrl_handler_free(&vc->hdl); - if (atomic_dec_and_test(&dev->num_channels)) + if (refcount_dec_and_test(&dev->num_channels)) s2255_destroy(dev); return; } @@ -1659,7 +1659,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev) "failed to register video device!\n"); break; } - atomic_inc(&dev->num_channels); + refcount_inc(&dev->num_channels); v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n", video_device_node_name(&vc->vdev)); @@ -1667,11 +1667,11 @@ static int s2255_probe_v4l(struct s2255_dev *dev) pr_info("Sensoray 2255 V4L driver Revision: %s\n", S2255_VERSION); /* if no channels registered, return error and probe will fail*/ - if (atomic_read(&dev->num_channels) == 0) { + if (refcount_read(&dev->num_channels) == 0) { v4l2_device_unregister(&dev->v4l2_dev); return ret; } - if (atomic_read(&dev->num_channels) != MAX_CHANNELS) + if (refcount_read(&dev->num_channels) != MAX_CHANNELS) pr_warn("s2255: Not all channels available.\n"); return 0; } @@ -2221,7 +2221,7 @@ static int s2255_probe(struct usb_interface *interface, goto errorFWDATA1; } - atomic_set(&dev->num_channels, 0); + refcount_set(&dev->num_channels, 0); dev->pid = id->idProduct; dev->fw_data = kzalloc(sizeof(struct s2255_fw), GFP_KERNEL); if (!dev->fw_data) @@ -2341,12 +2341,12 @@ static void s2255_disconnect(struct usb_interface *interface) { struct s2255_dev *dev = to_s2255_dev(usb_get_intfdata(interface)); int i; - int channels = atomic_read(&dev->num_channels); + int channels = refcount_read(&dev->num_channels); mutex_lock(&dev->lock); v4l2_device_disconnect(&dev->v4l2_dev); mutex_unlock(&dev->lock); /*see comments in the uvc_driver.c usb disconnect function */ - atomic_inc(&dev->num_channels); + refcount_inc(&dev->num_channels); /* unregister each video device. */ for (i = 0; i < channels; i++) video_unregister_device(&dev->vc[i].vdev); @@ -2359,7 +2359,7 @@ static void s2255_disconnect(struct usb_interface *interface) dev->vc[i].vidstatus_ready = 1; wake_up(&dev->vc[i].wait_vidstatus); } - if (atomic_dec_and_test(&dev->num_channels)) + if (refcount_dec_and_test(&dev->num_channels)) s2255_destroy(dev); dev_info(&interface->dev, "%s\n", __func__); } From patchwork Mon Apr 29 15:04:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647163 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 945E5C4345F for ; Mon, 29 Apr 2024 15:07:33 +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=PTpFBFMFb7+ua2Yho6Wgm7e2NMPhrXe8y78gH2oylZ0=; b=4znUWVaIlMQVHJ BkV+72Xw4YZUY84uFZYQXA10Qcroc3oGBccGPGj8grWpBOzN9do9NNJPiQO+bj1ToKMPGxVpZfq3w VUTtq6HdaX0/yLRYzUT6a/zYylywI0wEAX6HG1u2fs8c8Qnq6bjmawjHaOsr/WN+fqs5eWFXhY/K1 PmA/Nz0MeuF2R1GTT4COVAwYB8+bCw7Xgtg1XWK5vrz8RvSuU3XY4fq5j1w9Z3Vdkrh/m6YGNKxr0 gKk3/MrIPG0tMRwcS5hOFbRF7y7lbwz7vA3tu2V1fpcKjHWMLSppYaINcUr5fk2t4GX1zX0A3b7ZL JF7FlAsX6OBT4TtL3FwA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sb5-00000003GpK-2orG; Mon, 29 Apr 2024 15:07:15 +0000 Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYr-00000003FPw-0XHd for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:04:59 +0000 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-2352cc0b076so1779339fac.0 for ; Mon, 29 Apr 2024 08:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403096; x=1715007896; 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=X5IbU7HBHK5ZSrS81fN3o3XopIPldfFFy8PdyHH7F6Q=; b=dpfhdF9Eun2gaFTf2F7N+xteLIY6RxLFshuqqCDcGFC0rnQmlFizE0KKbI0fbaOm5F bMRuUdJSkTbOqkPkGJiw3Jcdj47YVbvyJwqX/O0OQk3r9bTK0zOWSPKUKWQgOVG6gv7c fhT1rPZQgI9rnv8h6cjxI24bV5PF9IUZZc59M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403096; x=1715007896; 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=X5IbU7HBHK5ZSrS81fN3o3XopIPldfFFy8PdyHH7F6Q=; b=L16a3Ni6P8G3Q+RKld971AwF8XDYNueaogk3XLnQLvSsOLwgfEEcWv1MxubueB53ZC bF++FfUz8OjiCQqd/Z84vlLm+ARxeNScl6oJH19/JAnlMVKucLDnS5hmlLA0c4SPtzlc 2GbGjf3EN6/N57Loxh32IxG24HiAO5Tn+wGvwt4euxePiCQln5cJqOEAQCejGNoP/RyN NPmWEHFMzu/ckcs3joWsOO/iV43w4sY7vmqiHti5mKgMvUbscCezmRizuGnZtbcemT8i uOsfloFom5LfVg2U4M2PQDOlH88ly5kR4aLA1GMe939dYNzgl4iHHrSv7lFcDsraoLS+ Gjyg== X-Forwarded-Encrypted: i=1; AJvYcCXptIjL8CXCLUkO7td5N4Xx1chwG0BWaOdg7JbVf4GawniZRMrJwAjWtiRCZ3n4+xqIeSAf1ABmNrrz2HppJyFgpt3ylY+rbR9TzTerKNV0ikoe5xk= X-Gm-Message-State: AOJu0YyVorH8qU5x5EqpgizpptCrC9k4qZO4ypaadPtyyb82Rpg1hT9Z o/LYCqP2lAARrhUmzmypaDaGsz5UUJiodLhaiCVjmsdXOA6BU0mmCZwuAC6QYw== X-Google-Smtp-Source: AGHT+IGVAH/IwNYZ4S96l7NvgpYNIEj4hEsjMjcli1Y8ndu6kmVsTG4AE2U+O+g2MrONF6L3wD0YHA== X-Received: by 2002:a05:6870:2401:b0:233:55b8:edf1 with SMTP id n1-20020a056870240100b0023355b8edf1mr12050766oap.8.1714403095753; Mon, 29 Apr 2024 08:04:55 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:55 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:51 +0000 Subject: [PATCH v3 12/26] media: platform: mtk-mdp3: Use refcount_t for job_count MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-12-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080457_349751_8B00D540 X-CRM114-Status: GOOD ( 16.17 ) 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 Use an API that resembles more the actual use of job_count. Found by cocci: drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c:527:5-24: WARNING: atomic_dec_and_test variation before object free at line 541. drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c:578:6-25: WARNING: atomic_dec_and_test variation before object free at line 581. Signed-off-by: Ricardo Ribalda --- drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 10 +++++----- drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c | 6 +++--- drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h | 2 +- drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c index 1d64bac34b90..ea2ea119dd2a 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c @@ -524,7 +524,7 @@ static void mdp_auto_release_work(struct work_struct *work) mdp_comp_clocks_off(&mdp->pdev->dev, cmd->comps, cmd->num_comps); - if (atomic_dec_and_test(&mdp->job_count)) { + if (refcount_dec_and_test(&mdp->job_count)) { if (cmd->mdp_ctx) mdp_m2m_job_finish(cmd->mdp_ctx); @@ -575,7 +575,7 @@ static void mdp_handle_cmdq_callback(struct mbox_client *cl, void *mssg) mdp_comp_clocks_off(&mdp->pdev->dev, cmd->comps, cmd->num_comps); - if (atomic_dec_and_test(&mdp->job_count)) + if (refcount_dec_and_test(&mdp->job_count)) wake_up(&mdp->callback_wq); mdp_cmdq_pkt_destroy(&cmd->pkt); @@ -724,9 +724,9 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) int i, ret; u8 pp_used = __get_pp_num(param->param->type); - atomic_set(&mdp->job_count, pp_used); + refcount_set(&mdp->job_count, pp_used); if (atomic_read(&mdp->suspended)) { - atomic_set(&mdp->job_count, 0); + refcount_set(&mdp->job_count, 0); return -ECANCELED; } @@ -764,7 +764,7 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) mdp_comp_clocks_off(&mdp->pdev->dev, cmd[i]->comps, cmd[i]->num_comps); err_cancel_job: - atomic_set(&mdp->job_count, 0); + refcount_set(&mdp->job_count, 0); return ret; } diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c index 5209f531ef8d..c1f3bf98120a 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c @@ -380,14 +380,14 @@ static int __maybe_unused mdp_suspend(struct device *dev) atomic_set(&mdp->suspended, 1); - if (atomic_read(&mdp->job_count)) { + if (refcount_read(&mdp->job_count)) { ret = wait_event_timeout(mdp->callback_wq, - !atomic_read(&mdp->job_count), + !refcount_read(&mdp->job_count), 2 * HZ); if (ret == 0) { dev_err(dev, "%s:flushed cmdq task incomplete, count=%d\n", - __func__, atomic_read(&mdp->job_count)); + __func__, refcount_read(&mdp->job_count)); return -EBUSY; } } diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h index 8c09e984fd01..430251f63754 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h @@ -134,7 +134,7 @@ struct mdp_dev { /* synchronization protect for m2m device operation */ struct mutex m2m_lock; atomic_t suspended; - atomic_t job_count; + refcount_t job_count; }; struct mdp_pipe_info { diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c index 35a8b059bde5..0e69128a3772 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c @@ -104,14 +104,14 @@ static void mdp_m2m_device_run(void *priv) task.cb_data = NULL; task.mdp_ctx = ctx; - if (atomic_read(&ctx->mdp_dev->job_count)) { + if (refcount_read(&ctx->mdp_dev->job_count)) { ret = wait_event_timeout(ctx->mdp_dev->callback_wq, - !atomic_read(&ctx->mdp_dev->job_count), + !refcount_read(&ctx->mdp_dev->job_count), 2 * HZ); if (ret == 0) { dev_err(&ctx->mdp_dev->pdev->dev, "%d jobs not yet done\n", - atomic_read(&ctx->mdp_dev->job_count)); + refcount_read(&ctx->mdp_dev->job_count)); goto worker_end; } } From patchwork Mon Apr 29 15:04:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647158 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 73EE0C4345F for ; Mon, 29 Apr 2024 15:07:13 +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=o2bJ6ANx953nwnuY5/oUJ0q0RRWmltmWqe4tCkjIwxo=; b=dnc/Zw0Z1JIh26 QbONVFh2m17VqQFWNs8dh73nlCO6BHanUh/W6rdCHx4qwRbcOHF+A3DfzhrEl0H/Rhwv2CQQ1ImhJ /+S07J3XOZWsT/b2wPCRqczrBxmZhwGc0fwy0Py+9nMt7q10BJOauui97tnE1gnIDKz5zscn7SahN jHn5Td7//PAKdSs5fYvo4moyzvgaJ729sN+Xks/6wALhw3CropqJkuM7r8n8bNiZ3FqgSm8ul/hZB stRhg+lLz3XECySK52eTaOCBNjZyuPgnuifl1z6kQICCbjxySNR2F5yNOm/L70XZrGLUarcaiQ3Pd IzZGjo3Zo5/ctomWngoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sam-00000003Gby-2qPM; Mon, 29 Apr 2024 15:06:56 +0000 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYr-00000003FQi-2RId for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:04:59 +0000 Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-78edc3e7cd9so346862585a.1 for ; Mon, 29 Apr 2024 08:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403096; x=1715007896; 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=ouc75z4uJmyNonUkF5EXar7vMPGdSwUxTwWXSBMXCBo=; b=nV3ScZYPG9xyQU3Pi7VrjfMxeOwIzfEpMU0MlhoyMQ/IvjnCXvjEeXLaBdLAFOA5hz c75w3wAR59G8hZpb9qeR7nFxKgREzSw9vSmE13GjEVY1YNSTnJZCUyN+zcTaeXOZ1Gtq MEBqYS88THkm1UMJcChappdzBH37Ls7c+JWaE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403096; x=1715007896; 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=ouc75z4uJmyNonUkF5EXar7vMPGdSwUxTwWXSBMXCBo=; b=EWLWOWLDaSDVCY3gx/EksOXY3ds3lNEHpKFwOdChk8b9ixLXjsO2PsYcFVKEZF0r8f LGHoNTUYa/WJ1pwUVGa5AeWyMmEWUStZ55hS8qnqsxnbsWiWS8vXMDTQLArXsgNa0/sz S8D/4fiCB+CoSjEGSXXKvmKPaKArNPfxS2km/fTIKXeGTzSOUO3CtkAbT+4Z2UQTgCl3 EVFEf30fvw91acBdEe2R7+dloV+qwm41ycQgxO3p2cysQNjw59LBOVsHVanUSwEXYEhg igaaEPaR1qUrV/uivOxCWcPvgOnI9hRJDErAdfRDFiKozT3sVVOsOTzvVyE3GQ4z+Iwv a1HA== X-Forwarded-Encrypted: i=1; AJvYcCWuaN4VWLcgT63Wg4/gRZs2QEOCRHiW0EPDGkSDasxVoE2W0qpyM/DEL8VpmUWGk5kxpjjvFYc8h9QnQYK6LYHH3YDVef+qjpMAeoGWaumT+Y23HY0= X-Gm-Message-State: AOJu0YyHlwHMgS/BIKYFreiq6RPnXkd3KmF1styWm7vQdWG5WbkHPjm6 d9ymaQmBfCCn7y5+zW1gjyKR/mI6UNh57sNq2UbqFVTDdOe+6VmfRaIKmLAy3g== X-Google-Smtp-Source: AGHT+IEBZ4dmfr/e0QaIDLPes2AA5z7Utc0Aqd4uHb97QSLpEnTeDt3Yt9PtJFu+W2rGkPiTmePlKA== X-Received: by 2002:a05:620a:640a:b0:790:f573:2ec5 with SMTP id pz10-20020a05620a640a00b00790f5732ec5mr3631789qkn.8.1714403096616; Mon, 29 Apr 2024 08:04:56 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:56 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:52 +0000 Subject: [PATCH v3 13/26] media: common: saa7146: Use min macro MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-13-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080457_763137_DE064036 X-CRM114-Status: GOOD ( 13.71 ) 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() Reviewed-by: Bryan O'Donoghue 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) From patchwork Mon Apr 29 15:04:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647207 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 415F8C4345F for ; Mon, 29 Apr 2024 15:10:46 +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=dB7Mm8RhuRiF66Qef6NQNwKHcZF9fbGAEaZeZLTx+Fs=; b=kZt3y2iIWOjbvX uzP5JT4ZqRu83GxEbTaAwWO59J0HbS7MC7sne2H2Wfch4DUM67vm8eXh4nUpQo79ejiguWcizvlzy 8q+5/3nrRmR1CrfPGHyyQXsvVRzWe+krvb2hCSvflvdYPuKIqF+cPsGGxGyCX1tSdFfHj3K2up1yF vE6NDGyQf+uVpm3EIszC0XrNQwnElLbqeTCquBf7Qs+gnv6DofOc9vF2n8Eo9sh+olzoDpfuw63yn USJJ/4Ue97S1dfVQeONsYDuYGzUMdPo0VmhGRMfc+i6ualn087MvwpJbp38lkwhjpfjpJhSAwTawg 2BkTMeopFyBjdW4DCSxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SeC-00000003J3K-1aSj; Mon, 29 Apr 2024 15:10:28 +0000 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYs-00000003FRm-36ps for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:05:01 +0000 Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-78edc3ad5fdso398183185a.0 for ; Mon, 29 Apr 2024 08:04:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403097; x=1715007897; 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=B7WgC2+IPrCSABKNTDoDmq5evIyXV522VQOG0leEbcc=; b=dnJW1qZsDLKjRTuxn/jO/Kqc0Bb6SBxFksMIpsruwTfkctpuBVo7Qw6XnCS/JuajDo Et7iEU2zZGWisTcEUlti8Dcbr1AVhgDDLwZU0PCnxGgPBzNz/9OHhr8irnnMHoju+ZvG fx6reGdaVV1ftuOxHiO8oHvq2SmMk3wxprsE4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403097; x=1715007897; 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=B7WgC2+IPrCSABKNTDoDmq5evIyXV522VQOG0leEbcc=; b=bZOnJxdp+czQN68qURD0++XPyyk4opFDrhE2Q+t6gluGRPeuAHoGJBXC1UQ1Kg5KXs eFG7zkfAMrCIqHMjEssemX1fmjQ3OU3Ak4m7/WnRow+n91R9V7ePAsXe1/xuc0TUs0d8 Ibc+fKxIKz8I44388zIdFFsdvUhER3eoks1oGlRO32UVsE2wZ8X0q8pXzjBt3qQxDSJ/ 5tLHjHeLomdh7iyNAJn//QhhQDfC5S5zPySDNHVJWtyM5KXJ4B0karhLcggpCkFEMPlL 2O7Fr85KJSZWzh7U0HG+ccLx+mQIJgyUx9JGYFnpnst3DnA9p1U8eQj1yHpiyRPQnsA8 qTbQ== X-Forwarded-Encrypted: i=1; AJvYcCUSfMvroHhv9praI0QoDuPUM+l65Y1+ii3HftAkLqh2CGZT5jmEtH+l7QRdbzQvZEmTNAjasSjCQ/fMeawhJEg/zdPnMHvn9FGlnNb+CHm5aSU4WtY= X-Gm-Message-State: AOJu0Yw6kVFBNqfkhFHjvjOjCgBvY1/xSGhSqGRqWDStopfFIliFt6dN WVY8svCSNLo1IZO2lvk9AuUlut20ra2huXvScHzB0/3oAg4S2oHRTscLijW8qA== X-Google-Smtp-Source: AGHT+IF5XTR9AvencoZ/44RX25g9bUhd0pibp8Bru1gSUBx9gDRO27bIj/oJhNJSOtkZAwqzS5pcnA== X-Received: by 2002:a05:620a:29d4:b0:790:8656:8427 with SMTP id s20-20020a05620a29d400b0079086568427mr12321977qkp.7.1714403097437; Mon, 29 Apr 2024 08:04:57 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:57 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:53 +0000 Subject: [PATCH v3 14/26] media: dvb-frontends: drx39xyj: Use min macro MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-14-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080459_114390_DA7D42E8 X-CRM114-Status: GOOD ( 12.73 ) 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 Replace ternary assignments with min() to simplify and make the code more readable. Found by cocci: drivers/media/dvb-frontends/drx39xyj/drxj.c:1447:23-24: WARNING opportunity for min() drivers/media/dvb-frontends/drx39xyj/drxj.c:1662:21-22: WARNING opportunity for min() drivers/media/dvb-frontends/drx39xyj/drxj.c:1685:24-25: WARNING opportunity for min() Reviewed-by: Bryan O'Donoghue Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-frontends/drx39xyj/drxj.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c index 1ef53754bc03..6fcaf07e1b82 100644 --- a/drivers/media/dvb-frontends/drx39xyj/drxj.c +++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c @@ -1445,8 +1445,7 @@ static int drxdap_fasi_read_block(struct i2c_device_addr *dev_addr, /* Read block from I2C **************************************************** */ do { - u16 todo = (datasize < DRXDAP_MAX_RCHUNKSIZE ? - datasize : DRXDAP_MAX_RCHUNKSIZE); + u16 todo = min(datasize, DRXDAP_MAX_RCHUNKSIZE); bufx = 0; @@ -1660,7 +1659,7 @@ static int drxdap_fasi_write_block(struct i2c_device_addr *dev_addr, Address must be rewritten because HI is reset after data transport and expects an address. */ - todo = (block_size < datasize ? block_size : datasize); + todo = min(block_size, datasize); if (todo == 0) { u16 overhead_size_i2c_addr = 0; u16 data_block_size = 0; @@ -1682,9 +1681,7 @@ static int drxdap_fasi_write_block(struct i2c_device_addr *dev_addr, first_err = st; } bufx = 0; - todo = - (data_block_size < - datasize ? data_block_size : datasize); + todo = min(data_block_size, datasize); } memcpy(&buf[bufx], data, todo); /* write (address if can do and) data */ From patchwork Mon Apr 29 15:04:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647208 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 5503AC04FFE for ; Mon, 29 Apr 2024 15:10:47 +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=RdnUnn1DqeDKn9S0llfgkh7xlSlzwoStITrFN5mfIsM=; b=YIO0XcmMnUfIqf iDUMVQ89ggib3HOpixtmERLwJOp5B6wmaVfidE50NvcpvABPVGVEHH8C/n85GrLnZ37SQJ5abqMbk 1TBan5/pKD62GdQI0XQtiQfb2VKNhnyrCx/12PdPRkaFJ+Cd9J1Zlr1aORsT1fUo8H0FcePiQTHAk KaFrNcJJSQJRN8hL5joYWU8Sz2WoYZQhH9vutmtKwHcYiGXMYdesi6XdHP0WMA3g8xZruQ0aqEUPL LvIMUH60MMHLT65A47gXSkdOIpsnZTry8h/nwImXC62TBrFLVFFMRxuiY/tY0i737fj5a4feOpWe5 hbX1KYJ3gYNW8UGSFLQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SeG-00000003J6o-0PT0; Mon, 29 Apr 2024 15:10:32 +0000 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYt-00000003FSY-2pJO for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:05:02 +0000 Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-78f049ddd7dso369264285a.1 for ; Mon, 29 Apr 2024 08:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403098; x=1715007898; 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=oXXgUMwvGuh/bAZ05Vu9f2lIZUwmSZiJ1Ue2E9QmyGE=; b=gKdMVmmboYiRLPnHgjjgS2sNwjOt+hp7ULMWAfWMxBKmQMFDW5gwsm/o2WYxf5AuTA q6RJF1SwyWPDNFklCTcOSzhWtFL+A4iFauQYtnOEGrNB6HUuj4wNobcEF5JXdSBbxCbb 8j/lQ2hOqgGo+gAQKyAROwySV2g4Z4mmTneDA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403098; x=1715007898; 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=oXXgUMwvGuh/bAZ05Vu9f2lIZUwmSZiJ1Ue2E9QmyGE=; b=G1u3OarqST+6Xf6I8ucZpJ0Aa9uttcR8VPoLwL34XOSmmg+KM1w4Pw8VjotrF75YOQ P82xr2jyo3nYoDgTE7LDxGEgnOj6cx9wXPm5h8LM74AZBekzVdVFvQVddk5BaKm2BFgu pA2L3nmnQEbxZ2vqyPVoNxEtdaGkYXZZ+U+sWRi8FFBxTsCQRpQSJ24e2A+lfoMQ0PiJ ZYmQeYJ0Eppkj5MiVOqm0lrS5pvfdIi32lj0Rr7Ld5hIgvco7tgjgE1MbtNy8BIolldO 96RnpVdRwkN+kijcQJGhNkZMQQ1SHw62Uz8nbld7Bd9B8q2fBcrDf0ahq4qwfYVYXoFs hg+g== X-Forwarded-Encrypted: i=1; AJvYcCUn1dV5eQx+fUdmi2+2v2npoDZ7iyEVoKpFc6OowlvTxVFik8FCs7UEu4s43hJhefNoKG9iEO7a4YvzLXqNZPkDZgZQQNvoTHKjzS+kBF35M7F/q2M= X-Gm-Message-State: AOJu0YywSypvwkeoVeeJXJoyweGdv71O7YKi/hL7GvxAOJpZNaaxAAPP hp2wFG6dh8FpFJDLIUxAHbyWey0eQWyZv2ZVBVCvSneyxOrNeJy/grau1UIa0Q== X-Google-Smtp-Source: AGHT+IFJT4Q2Syc1PBrJKVClvA35sFEGet4fgiHKy6TprlGgcTs6U4UnMxlpWR+ax38rGRoBMytLog== X-Received: by 2002:a05:620a:410c:b0:790:ef3e:24fc with SMTP id j12-20020a05620a410c00b00790ef3e24fcmr5535437qko.16.1714403098672; Mon, 29 Apr 2024 08:04:58 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:58 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:54 +0000 Subject: [PATCH v3 15/26] media: netup_unidvb: Use min macro MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-15-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080459_960785_F82330A3 X-CRM114-Status: GOOD ( 12.82 ) 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 Simplify the code. Found by cocci: drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c:138:26-27: WARNING opportunity for min() Signed-off-by: Ricardo Ribalda --- drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c b/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c index 46676f2c89c7..1c885d620b75 100644 --- a/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c +++ b/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c @@ -135,7 +135,7 @@ static void netup_i2c_fifo_tx(struct netup_i2c *i2c) (readw(&i2c->regs->tx_fifo.stat_ctrl) & 0x3f); u32 msg_length = i2c->msg->len - i2c->xmit_size; - msg_length = (msg_length < fifo_space ? msg_length : fifo_space); + msg_length = min(msg_length, fifo_space); while (msg_length--) { data = i2c->msg->buf[i2c->xmit_size++]; writeb(data, &i2c->regs->tx_fifo.data8); From patchwork Mon Apr 29 15:04:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647233 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 0E980C4345F for ; Mon, 29 Apr 2024 15:14:26 +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=abb11M8114OIWGtfTSUNZy/TSVJSWZvpLeA6HDz9Bic=; b=CV6DtJml/zlNt0 pU89LKaKspBd/R4yiUJ8CtUKhqkujRF5hVUMDMSW1LS8gEziGsYz/tErYpKiZLSCeiFNwN8ErgSiX 7l7nhu4Wilro+eRRH+imYxsVgBNNjeWEzCeuR6LpVvcaT6u+sfsuackXHc7UKowFWy4DOLXH1xVMf Xrc+Z9xI0zC1kZrar/sod7n595FR1iLvfr/pYZZy8ziDLLA/JpM/KZbPBgZdHkbZhUuN4MagU6rJp euxr9L689ncLoSeYSuLmp4KfKG8xLVYeqdOZ+8EhsG7EANQ/rJDauSjyxEYL3VxW2KsOStSRLTwUw qyiUM/VQ5HoXZAWaBPGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Shs-00000003LCf-39HK; Mon, 29 Apr 2024 15:14:16 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Shq-00000003L9s-18WD for linux-arm-kernel@bombadil.infradead.org; Mon, 29 Apr 2024 15:14:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=M868xcge+vjTb4vcqz3d1wlm8C5wkLs//kWdILTOdIY=; b=nm2i61UsLT8w5x92XhoIxHvr8k TjJKDHs9UzTCDv8E7LGJiREb82O4P1vBEClikFEHjQJHsYxXFSNcc5W/RGo251FqaZcZgm8Kdoh32 xKOjkNO10hCS7WEwRP7bnljfgaEHpSwAprR5oa4gu9pqs2trXVgpBc8pQlaNypxe6glDMMeuyYfyx S8Y7GftMxXtRVKJNucImk04Jz5Imj7izHPARuqkNN0brdVeXwfKHs7/BaSgmFLst3dM8KGJs8TgLm ONtusTfXboJNu7BeV3Ms7BAa3a107fUnCWgHj+u/wlMYeKb3/7VVWC3fVTE1EqbPLIqmaWrLFOdzQ ksEa0EEQ==; Received: from [2607:f8b0:4864:20::734] (helo=mail-qk1-x734.google.com) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Scw-0000000GYM4-20Bv for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:13:47 +0000 Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-78f02298dc6so392261185a.1 for ; Mon, 29 Apr 2024 08:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403100; x=1715007900; 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=M868xcge+vjTb4vcqz3d1wlm8C5wkLs//kWdILTOdIY=; b=ls9rRXi5HTnN+2uzEiAFCATRR8quPgEFe19KuSzKXJ+nrFVU+HH43FW+X3MJGKGtVH kAbL2u11f2wHm8jI5Y+mewty+uVKMSSED2LFJxYNImkz27MYy22BjLlFdMoALQlDORxw FVPnMpaSp5FvTJXd6TSB8lzKl7mDkP8QHOC/4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403100; x=1715007900; 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=M868xcge+vjTb4vcqz3d1wlm8C5wkLs//kWdILTOdIY=; b=H+H3qe5CxWxj14IMi55mI84F9MMQXgoNStkCIxvxPb0/dg1wccnIqtanvf4JdJrRuZ ceUGk8zRuETc1monLOs946FL1QiPrQTRYGD3nfEXi4wLYy44kgQivmkWVr97VubmrBWF BABlaFW3Fu6tzIFV/7YgdvrBm2zNNA8kEU50cQkdPGnDVEOHEP8AaqL0DhqeBlFIMsHb nhrPnyfMggVYWaOsiurn3ieeH9oXZv0gmIT1wVlpFZsyzRr+jN8hqbJz6ZMMOLWeecAn feUtCwl3INXIHZfRajqG3yzi5URBUDvgS6OWr5asGrJJb0mu8cbWEAmSutY7x1wGezEM HCAA== X-Forwarded-Encrypted: i=1; AJvYcCV7Ro1pJ+Vw0Tep/QsijCYLTLGanzulZbMvMRTc8UThj5vUEd0ETc/bmoeZYAbNWKSvu584NoU4jZjjRI+SqStFkRKnhU219uUdEzmNFKwNe0ZBB1k= X-Gm-Message-State: AOJu0YxpSstksygnaY/njp4YajMQOtT2DV4+oLZOyy1CP26tiR/maUO0 8uRf+M2F+DNearbCQdUE4pKvkxo87HRqd2pagxDFUJY9Lb5o2OyhwL6Ds8ZnAQ== X-Google-Smtp-Source: AGHT+IFpnQ4ab2gf5wQortCnYRGRkza79tueM0GmMJw+OfK9t9OORYfudlojtT2eZzgU8317EfmzQw== X-Received: by 2002:a05:620a:2005:b0:790:a961:373a with SMTP id c5-20020a05620a200500b00790a961373amr16658835qka.31.1714403099487; Mon, 29 Apr 2024 08:04:59 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:59 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:55 +0000 Subject: [PATCH v3 16/26] media: au0828: Use umin macro MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-16-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_161054_912373_BADA406A X-CRM114-Status: GOOD ( 11.79 ) 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/usb/au0828/au0828-video.c:605:11-12: WARNING opportunity for min() Signed-off-by: Ricardo Ribalda --- drivers/media/usb/au0828/au0828-video.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index fd9fc43d47e0..2ec49ea479d5 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -602,10 +602,7 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb) vbi_field_size = dev->vbi_width * dev->vbi_height * 2; if (dev->vbi_read < vbi_field_size) { remain = vbi_field_size - dev->vbi_read; - if (len < remain) - lencopy = len; - else - lencopy = remain; + lencopy = umin(len, remain); if (vbi_buf != NULL) au0828_copy_vbi(dev, vbi_dma_q, vbi_buf, p, From patchwork Mon Apr 29 15:04:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647210 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 D12B0C4345F for ; Mon, 29 Apr 2024 15:11:00 +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=vG41rBZZsIFkdSUB79oMdfVs3cT0pumyJSVFXwHoZfI=; b=sNwPuL4cYNiW9u wH3oBp1AOOf5wrWCbxUIEEPT5fvj0XnfKa35InFpInBpOr1KSUYSXE+VrCxeZf25EXXla8X1OZaKs xdoKVPKVQmu94qlQYsF/5OPICTjPqlDnTUk/TWx0fQUUHVtoXiXQeXyU0zXWVT0wZ4ms3eSbLVCdq n10tfg/NaAhWTuV3FbEaXDWdgIp4muN29BtEIpEHdw6Daas7rPKWLDVD9j2lvA1Kj1dztha5Mkx4C sGfvmO4y7sX+QsCl1ZizrCWZWSr272kapaQYphuTbfOn85N5cm00F2lZpCLxCpcF4iVrcT2VsYAe0 Fpmmo/ijz5F4gITpPpvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SeT-00000003JJR-2e87; Mon, 29 Apr 2024 15:10:45 +0000 Received: from mail-qk1-f179.google.com ([209.85.222.179]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYz-00000003FVT-2hmE for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:05:07 +0000 Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-790605809cbso420848685a.3 for ; Mon, 29 Apr 2024 08:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403101; x=1715007901; 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=7GlL3qsiOGQC7mYG6gX2GhOJ6HGHUo3zfWR8UxyLbWA=; b=VME8VIoSoiLpw6IhEMqkpbFxoiEftCP2EuQRw22vQF3KA8Tg5/dMyxqOknyncOVukB n8oDpSEYPAJS24Bl/AaJyu/k06pQk6Is4zb1M4aRgwbZh5zz7zryU17CruZxP0kamokZ dVER+RWTJY1mWFJsft8DRuHMVKU3aBfFU7IVM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403101; x=1715007901; 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=7GlL3qsiOGQC7mYG6gX2GhOJ6HGHUo3zfWR8UxyLbWA=; b=EQhGrkUry0J9ItVB8lVZDUy0e4XOGFRc4aYa3btmcYf6rKCVoH3rCO99pGBVNWm8ra V0d0Iy4qmlL+uty2MwtLnSdpfh9S8wVCEOb2Eap6cv7wkfBjmTKws+nzfP4WNcmKcyaN 0QPPkX9PpM+dCKZu/1HmolSgreUx/DiwulCBuOWa7PVYasXGVS3PtDHg8My9Nw98gYRA 0yYGCp0EZvINJtFC46Lw41B2yP3qT9O2wg0xe/twtGuMLSFN3Us8/hXZel+52gRHzqup HD/b8EsoSE3DBu/uLbLFK6HIRmX4e9bea+GPwz/qqw3Xd5Y21A+k3G3J1PbuPUOoQnly WVyw== X-Forwarded-Encrypted: i=1; AJvYcCVGLftQ6BZIKfj7UKN8MByB5KHC+eQhxyM5uk1PlOH6+jvJphyq3drK415ther7XqAgcUUpjuIbKeu2TLcJT1izVLwqjJGQCj6UJUwb+CWxWNJIGzI= X-Gm-Message-State: AOJu0YzNp05WWjTDPZHvSKNuzY89jO1VPVCn3OflsZPbQhu6yJTMnMPY QoPcdAjFLbUYxaEHDcig0HW4PQLFXFHQ5yGdNYzW91bRQ0TTkuX/G7H5KBYrWQ== X-Google-Smtp-Source: AGHT+IHEbQ6k/spB/F4rjxeKOljXK5qMBOo6nR8m19hLRAfwF8PZ7AqOGD/HUUCFVnU+KrmkTId48g== X-Received: by 2002:a05:620a:28c5:b0:790:ed33:5b91 with SMTP id l5-20020a05620a28c500b00790ed335b91mr5568169qkp.56.1714403100578; Mon, 29 Apr 2024 08:05:00 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:05:00 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:56 +0000 Subject: [PATCH v3 17/26] media: flexcop-usb: Use min macro MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-17-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080505_796468_DE01FFE2 X-CRM114-Status: GOOD ( 11.56 ) 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/usb/b2c2/flexcop-usb.c:201:8-9: WARNING opportunity for min() Signed-off-by: Ricardo Ribalda --- drivers/media/usb/b2c2/flexcop-usb.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c index 43dd3c932a85..90f1aea99dac 100644 --- a/drivers/media/usb/b2c2/flexcop-usb.c +++ b/drivers/media/usb/b2c2/flexcop-usb.c @@ -197,10 +197,7 @@ static int flexcop_usb_memory_req(struct flexcop_usb *fc_usb, return -EINVAL; } for (i = 0; i < len;) { - pagechunk = - wMax < bytes_left_to_read_on_page(addr, len) ? - wMax : - bytes_left_to_read_on_page(addr, len); + pagechunk = min(wMax, bytes_left_to_read_on_page(addr, len)); deb_info("%x\n", (addr & V8_MEMORY_PAGE_MASK) | (V8_MEMORY_EXTENDED*extended)); From patchwork Mon Apr 29 15:04:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647209 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 1FCE1C4345F for ; Mon, 29 Apr 2024 15:10:56 +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=lqPDx9h5k8MiuXqaJRc5EVMlYoESh7nyUE3PFYjgubY=; b=EFhjkb8/OyiFR9 /RiXWeQOiB5+rM+OdNZyOoJ4t5JY1TuYjC49SxqIsAlBIFd/Ef5P0d0J/hO5C26Cpm58SDDp+V6nt BRURnbvXKv/jmwMhV7DreD32KXEXdGJhWGsk/CoHtjb7a3Rdc4Ub+b+mCA4ziiWnf/dgGOtezX9QB lDoaBvF1rrxYl8i5fHSWjWX9kep44hYwSsptoy+riKpCvBFsjLzATGvHmXIiSEyW46WViuYMK0sKC SLsXeDWNfkwMBPils/sFFINIEEkHfUueINrzUwAqfaU6md2gXDNc1a5AgHhycDGxEsqyD46MjvbA9 DeOWsODq/JQVSI81ZNQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SeL-00000003JBt-40iG; Mon, 29 Apr 2024 15:10:38 +0000 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYw-00000003FVq-2IlV for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:05:05 +0000 Received: by mail-qk1-x735.google.com with SMTP id af79cd13be357-7906782388aso306571485a.2 for ; Mon, 29 Apr 2024 08:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403101; x=1715007901; 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=kyue/FRqn/p1WnqrFE53P+Zy+G2t8IVLierFxkwHoc8=; b=gUL4SPwozCrSPrdJehsGd23fy+5tRaWzygPfnRvUcR5UyMoahlvcKSG2fuWyJQ1/cX kBTsUr2DkTAh/S99B4pIkY6eFDglxaGh5rY1jNO7u0+lJ68d5YACKUhPDW/xVCdfu2aK i69JaVLjnwrELdaikHpyMfWr6KoIk/kf0eRgk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403101; x=1715007901; 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=kyue/FRqn/p1WnqrFE53P+Zy+G2t8IVLierFxkwHoc8=; b=nu+/wvDBVrqS8rV2RwffbVslpABUaIi7NJZ60Psf3v7/y/p1vhmyaTCXihnkkFneGi ZpYXLJ8v1OfVWRbvSmgpp8fnYIYQuBe30kyzAG+E+2uexmDYb/mwsddnEIM6oY/gy4Lj +t3vf0ddabfoRfRNWhN5iXQrkVCx/PXmYgBwr/Ugj3dGRLjm4KJxHFeFjB2SK65QHqIt xZRpz9LYQs8DkoyN2tEnsaTOHsPa/leKJeZmWKnnI7hNi27lrmZq8HgSrapNV0Wd7KQU mSPllqMdaVYg1zmY9bswzNTTtH9yiHyoJaPDdAgkJi5d4omWqUGXEGDrefjzG7/diYT5 pBvw== X-Forwarded-Encrypted: i=1; AJvYcCXqegAAPCcY9Ba0NxnmViVLKxSNZdfQoj0Pa9/TOrVALKLCdXzRz9KcMom2VVWZZ0MrPWM9pg9vNacTc8sEBnXUfN0/StoeaRhGaM4hWpt1U5TA/Rc= X-Gm-Message-State: AOJu0Yx4psu+ldh/4xmAJq77AI9ZIgjadJKdONRUfLPOr+0AJSTK/uSY cgiPmyzARMTbo23Db0eacLMiw6oUUho4Z9kMzpoAiAsZG6+czNDkdY3VmNGEdg== X-Google-Smtp-Source: AGHT+IGL4vooVVR+0mzZmPQqvYaly6q1aVJv7Kw4xqkfiCYuQPEweu/zlD5u/57ahvXotSjFXGqNNw== X-Received: by 2002:a05:620a:2059:b0:790:a36b:477d with SMTP id d25-20020a05620a205900b00790a36b477dmr9906478qka.35.1714403101530; Mon, 29 Apr 2024 08:05:01 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:05:01 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:57 +0000 Subject: [PATCH v3 18/26] media: gspca: cpia1: Use min macro MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-18-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080502_754995_0DD15899 X-CRM114-Status: GOOD ( 11.72 ) 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/usb/gspca/cpia1.c:607:30-31: WARNING opportunity for min() Signed-off-by: Ricardo Ribalda --- drivers/media/usb/gspca/cpia1.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c index 5f5fa851ca64..14aaf36cde6e 100644 --- a/drivers/media/usb/gspca/cpia1.c +++ b/drivers/media/usb/gspca/cpia1.c @@ -604,10 +604,8 @@ static int find_over_exposure(int brightness) MaxAllowableOverExposure = FLICKER_MAX_EXPOSURE - brightness - FLICKER_BRIGHTNESS_CONSTANT; - if (MaxAllowableOverExposure < FLICKER_ALLOWABLE_OVER_EXPOSURE) - OverExposure = MaxAllowableOverExposure; - else - OverExposure = FLICKER_ALLOWABLE_OVER_EXPOSURE; + OverExposure = min(MaxAllowableOverExposure, + FLICKER_ALLOWABLE_OVER_EXPOSURE); return OverExposure; } From patchwork Mon Apr 29 15:04:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647211 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 D50FCC4345F for ; Mon, 29 Apr 2024 15:11:11 +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=TB8gbFyw6dlMHFQc45QyGRUBXy4IbY/49ARNT2BUYko=; b=vyksizYDwJX218 WBwqeEN9TxYcChiqopo/emI5YGjFInMmuGFRFQEP6ofNezSwkBPb7/Ss8pCMTUrt+EHxsD1SDM0v3 provo/eyKoWMvPOArriiAFvNLr9wCF2F5z4G104fRR2bVsOnfUf2Cc0rwAVCWP/CsVrk1eD1/jmIf OSiCR42KGXPYKWm9BgssjImi+PyzDbeqN2D8ZTKe68D81oIF1EELH4hGT8Cs2vkUjZiKa9jahn20O f1ZzqUUY/Jju/rHGwzo353OFKnUTCq7rzT2wuO9Fcj8GeGHJBZVhaaWKVCKDRy4QseGIqGxn0WSBG Vb6p4HY8tI1W/V+Dc06w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sec-00000003JRC-14O8; Mon, 29 Apr 2024 15:10:54 +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 1s1SaG-00000003GFq-2Neq for linux-arm-kernel@bombadil.infradead.org; Mon, 29 Apr 2024 15:06:24 +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=WOR8+WeMkxm0czNaQrlO8zy4rfkYFKnx5dqFso5t3cA=; b=ZFT17MzjFfALZXbPGDLKWNimfi Og0gLOEOpKvk5sTN5T5QnhwZ9vhkmjCXZnpQEO6xiWfmX1FDzOts91IElpppZE3Ir2ScPGd96/A6b 21NRahsha3TvbJ2YLRO1uwPjcOYbOnc/Wcs8soSJ/UZAUKH4/I0zPzgMm5qTe/EV5sfBSbSA5eUdd CV0nUj32HPR0fs6J4TUj1A8G6C9gHnYlbZi7rVVw3bi66vFSmqRlGI69IzsuXCTPJ4X4nQ85L6FUG vMCyetJ9fGy0d9Xa2mZOW/KEI9zGUq9Tkyog+ggyOiHjn34i8p8YWvnvskh2z83tzQCI7mm8WdUMY lwbG3idg==; Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SaC-0000000CfmZ-0bMi for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:06:23 +0000 Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-78ef9ce897bso314509285a.0 for ; Mon, 29 Apr 2024 08:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403102; x=1715007902; 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=WOR8+WeMkxm0czNaQrlO8zy4rfkYFKnx5dqFso5t3cA=; b=XiNH0pF829ceGkTdYZhF0Z9HaXc+MeVmGLSlDuqpXLmQPZHNAfgLZh803aLpKnj6s0 bKO8t9NPJyFxgHaXtklIvYA2HsEg7wEKBqhG9F7hvHgs2Xa6auhemGrvuks2SxlWMssV x7yl6iNIn+6TtdRnLhlDAeNlvQSF0KCo7yfLs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403102; x=1715007902; 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=WOR8+WeMkxm0czNaQrlO8zy4rfkYFKnx5dqFso5t3cA=; b=rbtgoJnL64roj4mNUjaUCph3eNjj56Ocy3H7KbmlgOVzWh4wimqGaLRatlmSZLxhOV qch8OFPW6/vP4iuw8VzfgK8nXLKYeIQaUdW9Z+ldddrmFUgAe8TtF1wP7NI0K8FmFKZL 9Oz+PoaJ3KODwSe6KcfEvIUTXW0N/zwgDK0Dh2RsPL1z3lNkco0onYwpHOUMZU6oj6NK dUH5VIYGdE4KAKHSnsEM88g6jBvk08JGFY3G5KxvID7PXBvc5Lw8i3tejoPgBSt3cNbg qo92Yf+qHERHvkCG4aihv2LLzdn5cfA2W0w9/ilf3MQ/zsPqmnKlVct2ubkI3mfeRcRb PJqA== X-Forwarded-Encrypted: i=1; AJvYcCU04EPJVGvCnhoVo5bhLDY6dd18r8NH5NhuSzxrHLCVHM6JbAqwL+qCnVHjX766wDyrc20BM9tpYO58SYrKmeramLaeXHsnO/ANGp6CSlOsmLZfgLA= X-Gm-Message-State: AOJu0YxjRgiPvDmSWTOcPzd147vdIb5xWfO0j01JBZxdwy4NGgnwlUAn p+/SPc/JAVbk6UL9GSbk6gIKvHnCZBdJv44ehMtdxmdeXyGE/GKTOQ8ypx8qJA== X-Google-Smtp-Source: AGHT+IFvqATO8BLnIi9vdu5lMT65HlpTVBjzYUMzQ45Qpvw3JFM44+jkXB+KR4H073WWP4wnEfgBGQ== X-Received: by 2002:a05:620a:70d9:b0:790:ac08:8d4d with SMTP id vk25-20020a05620a70d900b00790ac088d4dmr11390058qkn.57.1714403102367; Mon, 29 Apr 2024 08:05:02 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:05:02 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:58 +0000 Subject: [PATCH v3 19/26] media: stk1160: Use min macro MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-19-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_160620_265545_43251A4E X-CRM114-Status: GOOD ( 12.84 ) 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 Instead of a custom min() implementation, use the real macro. Mitigates the following cocci WARNINGs: drivers/media/usb/stk1160/stk1160-video.c:133:12-13: WARNING opportunity for min() drivers/media/usb/stk1160/stk1160-video.c:176:13-14: WARNING opportunity for min() Reviewed-by: Bryan O'Donoghue Signed-off-by: Ricardo Ribalda --- drivers/media/usb/stk1160/stk1160-video.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/media/usb/stk1160/stk1160-video.c b/drivers/media/usb/stk1160/stk1160-video.c index e79c45db60ab..9cbd957ecc90 100644 --- a/drivers/media/usb/stk1160/stk1160-video.c +++ b/drivers/media/usb/stk1160/stk1160-video.c @@ -130,10 +130,7 @@ void stk1160_copy_video(struct stk1160 *dev, u8 *src, int len) dst += linesdone * bytesperline * 2 + lineoff; /* Copy the remaining of current line */ - if (remain < (bytesperline - lineoff)) - lencopy = remain; - else - lencopy = bytesperline - lineoff; + lencopy = min(remain, bytesperline - lineoff); /* * Check if we have enough space left in the buffer. @@ -178,10 +175,7 @@ void stk1160_copy_video(struct stk1160 *dev, u8 *src, int len) src += lencopy; /* Copy one line at a time */ - if (remain < bytesperline) - lencopy = remain; - else - lencopy = bytesperline; + lencopy = min(remain, bytesperline); /* * Check if we have enough space left in the buffer. From patchwork Mon Apr 29 15:04: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: 13647342 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 41A5EC4345F for ; Mon, 29 Apr 2024 16:15:35 +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=G6Q1POLVy87He2CPgSEeLkbvJVlk2je2iObmBrYLylk=; b=G5QzsRafiZdFGn Yyo5bR80ViDwi1OXhGLP5UbPC6l0rs8ow3BOd0CV6E6Ww8XLIULu+QFmbtKQZ2MhbBolwzyAMcGJU MdVTJfPAOAcxOD6918AQMf1RFDxE12a2vUtUzQECQUuBPf36pGDghjGTNQdFTZ+w2fLCDasyIpym2 HyLSMUa8HhWJw7vsv9qDZ4jVkZ6gsnBW0H1FqHzWml5/D41JmbVMSt6s6NQP3FgZ2tD6nvoX87JPz ZMYgjfyQP45ayA2sn3ScQqlOe5LXCAQwHJKzRQs2ZnUEPau9fLChaWX1FssXQORvv5CbBYe4191yi pr7NGI4Kqi8xC8Lol4zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Tf4-00000003YBA-1zqv; Mon, 29 Apr 2024 16:15:26 +0000 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZ0-00000003FXf-2E8Z for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:05:08 +0000 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-238fd648224so1885493fac.2 for ; Mon, 29 Apr 2024 08:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403103; x=1715007903; 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=gMpzOFCFY/OFyCB78Iqov2ITRER3c7lueX7XaC40UJk=; b=gbYWN6wX00nv9deXtkedm9x6f9LU8EKRI240GEkVTtR/jcNy4NFbAkbvD9rLklLpMr N/DAbo1z95fLo2of4ZeIIcY3t1IMToDzW6M/0Xrk19csEHO1GRrn+WnusFLWiQM388zX vjKuRmQ5L5oQhA45mphjsMJ9CMIaqr8yx09u0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403103; x=1715007903; 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=gMpzOFCFY/OFyCB78Iqov2ITRER3c7lueX7XaC40UJk=; b=e7zILr3YDVwOUVUtJdTZBO6g0lm5gof3jcv9GVjP6hyWZjlQsA4MZqX6kRgeu4WIhd nKMpqiyJorbuLSRhuooc5/G5fSfvZdy58FUeDzF+n5nSRP0DEU0TYnMeT3dsl9/mEy1F UbCAlq2+47iMqTOgngxoRgu0x6RFPUx2TukfZCLvWV9aAl+lGG6L+XL07G4LQX6KP0wC 4c1vGxbvDmIqNHpRNxyyZicHup1Yzpz05S/9x8zH21krKDnFcLdoxgaqoFoPi8iBRYpo K6vMuz4ni9+KVIdlmq9HjhcLNLrolhUPqjJ1wfZqjqKw58smnZ1/IFpfaHJ5TPZVQk46 hviA== X-Forwarded-Encrypted: i=1; AJvYcCV2tezEXIjj7EX1BsuUeL65jizuU51BMw//Fw5qifEgq0ieJ7Zsh3yEp/QpVSCnVVEp/6+TAl89hKZhS2BRizWzvswatud2E2ct+0lMAEeVYTIt/5w= X-Gm-Message-State: AOJu0YwbxA6AidqyZC2buOhsiW/4gp7BfVelhQrUot+lCGYoJJvQ8IV/ NLp63jkWTgW2JwyJYDGjIn2zP57PJP1YiClSDkkiBXWWr+i8rdJn6uGGF71KpQ== X-Google-Smtp-Source: AGHT+IFhJl+kGtaYhV7Q9Gv3xiaVng6RdI8g6vF7vUpIJM3CzWksrp2O5EtILgQd8YzMcEQUTtUSrA== X-Received: by 2002:a05:6870:701f:b0:22e:d258:bc43 with SMTP id u31-20020a056870701f00b0022ed258bc43mr12416234oae.42.1714403103424; Mon, 29 Apr 2024 08:05:03 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:05:02 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:59 +0000 Subject: [PATCH v3 20/26] media: tegra-vde: Refactor timeout handling MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-20-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080506_692713_0709DB46 X-CRM114-Status: GOOD ( 14.49 ) 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 Reorder the branches a bit, so cocci stops complaining about the code. drivers/media/platform/nvidia/tegra-vde/h264.c:645:20-21: WARNING opportunity for min() Signed-off-by: Ricardo Ribalda --- drivers/media/platform/nvidia/tegra-vde/h264.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/nvidia/tegra-vde/h264.c b/drivers/media/platform/nvidia/tegra-vde/h264.c index 204e474d57f7..cfea5572a1b8 100644 --- a/drivers/media/platform/nvidia/tegra-vde/h264.c +++ b/drivers/media/platform/nvidia/tegra-vde/h264.c @@ -633,7 +633,9 @@ static int tegra_vde_decode_end(struct tegra_vde *vde) timeout = wait_for_completion_interruptible_timeout( &vde->decode_completion, msecs_to_jiffies(1000)); - if (timeout == 0) { + if (timeout < 0) { + ret = timeout; + } else if (timeout == 0) { bsev_ptr = tegra_vde_readl(vde, vde->bsev, 0x10); macroblocks_nb = tegra_vde_readl(vde, vde->sxe, 0xC8) & 0x1FFF; read_bytes = bsev_ptr ? bsev_ptr - vde->bitstream_data_addr : 0; @@ -642,8 +644,6 @@ static int tegra_vde_decode_end(struct tegra_vde *vde) read_bytes, macroblocks_nb); ret = -EIO; - } else if (timeout < 0) { - ret = timeout; } else { ret = 0; } From patchwork Mon Apr 29 15:05:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647203 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 96F3AC4345F for ; Mon, 29 Apr 2024 15:09:15 +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=u3UdVLpvFIGnoPjvRlzc01n2pFsh5faZCNRFDVG9Cys=; b=BGvnLj4Pa+xMa7 JGmcQ2B+wj+oxBk7gIZBB4h8B/ShPMnRcJSsNxWjL4MsIYUlCoP9gGmUaIFYBHAVmmTJoRVrcyJn5 k8c1qIOA96yr71Qs4x1FBBZ0iNu/5cYdOD2KvrDSBEwv36FZj4BNBZ9zhIigPg5e2uZOma8r9/An/ YlUQeBsC5S2TBxgJY5l/LFJy3qoSgvtkVR1Ke3TTPYxKANchrhrq4Pt69hn1Qvxf2ZUvBhuPqLSwB gTTEt2cXuAOFVwkS0qh5bFNqaO19W3cqyAYYbMGZ32zjrwgoTPqS2lF5BTaRUMkB52EU+pNCiTzex IQyw6nt1HbKrud4TDCDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Scp-00000003HsU-3oxt; Mon, 29 Apr 2024 15:09:03 +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 1s1SZv-00000003G3x-39xI for linux-arm-kernel@bombadil.infradead.org; Mon, 29 Apr 2024 15:06:03 +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=8OKO6D6+Uymjr7y5phUxNbL6FrIK2B37/+KaDSdt/b8=; b=UtBXE412iV8DROFNtXP7jSuqzl pFvFG9UrV7iK6fBhqY0Ce6uoC+W+NPUgxg0JDOiZVThEq4pAiH587v+f7MP5vqCPQvjEDtbG9y7dr ECX6nNhVBvPDb41lACEW4Y48N7if88uQRsEiHzSaPLP/cRDIY/KJFa5i756hOA9NvQ4ZPAgVLMqKa vIhye/y9pgs49tfdRC830nvV+LCcsa0KI3pCK6PKFYdA84gtbGAasMc0xGn+1CnfYYrx6qgLn1AMU 2m59OgeIn8+7LCGKah0wBf/TurB0DUTEFE+jgHYOFYryQAzNZcsNH/5V6fKGXTJEazPAALQhyDF2Y yzXYMPXw==; Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZs-0000000CflB-3SgO for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:06:02 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-790c36dcee9so178370785a.2 for ; Mon, 29 Apr 2024 08:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403104; x=1715007904; 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=8OKO6D6+Uymjr7y5phUxNbL6FrIK2B37/+KaDSdt/b8=; b=PCGMOXK4kni3Fq7Jv1fZQhoEsWOlcmRCCBErk1okOvO2/+VWEabUGsbBAmQsOVoYjG kL2fh4EZb6/coGRNeK2ymqEmFCqjg9mASpCj2ckdzoAgCHMpW8Bc68NuC21UseY2B8yL P5WHZFqCJfHtaiZVMZ6BQZwwIaYtl17JSEvUA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403104; x=1715007904; 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=8OKO6D6+Uymjr7y5phUxNbL6FrIK2B37/+KaDSdt/b8=; b=h61uDv28P9Gw+Kkxsq2QmpNlgiwjYt68kEi10/xTeW+PMnH+Sy7RXjHukpUqDB2ZhW PJsxpwtKAbuD4S4EuPftMGoMc75/sy12lUU7uZbK9RplAhcRORpQfujZHYmTG2C4W6XK CkXGoOW6xzLOmWRRics7lUWK+B2lBeoP/DApdQBZYHyjhZs2LCRxeOxkhqJ+qfUTnAd+ k9yTrRpOVz9xW/2w5iTjWQcv5pNRMKcDkyyDXM+X9HvkmPzgshpY4E8HEIyHuR3hzfmO /DLIQ8FeEJl7M02Vm1KTp8F2hzSNw3Is3xENXNVP82G7cYPlynv99v8WiWy1XPKm+yQ7 LXDA== X-Forwarded-Encrypted: i=1; AJvYcCXQ846dA8hXZaGDC7dicSVKXaysQa2x9kLuxDQuXJAXf7jNEHP9PMt2QVCq3f84zN5InIbglvP2VtWZKEzkAWrzlJ6ddk9h6Gd9sX7HCP2VKqPYuPQ= X-Gm-Message-State: AOJu0YyQguIRWRO7uNXAP4H2X8h+y/uWyV7w98jk19+L7RZVNHzIyRHP jCzXXr0LKkaztEJw4jez5Ou+5dCIhQm1ZDoTzjogqzoARoXNkal2oxxb99gVzg== X-Google-Smtp-Source: AGHT+IFaMtke8GiK3PVK81BO+wCQ6+s/afNMwPPBZtmDsaryJW0dODmZmCJQPhu+Legma0gxWaBb/A== X-Received: by 2002:a05:620a:561c:b0:78e:d4f6:3949 with SMTP id vu28-20020a05620a561c00b0078ed4f63949mr12152221qkn.25.1714403104299; Mon, 29 Apr 2024 08:05:04 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:05:04 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:05:00 +0000 Subject: [PATCH v3 21/26] media: i2c: st-mipid02: Use the correct div function MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-21-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_160600_904200_465CD9F5 X-CRM114-Status: GOOD ( 12.14 ) 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 link_freq does not fit in 32 bits. Found by cocci: drivers/media/i2c/st-mipid02.c:329:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_s64 instead. Reviewed-by: Benjamin Mugnier Reviewed-by: Sakari Ailus Signed-off-by: Ricardo Ribalda --- drivers/media/i2c/st-mipid02.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c index f250640729ca..b947a55281f0 100644 --- a/drivers/media/i2c/st-mipid02.c +++ b/drivers/media/i2c/st-mipid02.c @@ -326,7 +326,7 @@ static int mipid02_configure_from_rx_speed(struct mipid02_dev *bridge, } dev_dbg(&client->dev, "detect link_freq = %lld Hz", link_freq); - do_div(ui_4, link_freq); + ui_4 = div64_u64(ui_4, link_freq); bridge->r.clk_lane_reg1 |= ui_4 << 2; return 0; From patchwork Mon Apr 29 15:05:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647204 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 79803C04FFE for ; Mon, 29 Apr 2024 15:09:19 +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=mhFjwTcMOAQ/YpUwuhT1CprISPtVr4aFJBjGD3DIGQo=; b=g0VXbs3K2gy0hI jdmlmYYZtdtruvhff0rUpwsLfvK9tbHGmPuWmPTiz2C8Gk6Ub/Q/sQ7WvdSl53ZSjJVXAi7lAxOOc f1XsNPDcLF+U/Rjd1t0evJ5w8fYKd04T0kHj7COtq3gjChp35FrRYZlm2MQLMzwOVzQZoslj+bzC8 4NPf7P862PuiCfBIkNXGa/iZyEh2zNX8K4bMIJXiOjDdY1kfGDCxNSHax7udMv0Nj+zuAoKAD1Che T0O6q55whG91VgfRxzxJtMy5ALiCarXVd9FeDyH4s8/tSmqqKQ+LIGmB/ci2hxENLUlde7qcY2XFi S8G7wqSrfE8BfnycTdCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sco-00000003Hs2-3p2i; Mon, 29 Apr 2024 15:09:02 +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 1s1SZs-00000003G2K-0mM1 for linux-arm-kernel@bombadil.infradead.org; Mon, 29 Apr 2024 15:06:00 +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=H+ICFE9T0WtFgFxAAIzneJg+RkmVbFrs0mrpkqFICS0=; b=Rvhj+Th9/hYEPy8CsgHyncMpI8 PgI0V8dMar94Ly5zNiiQmgt2/E5Q64yz4srq8Vbba1VuPJzcDrpTJLWm2qBzZx8CL/Z1JVAw2dNES AiCpIhsN+mE72fk8u9QfFC40yCZECC2uNnadDS8RoeseJWSoQNOmQXqXSzrDTRegxeogkKfJu8fdF qPzNKysl9+yNVfSir4rNSmRZ46uTOWfRx6dv3w4yNydJFUdBUyQmcoTmNNTi4XCLUrxlx2p+KqEgQ FvM8qK7LrJO53YL1QDNRapDZHztrbyv/iezGw3wFIVudN8u488sDvRBV+GleKcbToa8DxOddcLnSF Uv8R2aPw==; Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZm-0000000CfkZ-3nta for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:05:59 +0000 Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-78efd533a00so336982785a.0 for ; Mon, 29 Apr 2024 08:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403106; x=1715007906; 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=H+ICFE9T0WtFgFxAAIzneJg+RkmVbFrs0mrpkqFICS0=; b=aY5za4Y3PCSTAM0/L3YfYpIrBxQk2ax8Eo9zCKgpF13I2GgVpA4skpx17VIZLtC1Am KjwRIGBGcwVQoqjVeH6m7F90DKmB0k4e+jBV/CqI517h2ju/EjAAoXf4mhW6G/1Wlo9f kGUhJRn2xEuYLwxctaCzhyfDaoA9mp+s6TaIY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403106; x=1715007906; 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=H+ICFE9T0WtFgFxAAIzneJg+RkmVbFrs0mrpkqFICS0=; b=t4zN9QPODNPsiFAKlEYKZ/g4Xg01NXsjgySEfva4GNS8dNKVl1Dtzub3xjZE/p4FAW OGHnIGS1fZIJdjNDweMFB/st17egcMHpQVtsVcLsy5pgQH5sS7xcGk+GrqOnjAWaSY6z 3wjkYImMSHLr9osvl+7rpQpK+9elXPmuyV6JXFxqFoB78h5pXcXH0TeCePXkmUOznRKp c9gR+gKW3S7gc/Z5+dtvrgfIQf1PnKOFjzlB8vZ16xBBk5qEnTxozsiPSOhtHDMxid3b ufQQxFOH+6mTDNkFqxh49C9LMivVi9UEjCSvOsTKPiI1XB8H15lkRbAqWHsfwR85GRlu quRw== X-Forwarded-Encrypted: i=1; AJvYcCVf2xFMDMSIdsYyFZkFwPnB5uYSbcPb24XjoViMpDWsFAjnxM8tafxuNCh8XHsIcOdME6GwIH97z1KpV9UiFwFlH1KuFWvaz5Q5pTiQDMO8hfXhRKM= X-Gm-Message-State: AOJu0YzDC0Dg5cW32TO52Ttn7vx+di49qBXc7p1X7HgKxK8pz+ibyocB l+SIjgEoYQ/X1mhNCRq5m+LMAQ21kIQTPekAPadh8EVe6e/bIZhx4XaoE8e5AQ== X-Google-Smtp-Source: AGHT+IE1jrRBd5HK/tPuhHP5Hku+rmhJzqzd24VfyQoPlWIHBef+7Xc9RHcUZ/XfTRZVrVfoGNJ+0A== X-Received: by 2002:a05:620a:57d6:b0:790:b2a3:f86c with SMTP id wl22-20020a05620a57d600b00790b2a3f86cmr8844059qkn.34.1714403106175; Mon, 29 Apr 2024 08:05:06 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:05:05 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:05:01 +0000 Subject: [PATCH v3 22/26] media: tc358746: Use the correct div_ function MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-22-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_160555_031904_AC0069B8 X-CRM114-Status: GOOD ( 12.14 ) 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 fin does not fit in 32 bits in some arches. Found by cocci: drivers/media/i2c/tc358746.c:847:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead. Signed-off-by: Ricardo Ribalda --- drivers/media/i2c/tc358746.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c index d676adc4401b..edf79107adc5 100644 --- a/drivers/media/i2c/tc358746.c +++ b/drivers/media/i2c/tc358746.c @@ -844,8 +844,7 @@ static unsigned long tc358746_find_pll_settings(struct tc358746 *tc358746, continue; tmp = fout * postdiv; - do_div(tmp, fin); - mul = tmp; + mul = div64_ul(tmp, fin); if (mul > 511) continue; From patchwork Mon Apr 29 15:05:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647205 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 4A60FC4345F for ; Mon, 29 Apr 2024 15:10:30 +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=ckpLMePUoEkZyIedBfYkBAPdmV+/tbMx3ksnX+lyDyo=; b=0xA5YhOQZTFNqv bNgTQ2osU3xZqeBa41PiOjjhQjE5/7fX+RaixT6+B91zb9Ep6CVCp5KR8FUv0GM5ZxcJhyI0deRqK MmjkjngXo2+NuqoPoXL+6/3knPzUOxXHqXMPJkoUwpJ8pBeSnQUfy8/2PwIvfnuouYCwWbxyxbT9q gDyqe0pdmz8mp242KHLgKAd5Mija/BDt0ONdQCMBqs9tico6G5mX1pZma+yetyEoV/Y9oYzIEr7C1 BXfegVULGslogJ/7t+oYDMsgXeWiVa8G/y1nyCxDH6n5RHrmMPtjft84Iwzivh45y6WkgW3qN4Umx Apwoq9yzClhtEXefKvgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sdz-00000003Is8-3T4d; Mon, 29 Apr 2024 15:10:15 +0000 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZ3-00000003FbS-1Lpu for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:05:11 +0000 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3c750fd1202so2703217b6e.2 for ; Mon, 29 Apr 2024 08:05:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403107; x=1715007907; 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=sSE1LZ8RJP6sIAmkq+8umDfF5CuS0FK0HNlyLUmOHag=; b=BpGdNNApxnXWD0zPMuzZaLNSVd9UTRWV3qIHg/Oiwa6GjEnVdUT7Cn4VvgltnUVQ/X N+ycV8UqyTNozD3BIL0WB4ZGwzelA0UHmKi6cHn/EVaZ6BakDcSJ47dWIP17Z4ec4cE5 DIsIAd7CZCxtilyDnEHvWQwfyr07jaFPSiCoY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403107; x=1715007907; 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=sSE1LZ8RJP6sIAmkq+8umDfF5CuS0FK0HNlyLUmOHag=; b=Nx3zN7Puu9zJHfFaiZOxv+k3U+nLBthPSGE5/TKJ6p2mgMc2P3tqTOjrLJe68mUT2E OPerqLt5gDhSBv/JXeqZ1B7EzvQ9MCCAmHwmFaq1+E0vfcYMcSyytdJaj4ZTkxjWnII3 +HGtVG66yqDThHdRcoJ7ZAWEjmpsf+FX3agc8drZtaJTdeyJ6P9c6nxkrxaPUuUmC1Kt 5MTfIAFE16cBmf2c2afFWL+E95BZfurtwymVXpfxDXRPZ1TOjFdLh0hAR2ZO/aIHKRUA I3mlPdYCCc1+Spp1BItS2P8rRY6ZbTlWGHsS0m7KZWL8HXYz0XLt7wxf/bvuy2rmA36f fhhg== X-Forwarded-Encrypted: i=1; AJvYcCUWJBBHxaZhcfiEhf8lFGZ6Ae1+7jgF+laFBmEhv4U/qLik1pPHbKuWuFKpQPlJE27+Gy4tjZgRnAaK6zYTe5yQfNoajyDZyF4chLmewBpbLJMDrmA= X-Gm-Message-State: AOJu0YwBl4YmMeErARQDClJRq2u1thBfaE3q2P/cdQlEyVIIFPypIBST HTQtZEo/eKHcJsva29ujiDFwpr40QO3FpISBEi2OrOmM67cBnE2bE3U1ngkxA2vQ8dFTCaz7TNA = X-Google-Smtp-Source: AGHT+IH4U39JmXtitBebyQXf3RiEBhrVCarSNwVpuxhIdD3y/YgatSZWK47F6u8fGZIDpkmTeNgcdg== X-Received: by 2002:a05:6870:a70e:b0:22a:9c40:3782 with SMTP id g14-20020a056870a70e00b0022a9c403782mr12043126oam.11.1714403107649; Mon, 29 Apr 2024 08:05:07 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:05:06 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:05:02 +0000 Subject: [PATCH v3 23/26] media: venus: vdec: Make the range of us_per_frame explicit MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-23-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080509_637732_B250EC47 X-CRM114-Status: GOOD ( 13.43 ) 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 Unless the fps is smaller than 0.000232829 fps, this fits in a 32 bit number. Make that explicit. Found by cocci: drivers/media/platform/qcom/venus/vdec.c:488:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Reviewed-by: Bryan O'Donoghue Signed-off-by: Ricardo Ribalda --- drivers/media/platform/qcom/venus/vdec.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 29130a9441e7..2b2874aedb2d 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -464,7 +464,7 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) struct venus_inst *inst = to_inst(file); struct v4l2_captureparm *cap = &a->parm.capture; struct v4l2_fract *timeperframe = &cap->timeperframe; - u64 us_per_frame, fps; + u64 us_per_frame; if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) @@ -484,10 +484,7 @@ static int vdec_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) if (!us_per_frame) return -EINVAL; - fps = (u64)USEC_PER_SEC; - do_div(fps, us_per_frame); - - inst->fps = fps; + inst->fps = USEC_PER_SEC / (u32)us_per_frame; inst->timeperframe = *timeperframe; return 0; From patchwork Mon Apr 29 15:05:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647201 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 8A6BBC19F53 for ; Mon, 29 Apr 2024 15:08:39 +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=vFtovAQXQEQs9BUPzoyhREkFyr65zMUYKjpps/ZwHXY=; b=YvQbhJB7WFsuFR olIUKupJKYFzk4TIF+rp8Tn59MtsCsv1jd5kJVfj1//ZLdgEmgdrDoonfT+9Ba8/3ZssjhWIGd+IC Dg3h6/dvPmf14J2zQ3KQbxoRXFQSQc6doPhsLi5MB2jq8DzTWylCZDy2E5dkNoMX0YLuAV1XcRQu7 SvUleCVz8lZVRuDdUM+248D7RSFlBi3/L/9KpYLMd4Y1Dlz6fS1L4t0De6yNS3LZUJRrgZiA2EoBb WirS8oB7LNyZuirD23528YhVKJd8dozJSJSYolMfirDhGfEBkOdllMXr0xPMTAZKGm8bXPBSAK26g lTrS4mYg+3cNbr931MUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1ScE-00000003Hc2-0HO8; Mon, 29 Apr 2024 15:08:26 +0000 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZ4-00000003Fck-1jSM for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:05:12 +0000 Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-790ff1fa7b3so45316785a.2 for ; Mon, 29 Apr 2024 08:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403109; x=1715007909; 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=WhbcF3TWQTA5MkpkxmSIX7qa4yJQy6aIRpdafwtebNs=; b=OZlNwpYXS3tYLDmuay6yfhhhr1I9yXqLegFC9A3f2uJ3oM4lVHbu/ni0ZIZ1Nur+QT Fv0djoqo2r0T+FKR6pZDSEMlg8TPN6JIRf80M/VB6zZWeoJixGE+UYkL8FSwgBKF8cYl Q4Qf3vUFvt1rqwutlIMDlxYWBZ85hlfsovJzU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403109; x=1715007909; 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=WhbcF3TWQTA5MkpkxmSIX7qa4yJQy6aIRpdafwtebNs=; b=kX7sYRhALQSV5YsbiibTmUlMaM2QyLeTht+LNIvma8JHJ4jupbApAjKCdPdIfLv3BO 4Xq3wnnkn8Y2ye0L+daq8TZWAtwlcpu+Mh2SRWBgk7NoynnLQJvKutNJtjOl78UidPuB BYtCkIluQtiZBWoJ2smvHl8ab6V7hgrchYbTgp5dWToNS1x3qkuRmoTF8Qwl9Itm8XIe 5JylkzyzXppW9rEB4TYQSUE4M6hfZOUOHVnCNF2BCKzLg5D0nB6LYrOyQ60My93nL3sl U/o2cF5ylwf/6DJp8SbkPT51J1CyZY/FpG6bypcfoZd2QgiVgPDDU25kp/MWohYIw+lb ECLA== X-Forwarded-Encrypted: i=1; AJvYcCU/f9p4HR1KOOhDtowF44/DZWoHvfFDjV/4ROpJs+isyZpPvq4BnLK0JyrRImHXXzTJ1iKrDBCDDdWo/IkO6s62r9p9CJIeBa09iDlO3nhT9/jSp/A= X-Gm-Message-State: AOJu0Yw3LyBM5RCInlrwX6ixshVycKxWCG6zwiyEdxqj+WVH9anQLkIl 2jfEgDaKirezZ0L5tFCHyp7rqGX5/u6tGXHXK5A+CUjm5b90SeZmC5nQboeqsQ== X-Google-Smtp-Source: AGHT+IGs4sEEfsd0KHK969uVD2lhoqcTxzDs2zjOqF/5cv6aPK5AvcxX8HFB2EOaJeVcr8eLM013oQ== X-Received: by 2002:a05:620a:8204:b0:78d:6479:7c39 with SMTP id ow4-20020a05620a820400b0078d64797c39mr7471552qkn.19.1714403109214; Mon, 29 Apr 2024 08:05:09 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:05:08 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:05:03 +0000 Subject: [PATCH v3 24/26] media: venus: venc: Make the range of us_per_frame explicit MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-24-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080510_511117_E23E77A0 X-CRM114-Status: GOOD ( 13.43 ) 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 Unless the fps is smaller than 0.000232829 fps, this fits in a 32 bit number. Make that explicit. Found with cocci: drivers/media/platform/qcom/venus/venc.c:418:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Reviewed-by: Bryan O'Donoghue Signed-off-by: Ricardo Ribalda --- drivers/media/platform/qcom/venus/venc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 3ec2fb8d9fab..f87e33a34610 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -393,7 +393,7 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) struct venus_inst *inst = to_inst(file); struct v4l2_outputparm *out = &a->parm.output; struct v4l2_fract *timeperframe = &out->timeperframe; - u64 us_per_frame, fps; + u64 us_per_frame; if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) @@ -414,11 +414,8 @@ static int venc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) if (!us_per_frame) return -EINVAL; - fps = (u64)USEC_PER_SEC; - do_div(fps, us_per_frame); - + inst->fps = USEC_PER_SEC / (u32)us_per_frame; inst->timeperframe = *timeperframe; - inst->fps = fps; return 0; } From patchwork Mon Apr 29 15:05:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647202 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 7BCA8C4345F for ; Mon, 29 Apr 2024 15:08:49 +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=IcGMDNEQDU9R3leVQWEAb8sk2hAlmfSZJWYPF5l3WJQ=; b=FhDg9GFinYrw0e 8v8KTir1H5ghxDBjRz4EMaYWPMJIBseiHFzVa0zs130NzxJ9/jZ7Vduhdf2sDZY7D9mzAMDrUpKtZ GxcrKt3F9qWa4RZAoir4XpF5gWd543phkkqG1aShm3K1JeMkBhDfdKFY9ndiDNyLze7MMuUKjW9A4 iL+QHyJiYNJB6jdUbPacOvPoeVMKqoDCIaNObr/V/9IhPn1MGmoL+v8cMlIrE1n+GmwzH9bGkFjq6 iMug3g1PWOAjCfQnqHZ4hYzq5yYVkQukr1vv2FBI9+PFC2tZgrkLeYwLWXbgTTA0d5yHkoxrpbvcW EQdumQGU/5OQFB2xWdqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1ScN-00000003Hfh-3wwK; Mon, 29 Apr 2024 15:08:35 +0000 Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZ5-00000003Fdo-2FSb for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:05:13 +0000 Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-79100a90868so29723285a.2 for ; Mon, 29 Apr 2024 08:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403110; x=1715007910; 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=vmuUSFnHzqjHSVO6x2xCi4IdU77yIJvh23Ivq0XCHvQ=; b=eUdeAe34tOyMEfTcIb5OxAG928VtQa3E7KxaZEckDtIpiOc4xtCH3MO6NHOg5CZy7S TOHgrDo8WrK/zgnBEmT1Ykvwi7DQ/veppJWXeDDvU4BIzhgN2rSakipNfF72qiwKIZF1 bgKksusZtScavk/0Q0s26un9/sz+DQA0EcxWY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403110; x=1715007910; 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=vmuUSFnHzqjHSVO6x2xCi4IdU77yIJvh23Ivq0XCHvQ=; b=ttojWWOnqvRvqAUk2NkcJV16acQyob50ChXpDZbtwBJhSg+kpLoMXtL+RsTtEVaL+r ZPHIfqhPU1peqtvWsLhtz0FJptFHtUZ7ecDJMioT/3DUnRMccSQKo15fQ1lLGbGzOp7u BjhwGhskm0V1ZjbszsrCUpunXnHoL/yugoowyYMVPH9o1X30WN1liyiF7Yp1VANCB3FV QyPtrBsj7fR02eccENtv4q2Q9xwXdjEHqf05EkQxk3MicNq7qgHR/lYX2gjxSi+uD04n w3jOEEVtH4iAKoc3pP/00wFGvmg9ykBmunck8sqRhwbornaoYyB8XwHXBVMdArhl7v1a +Zhg== X-Forwarded-Encrypted: i=1; AJvYcCUq9za0kZCYbUJu0svH4yo9X7a9mCrtQZwNdPlyVfAG4McN6EbR0iZmVTAi6yGcv/E3gOUOgz9/IeS2+2zS98ij7t5mTsUZzdi5CKJocPjo5HfDcAg= X-Gm-Message-State: AOJu0YwQybv3GQl+y+Sh9VTuHWx42Ha51zUPDEyOrAQ722TLz1pFwiUK GGEH2BNlit3y4LA0qD6p4ZSOflGMTiV2Kk1dSIUO2NdsvCpccWLhQpL2do4RnA== X-Google-Smtp-Source: AGHT+IH9sz0tcRc5gxc3Hn2yH4aEBZFdiRiwY4P/N3aVh4I90x1YrGS0c1n2StA1reM2wgrnpB/ryg== X-Received: by 2002:a05:620a:1665:b0:790:9e62:787f with SMTP id d5-20020a05620a166500b007909e62787fmr11023549qko.28.1714403110567; Mon, 29 Apr 2024 08:05:10 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:05:10 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:05:04 +0000 Subject: [PATCH v3 25/26] media: dvb-frontends: tda10048: Fix integer overflow MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-25-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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 , Dan Carpenter X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_080511_795073_48011515 X-CRM114-Status: GOOD ( 12.76 ) 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 state->xtal_hz can be up to 16M, so it can overflow a 32 bit integer when multiplied by pll_mfactor. Create a new 64 bit variable to hold the calculations. Reported-by: Dan Carpenter Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-frontends/tda10048.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c index 5d5e4e9e4422..3e725cdcc66b 100644 --- a/drivers/media/dvb-frontends/tda10048.c +++ b/drivers/media/dvb-frontends/tda10048.c @@ -410,6 +410,7 @@ static int tda10048_set_if(struct dvb_frontend *fe, u32 bw) struct tda10048_config *config = &state->config; int i; u32 if_freq_khz; + u64 sample_freq; dprintk(1, "%s(bw = %d)\n", __func__, bw); @@ -451,9 +452,11 @@ static int tda10048_set_if(struct dvb_frontend *fe, u32 bw) dprintk(1, "- pll_pfactor = %d\n", state->pll_pfactor); /* Calculate the sample frequency */ - state->sample_freq = state->xtal_hz * (state->pll_mfactor + 45); - state->sample_freq /= (state->pll_nfactor + 1); - state->sample_freq /= (state->pll_pfactor + 4); + sample_freq = state->xtal_hz; + sample_freq *= state->pll_mfactor + 45; + do_div(sample_freq, state->pll_nfactor + 1); + do_div(sample_freq, state->pll_pfactor + 4); + state->sample_freq = sample_freq; dprintk(1, "- sample_freq = %d\n", state->sample_freq); /* Update the I/F */ From patchwork Mon Apr 29 15:05:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647206 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 DBCDFC19F53 for ; Mon, 29 Apr 2024 15:10:39 +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=bK30URgvbTbv/+6RC5dElcsAfzChmheMYFYS9URU3PE=; b=qRA9Bp4Vt5kZDv mJWLV99tvCa355xjgPc4k/YoH+rbudovrpazHPAw+kWb//7Vpbd+WnfMspULxNik5iqIMrY8OgRCu hHAG28s3Yuo0uT3DiaoNHFCWTSCASlS+epW0BQQbtJaXuPxCy3n8bIs58Ve5PAaxCUgdEzd+wKy3A vWT3ZSi4bQBvctY0NOXSJqBXqtvWLYWmRbz/h7cs7nJeOn0fXwhm0S5+jNkOkm4Zw31T8RbROjxej F/z3WJfHfCbGNu8Z2/RwJq5X9E3aXuek4teC33yLv6uleleEOZeGkgEPSkAxekd/sJvjOBHPCnNLe dWpU+JsgO3OQYI2RS9lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Se4-00000003IwJ-2vBT; Mon, 29 Apr 2024 15:10:20 +0000 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZ6-00000003Ff1-1K2h for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:05:14 +0000 Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-790eedf44faso116876385a.3 for ; Mon, 29 Apr 2024 08:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403111; x=1715007911; 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=STqazHEagBxWlHC69lQFp5WbvQ2Sdx8rB6+uKcUB0cU=; b=kdDIo6RTE0kYIgyOuv0Ofmd+4m9/txXllDc0zHr+YcwjXT4aUvmyksDY4TrbigKkBB VpCnCm6TVwErAIm3KrhF07Usyva5z9+JbUFykFSBzNKaYMKJ3mV6hG7dStqFTGG5/ZDw RdnwUvhLpTcEFC/bUonVvjjO2FEu0IjQv/A2w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403111; x=1715007911; 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=STqazHEagBxWlHC69lQFp5WbvQ2Sdx8rB6+uKcUB0cU=; b=XSqh26VNTtsP9CiRYjGKyZBB4V1xoIxQtwAfOUtwuwKuA5ARlTFpCS5qJ6pD2+owfN muZ8v1REFuxuIn/lMDLQ9jJoRB1FnICVzo1b65Sv0hG6sz1ACMavGsasA8vs3hXJg4cU HDBAv7ZP2wku588YoEW4OxGucYUhtmjDT6iszL9zR4Epk3/bQngZsuyh4eOHX8UCaJ+U +TBR+Ro6hCPN26BuQ4Vmf56IqOS4eZ3moEmxfHxEHrcda2ffBtnXXHOWnNLiMxFk/W3W 8X7MQ46JtIjGQ7/MKF/M7VRHc2sdhERaosrDQ1wrQTtngyQqofrDTu0qIpTfnsRR8di+ 3AMw== X-Forwarded-Encrypted: i=1; AJvYcCUqHvIL3k5gHCQTJ98VJkR/9KqmjxFD3EOZ2cf5oSMF4yXF2aF4p1QHmLpGf0H8uFmCwGG3mq1fAZne8C0uln9KCmiaYTXI8sPiT+OmEuSK32zL0AQ= X-Gm-Message-State: AOJu0YzBM1qkNOnsK9N0d8BMK2Wju3vIRMjXjMb83lh8OAcSb19W/jPx KjJg7GtF/MPHa2DZlxEa0t7beMhVGjA8yycBvEpupTjaMLWtTdXXXI/PfUkXfg== X-Google-Smtp-Source: AGHT+IHvPitwm/34xW/kQUa8TA8n6UCg3fwO9ex2lf7MaH+MC5XxlTHiUGq0Riy9QnEe78dxXREmpg== X-Received: by 2002:a05:620a:5e48:b0:790:c81e:7840 with SMTP id ya8-20020a05620a5e4800b00790c81e7840mr6919928qkn.12.1714403111405; Mon, 29 Apr 2024 08:05:11 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:05:11 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:05:05 +0000 Subject: [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit. MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-26-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@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-20240429_080512_616453_70A4A33D X-CRM114-Status: GOOD ( 12.73 ) 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 We do not expect the sample_freq to be over 613MHz. Found by cocci: drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-frontends/tda10048.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c index 3e725cdcc66b..1886f733dbbf 100644 --- a/drivers/media/dvb-frontends/tda10048.c +++ b/drivers/media/dvb-frontends/tda10048.c @@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, u32 bw) { struct tda10048_state *state = fe->demodulator_priv; - u64 t, z; + u32 z; + u64 t; dprintk(1, "%s()\n", __func__); @@ -341,6 +342,7 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, /* t *= 2147483648 on 32bit platforms */ t *= (2048 * 1024); t *= 1024; + /* Sample frequency is under 613MHz */ z = 7 * sample_freq_hz; do_div(t, z); t += 5;