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: 13647092 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 912BFC4345F for ; Mon, 29 Apr 2024 15:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=cX0Nt2WjhKwJC/tEnFmYRvlB1MfFk2LmbDG81TIdFVM=; b=grr2Bxpy0y9buLKP/8A40Qbi72 jWq17ErUL2QC/2Dsb6acFm8NZpSbmZr6an24i1Q2Q2XfI1vi+DLcgH2EuYkoLY9Wr2lNup1zgRCUz jAkXv8s6lsAlCbSVcfKeKcf4XCrpmVVKQRLjh03b+pjyF9m2ES+FAn4kM9ksmYjjhyB/aocUCEWjI 8ej5wI/k4gYnghlHIvtMrFZL7wIk2QmiIIVdmnCd4P9YxSew1E8CUJ/YCAjRlq8KC2XGb7tT6M4mx al35SAgnsIIH50NYthCL39q9d03Kj+NVWdzgPJHvOXjmFvBg3jGV/foa6cXuVApF0OZ5zAbvSoCjd PMYxWtcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYi-00000003FIJ-0QRA; Mon, 29 Apr 2024 15:04:49 +0000 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYe-00000003FFr-3t1i for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:04:46 +0000 Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-78f05341128so332452185a.0 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=O2wUNVKfRKW6GOR4kcT0Qe1PNI3X8iR3juz/EQTvDcCRtGOY0dHrgVdc7Ztvjusq7L 9bbuprMkB8ZUrlkADCAMNl6NKejcQbsSlE75xrMYrUEGbPWibUGc79qFsy0WnDBIbwEt /r7cjG79x7WH81hiBLklvdYS9kZ4jk+vGmQ0V771uQT1pB5R25r8z+tTJegkq40fY9Vs 6JYbqqitQmdoySX01jA5XROP/jdpCU4Gm/SIyUJ4eDFrmdrIfCNDxktNTDnYDbW7WO4b nIZpY6jyFxBVoiP1jhW+EDRkN/B0/TCRCrJ/fRnu7yBcXnHLwdRNgxurwe4TRtmiFp27 XP4Q== X-Forwarded-Encrypted: i=1; AJvYcCWanOE1rwRWSqhzL0s/7hOCkpR6udL46OREKLK3IOn1BnfqvOqDjVMU92y3ZnUvpWNynujRGGCLDQ7MMvsbtIkHKSp0o9rwZcFkbKxzuVjchnzE X-Gm-Message-State: AOJu0YyPmwgvWOGHcfPe6+1O1/yDY85E5Mxnbhlv5gAHypr5tfSGO3zh ltRxrqXCHxsiGb+WFolnykcDXTFYNQiswiQ6+l5xSAX38NyG8n9JcKIPWXSqIw== 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_005673_AE2631AE X-CRM114-Status: GOOD ( 14.94 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647340 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 46246C4345F for ; Mon, 29 Apr 2024 16:15: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=TBoYdFZFpJunUvgv52P8o/805oLnG0rRdaJVdgyqfIE=; b=H0+YC8dh5VnzMf1TLUSlpBw0er l543vxagaUa2CU0cjutcSR7hj/xMBCIrfqR4r6XzJAODr2kRPZrmZ+M0a4Gcq7OWK045TN61uF2ld M8CjcJmXUrVcwjWwMrrwCyXrDlfWN+j0OWHzOyb2SzVDhW/IpcNikjUpwfZ+HeL8gmA+l3vHO9hH9 KX7w4YoLybtISAeB9G9NqHvqEdaMiB7UtZHZYUkAkFnheCcuW71nZbrZSo8U7ZAtUZ35Rs1e7+bdp P4/19yxzpEnddeToKH9/lj9BdCXF5sUcjJ9lSlt6BuGzl5fFW5oFYTUbsVt0Oa8OJbw1f3XR4z/SJ jIDt/KYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Tf3-00000003YAd-1B3y; Mon, 29 Apr 2024 16:15:25 +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-00000003FGL-2oRt for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:04:47 +0000 Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-78f03917484so307887085a.3 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=W5ibOOt3NBBcyBy8pC+VflwY2TaQUPjsf32efxERhxzdvgRlcCOHJcjbi1+DEPiBjW KaiMCnq+yOAemPD9myYuWkwuvlFaXB2Pms/Y3tCRhrkMwHnNnESKZ6jpLccGVYk+gWbP qrn2nHHUT86kThdzRM97vPT6fMTNHLcER/JlfDkuKqE90oeSVf4evu6YmfQEaR0HLwBi rzVIyQtql66ENldkp4QVc2je5zP4VwCVLUdyVxb5DE2LowK/I59zL3+7og3DYprc72hi dPr1LnDR51e6f5K3SHrqzccED1EqW8/q9VSOo50MZPqsHOwE3G2bcq6Bbm7nJY43HEWa ljqQ== X-Forwarded-Encrypted: i=1; AJvYcCXA826Trp55ftdcdX+JiB+yyUBPg7pPOpOv61aoTLQb9HLFBMrXA7lK8zTwQ/lPYZ/HdiVq42NT3ehnpvsxyF/xVGmFkJfeFppKCuMCIndRxmKr X-Gm-Message-State: AOJu0YyGWbYqEhyhsx4NcEqS4cBTqOvj8it2AT9Q+Fn2bCN6gtURR5pN Ts0Lj/r5Iwl7U2E4o5VUsMH8jV9kD+Ep8JLeG30JgM8U8jidqwp/v8Ko4iT+4g== 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_080445_746282_2322CC14 X-CRM114-Status: GOOD ( 12.56 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647094 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 49A4AC4345F for ; Mon, 29 Apr 2024 15:05:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=fm7JWuSLrjUxnTtxzzsVfK/l2tiOhulSLLxdjSxChR4=; b=aBAhKjdHmCGCP6JVNNGQFod+d8 VwcliNZQ46nElkTsWzhzHDeu92q4ph+NL1IgoU1WEjiqd09jm9nX3Xan0SHD40mPoT+AlKc2Wb1qr BtH/9Yt8n61ywIOm7+nE+KtG7JVhL4oZk2WSJbz9UklPFvXvqxGizyvyzRu07BUIi53KNsxSNOHCS xzRpf2FjOknLGtcwXUCR0voqe/nBh9kX0+D386S9ssHb/Fc1bKyeee9Um63+rnqgXj1YP9mOvWszj wcPkxapU9shwZ4fkQA+lUY7/laYkqBkRyyODLgdpGWce7b4QuxQ0fQNLKUVQ0+GIjHmB+d3I8NJtN a9QT+EKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZV-00000003Frn-3VXU; Mon, 29 Apr 2024 15:05:37 +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 1s1SYh-00000003FHb-2kuO for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:04:49 +0000 Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-78edc0f9636so308013185a.2 for ; Mon, 29 Apr 2024 08:04:47 -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=i/r0mnEA9IHJ8m/mqzjquJMqnRTlGMYBzOA1KI8PktNWphFVBZfqf7gMdamIUB0om+ +TKulbKhReaTYUpsHH2DmOXAbd6WyTSmGiKG/5bDnZXmxkxMINqyKgKmhIYqnnTBte1y nS4cbDbEzFrffCISVqKDIGL9S4Ji4J3eEuMcGrX54+FrGIVmpztoH/IDB75yQYauZinE rFHM36TmN1QcMCouTUigRiohoL3UQX8Biwo0dHzhInx2k4WNDFT9djhLGXntfRcQGD/u qFgDYt8P8D/j7RGU/QZ8MzDUATPrKzOYEN1/sCECUePqp1wkBSPi9QXLZaxZ01XGCmkP /MTA== X-Forwarded-Encrypted: i=1; AJvYcCVZ1oWrd6xvfdV+zrNMfmxCyYfFjEoppbLKYJl1u3Of7eZvk+2OKLmZcwwS+bjbyfaaPO8r8aBKVZwnJ2SSezWGE54xURfjmjyQMiv4mrlU57BM X-Gm-Message-State: AOJu0YyecdCu5/b4C2HkMuPahUDrGGUxlERtM+Snl4fuhOVlQN2WJhWV V2+vqoWtLu3azb1HqBH4P1oMeq7XPqfot54k7r4GO3xLhtp0VWTnvtum7Tl8pw== 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_740198_93CF5410 X-CRM114-Status: GOOD ( 16.11 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647241 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 6EDA0C4345F for ; Mon, 29 Apr 2024 15:18: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=2ANA0Ymw4Lt0Uz9R7FMbv4c7Ba86EanvWiJ79X90fJk=; b=pqd94QuWWTpfn3TU+RRqZJzfBp MMarVS58wOMb7ofBs4xwA+c/4ybBeOdvDWcAkUKJV53NjzE1lGchbPBddGyAN3T7DCWILPyXdXSJH R4Nb4S4zmSLsf3I0KvkkY9IRVhSEtk1p+A3G3UiwVs/Di9r6a5GQ44bVmk8pUv1AR0iKYzCfULA6o jB9wJ+PzXpd6wenyQXbEVCejKudoyybAMOXGOaE/THM0aArHLF3XLYuvieISKAJjmMKSFvGuGpbfM GjNiM/xW4y3Q2jhhi60uf73Tc5VfOx1xZnbvsojeIPKj/6+sKhCFDTYYivTKVax408lILoM7p8dg7 NcAMqaDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SmN-00000003MjS-2ioB; Mon, 29 Apr 2024 15:18:56 +0000 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SmK-00000003Mi8-1SOt for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:18:53 +0000 Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-436ee76c3b8so37053551cf.1 for ; Mon, 29 Apr 2024 08:18:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403930; x=1715008730; 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=FtFsABTf1Y0Aa+syg5WBWhNR0G2+YKvKhlDdiTr8bLsrmAnNgUqI+A3ZfXMwHdHNC1 /L7PjnjXCCEKLZIS0R34DIXv2E7Np57jf/6iQLSu/iQm3F2rq/z3iAYeDpWQhbdOnvhb K7rSYD9LmCrnZPcdKhcUdpRSZzJQYauXGFE28= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403930; x=1715008730; 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=sf2T71Zpu/D2zlB57ic3ZDgaLW/axmTe63bxyzWCuQIjdH+6nuatSh4i8RMumOPRaV TFQhZG+JZmIuLyh+WZBjt4UeWHDwr69kxLPyTSGFmAcXoXrlCSHMax6j5tCSYMMP6zVl gbKuFuZYUI4lwUyrb6cBJwu6AlstgQYZuPxXWCailESFNWfm6Y8LPRLU4vVCXGXsAHJD Y1E1/FNywA333vQO3Gu0lKvuRNx+liggu0T9c2a0DUkCutnUMK2HC/0Q4thPsSltnshI v9mnZBqd/32HA6FNcm+E8Y+6Kp2xPg0QkmX5bV3D+2YmkNXVt+y3I3tyPygT101rvS0J wDJQ== X-Forwarded-Encrypted: i=1; AJvYcCUeq3GhvOn7yxrmt4uo2loA/ZkEhvApbD352DFSVg+TxZTWhhQYOwJVQGOnG5yUUELuo27r0TbXSO2J+WIsQqfDTCbQ8HubhkA7VVkOfiOVGU32 X-Gm-Message-State: AOJu0YyWnrIcZlwOpEHi811ijNKRz55cl1ufao+QkEDRcoTv7U5oxzMb 13qryQ6RJnJ6W8y7gsbumr8mNF/JAhc4+GVLZmJivHbDGVDb0p9C56S1VkQJspMG1JboPpLolG8 = 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_081852_399680_6A99B7D5 X-CRM114-Status: GOOD ( 11.35 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647095 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 D42BBC4345F for ; Mon, 29 Apr 2024 15:05: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=S/QHDINTXxaHfJymmPQd1ntNOyaEtGJ2b8ypDUwyIXI=; b=o9X4XU67P3qw/0e163PqomfsNK pIll7WObtVXu0xRurdGXGbr7Tuszi3Sk36DOxRCq3nOnWL4HpRJnuPloeOGuFkG7jepejdpxOPdW9 kxMe6rJf1wH5qXkfKu3kdVT036fPwI8aiF7NUtYZN83jsVGurVj8TnD9rSq0/eZ6ou+tY9keovjBu hHCyqFZRfxqpoWij/2U6ONS75XJ4mhGePsz/JHpzJ1r30iln9BfKXCMFB2dIBmpBtIpySh7BeSFPR LjtydJ3GC/u3PVjXw8TULr7m3/5nm0YO5ceA//kaRjaGbHlDBCaZ/Q6Qgwx7DVJq7+uOA0J3ezxIo BiMFaJ+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZe-00000003FwQ-1P9b; Mon, 29 Apr 2024 15:05:46 +0000 Received: from mail-qk1-f177.google.com ([209.85.222.177]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYk-00000003FIs-0iy6 for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:04:51 +0000 Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-7906776e17aso334251985a.2 for ; Mon, 29 Apr 2024 08:04:49 -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=n+jpZnsUFIaxomeOYWqDds5aakAgKA4e5ypkqDbmjmeTKSbi+BXbuZvSHShmIeVQKk k0WYDvr1hGxBwB2IoOk6I5e8vDgekCyG0Xe/iJddZ57U1SJ4U5ffee2Ue2l0yKN+zuji NHU4uQWdWEdIjaSC2JJLXNjfsdyciWJ72GL2ohgzb9EQlpOPIIuVwtM0vltWIh9VD+Q/ Db7lEjsKYTCpjkbRwC/jZO1EHe/72Z/vb3i/y+9Uag35QGpo0om6pWrWJJ2d45g2KpSV 7Kf3ymJDtqOvwVS/9sQATbTWi+jcGGPXVWhgFX3FpimfpKMpYjQocQYJFeU6NwOASWRo CUTw== X-Forwarded-Encrypted: i=1; AJvYcCXwTo0A3lFFl8pi9PH4tqPbznWs1AtLm9jSAFP6e6jMoN2f1v/oRUuzdzCtrFN5tKIpjnIkz0ciollblgvuIqZbnjldAieeN2VC6KsDIJB3DGEy X-Gm-Message-State: AOJu0YwrdYVNX9PjqiFZdqsnt/XESPaDP1rwD2eCdW5dsxa+mLVM66U5 ucwnW1WPMJuZmmGG4bmp1pymYKySqVfrbzTISpwvTm/2o6uNp8/HIr/kgP0s+g== 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_080450_286800_5095D093 X-CRM114-Status: GOOD ( 11.23 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647096 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 E29E1C04FFE for ; Mon, 29 Apr 2024 15:05:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=AThUs0uZjFFwmlw5yFatMODeeCPF6NJNDOtB7Vvi1Co=; b=n6JZc74bKw3u21jsPKaxgXwfD7 ifg3YixGwKxglDoUODcxcypIUuPMoNNWithTpjRYiJ/I5H0MJOr/XB62AgK+JBcSl79jKMf0hgHq7 pJE7Z7UAHIQzdZKzybjubAd1fzCZ4yhQXzRWusF6PzBtwbSGLSiqDWNyi5Uf6kDyccPeIhhBD7Eoy tvB9oRFZgoe3RhHa7b7bLV4qadMYESfN8bE6TWOgu2OKPbSTQNxVWsZjAqvQ6RrRx1B0C5F/nq2vo LudKA93DnzOKzpSvBCS6iCcGa4k7S8H2jliEZAznCEK2+BK1gcPimI3dsQj05jb2QSoA1NZkTof3c HSvSAxHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZp-00000003G1V-2OVe; Mon, 29 Apr 2024 15:05:57 +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 1s1SYk-00000003FJJ-2xiC for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:04:53 +0000 Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-78edc49861aso344049685a.3 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=rQrZGbu/jeGdfSzIFKq8MR2yvBBPKVQh7SfmEgmWxKTvanTTaDTos8UvL0LYdhqpcM SxF5++vCvIxpGj1Cd8Ujvz773TvPTmmEO+6pWRwPm/tUmXtdm/kUhse/PeA5BINYjzdt 35eGYMaUi0waUBXeuqVhUOLm2ddJhhru9y0Sfj6ZR52IsgeSNmnRLS1w4Uv+G+YoOn2v tVR4lafXCSrKC4nqDGgzc71Xlv5gCAY28YNA30ckjVEeAZfFLQGDFgxvUj6uShwW5/cW ggC3btgEXAQE0Bo4ZIx4/xm1WHXVtSRvtEUwEiXx5zz8l66SNEyAXmlIsni2v1yeJkpr O3oA== X-Forwarded-Encrypted: i=1; AJvYcCUR+POYdVb5Y1Wy4O2MApNi4RKAGlXuc1Cn8S3clSBLmL0GyCvvb62RcnYdHZ3UMjA2+9pnNRR9pr7eIjmkn2THmX/xCcybDa9Abq8N8hnUrBQZ X-Gm-Message-State: AOJu0Yyhp1PACncCwnrtZYJ0FPH2UIFbp4+Df4zkrBHkhdCpxlpziBrj CGDMGQrixviZIHWsyXBbIXpJaM5qTs9Cso/az6/aJW4hQ/p8JrYIqzY88HBPUQ== 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_984274_82555719 X-CRM114-Status: GOOD ( 13.08 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647097 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 DD5A5C4345F for ; Mon, 29 Apr 2024 15:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=/qUCWhD1zt8bKcdbs6yESnMSEdigGZ2fB7xO4uH5zQE=; b=utMqpzE7vOug0PCfMbwvhQSPBt aq0puLzFpgjB6c8w3YZjji8hspZB5KJPF9DNwyhb4bDDpuspkbevgkmuj9ZOy0Vuve4EzSjszA6zS U5QYVpbJhqaFKN9RbYHpjqxeg2m0vRwxgtkh57PHwe1DC5xxxZw6sgjPfreQPDKvxp+aYU7zZ/7je Lh8j54niGJh2v88Qmi5nCCJT/5f2qyXLgnc2iQTbgcFzzd+XzVLz5SX3VRheFmdH+IA4FESvEj66+ DsFpWcdW2kv3YXz7a3nK04JHxFRgu+PX9yAfU8JdRJKqyrGvvXBe1f0ZN8kAJJjPDS1EalteutTLN 1AOYunJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZw-00000003G4f-1wKA; Mon, 29 Apr 2024 15:06:04 +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 1s1SYl-00000003FKU-3ct9 for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:04:53 +0000 Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-78edc49861aso344054285a.3 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=FqXLyfhL3i4VqzWMzJntJEho1FBsY865KyJld3IG/RoeM3ReiVRghHtsHGII7cAQ1/ zNinRmsvRL2FtYe1fZYp0V6BGgXGO2TJYd80o5DpMKXv2noOj2E/Er/Vhfb5UD7Er9Kn MWuRgzmFh1eXuF9fniXYJVOHJNNbyLrj1gY/5FENDkP075tPbYHk4RqaZ2JuHoCevLXk Q53V2ZxiliUDvZXdsK8f+aoTfu3VKsrxNwW3QwqO/pgI9lq7BonZVD0Z8xI471lhu7L3 GnF3kgGiTh8s8dAwCOOBBMQoSKCGtLh/zbbNh6t9fX45jM3Jddyc7LHYuYkqex4v/REP 9YDA== X-Forwarded-Encrypted: i=1; AJvYcCVUar6elA68xG3dFWPDKZiWUZb7y1kB2ZII32WH7sM/eBAUA2lwfsfUmMtVZKiyvxYt/piMmQvbPbMNBBEGNdF9QgRngcQ0o1u4n6okDd3nny+I X-Gm-Message-State: AOJu0YygLu93ODdGHoerZpqAs9EzFK3ZwXOuqvOuwK9nPfv3pB6+oQ4W BBCty3hxzwTZZ18ryhnztI1cUIXYcVcex2sTzK42SsbRPYNE7OE1vxwczPCYaQ== 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_080452_080147_68D569C3 X-CRM114-Status: GOOD ( 11.70 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647188 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 A6F75C4345F for ; Mon, 29 Apr 2024 15:06: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=OI4AOi/6PtgU5zRnLUWjMVWmm8Y+CckVMvMt6qKhGc0=; b=R6JgJhT6RY9bUh5fGxYI+WtIOo lHbdrwdo6iPpjVOwxEzZ4oMz+Upqj0J1d7EwiSP6OfPyq/Iz+IuF6roY1Y9IX7Uqiq6xBTYfGraWP 6IgVBNYftIStKS+f3nzh9JUUG2VGPjzGx04U1hllg3BSaP2QgbkhnMOsSKLZnuG2ju/RfcMNr4Xrp jV3sQ+1BqW8F4jMSuv9Mp42+wl9NRxyv+8psdgmhp90BGtUFFUIe9BBcOVLqjgdV9DgJBkQiow4aM xJCY6rnOxHi8C7+TFLZndcy454dCGgsdlS1GVjkU+gGZY3Klr/jebW23tJWv307dlJxsGz0JQpIjK 1YfQ/vaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SaB-00000003GDF-0lXR; Mon, 29 Apr 2024 15:06:19 +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 1s1SYm-00000003FLr-3mZc for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:04:55 +0000 Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-790ff1fa7b3so45285385a.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=1714403091; x=1715007891; 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=fwXHxeHSPoBFy9UNO28adWy5GHJMLw15mfVGzA1ekdw4bPZn9GOoMZ5vg8ZZbRTye3 WjDW4YKTMuv6hnw9QEGFgZGiIpkQgU7UR0BkzT31dWH01fWgk4T36ASKlGwe0bq8A58T yVwUtK08axH42aTopV9YKWZLeSyVT8SBg0clg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403091; x=1715007891; 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=NZW4spCrsW13zTwQgr4sL0tl7mTKKdn960g0lhKsy2vsq/t97hzkHHVpf25bwcCiVt 8cb/xqW9uX2Y0AzI6Y9s/NJ8fJJxfjQ6ghKYmArH3sZS9W0D8OjuNWGfdO24GOCRMr+p aOcuaRRjfMMFykLlhZA0QkGvGCS3zhnbkSDUoKnjMO7ZnKEzLzttbY9lKJKmzrbOvqAb /WQTyTKeODuFKSSY2m+hGlSHwx1gmgvv3UnsVez9UUFs6G6HiQlynPErvVP5U+zXrbiF a9JtwACtxN+gthZZy2nbuHdAL9+Z5qrCMDh78MnK2e+01r4RhP8+QeBbq4M/3gaGbGWI qxtQ== X-Forwarded-Encrypted: i=1; AJvYcCWh3gVdX/vqBI7tU8W1yD46MhkOcIjZalcjljPjN0sltkNpZtbU++UrYeBqm6X5GNew4bbJJPfZ4VpxlIsP4jg97AR+gSE7EJJqh9ZtQz/C4ZlP X-Gm-Message-State: AOJu0YxXeyd2wxxqyWgn9xkN5h1F/qLg/hat7B5aCdSK27upquK9GVS5 9FsJTYEBdo9C0E9Jhdn8fjF5GLashmELd2o8Hv2eoCeTNY//YYYUcRWMVBTxig== 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_080453_268690_50D880BD X-CRM114-Status: GOOD ( 11.99 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647228 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 4F1D2C4345F for ; Mon, 29 Apr 2024 15:14:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=JNRsm9gIh82mFVXKJ+HUiStpAhIByx8KXG3SUDPUD70=; b=W+3bCeg3DLAxx3UcJ5u68Svl9+ wg0e9ajD93BGYwxdEzx8GXNkyiiVImpQF/9h94bg0BtGmntBSaJzfGkQFWccGwMUvITv2Zhs8MNRS UBV/+hS/CDqQEtY0oaFqyxTx14hzOT2hLO0L+vRnWTetgRYDRxGpbn2SezHD0iKe552LTdH7ZCuKY lNajYGpz4wKs970e+EehTzobfXu8QDNt6gNH/HLsavXopj+CtxTVdhi9bQgVZFr69sZBA7ny7KE3y sOuNVU6wEW4v1L70rQPGmo9fVfVxxNgAKKmU6kdbJOo1VvlE5Xu9Z4VQnMcZ6icN5dHPHk6RIW//i QS9EecFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Shv-00000003LF2-2IEg; Mon, 29 Apr 2024 15:14:19 +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 1s1Shr-00000003LAX-08MU for linux-mediatek@bombadil.infradead.org; Mon, 29 Apr 2024 15:14:15 +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::2d] (helo=mail-oa1-x2d.google.com) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sct-0000000GYM2-06tU for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:13:42 +0000 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-23bd61fbd64so1676822fac.0 for ; Mon, 29 Apr 2024 08:05:29 -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=c99CBZTO73F1kU3wLMelhpzkM1QpnnjCNgTOBZHwSifl6rBEfJz85E1THXhNcVvH9t Mzi8YswTeqDTcvqW9vXxhzDYo++NeeTiGqIGoVOwLazzZcCUrPxs1XG8Zr4XcUSva+x1 1J9SP3j+wHt4f0xHaSneNnjuNQynacclPUFwjd1+1C611aBn7CQeHTyH2NAi1jjQp6ES zUIds6fjVLja7ZojoxDo9KwpxnAItdYD26oxZRa1NOPEU1II0H9W1949zuQNdOLn7kOe zH5ZybIOzB43aeaCN6ab4GkMa0lwyNJnSbgaYK+aADjAr5A/7y07Gv7Atb7sCRtBgAHr Hq0A== X-Forwarded-Encrypted: i=1; AJvYcCVPYI+O+7303+TqUbDkzbA5+rTNUjIY7cWIMeFk56stFW8NVfofWhycrjmUKURTGdK/D2+uWsFGHWVyLZRzVBawzZG81ddrdQr41EKYqUWuIM69 X-Gm-Message-State: AOJu0Yz906ueUdCsJbokntA9lBQwNz4AAkhSNNSM9chZeH66KraWACqk h91dWPyi0iW5nZKglpNN0loGNUog7IaeHV7NtGi9j4L0CtfumnrnLGpLu+JqRg== 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_161058_396884_43DBBE93 X-CRM114-Status: GOOD ( 11.92 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647189 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 CBCACC4345F for ; Mon, 29 Apr 2024 15:06: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=I5MK517M661jXeUTMXVPJlov9z4l8/dISyr2IlNuzMY=; b=yypwCIe5qpculhw91go3kYchO1 GO8Z0pNxVXDK6qLf3vVN0AO6C+RjqvAZ6O7BLTLKWT3C+V0OiwdZqz+j9NzfDWcp9CH4aTSbV1qyv suM7pVA9iE/fN9UVprTgw2Uwr/LzH8OqKJyRCp9+q22m5TGekWFs04OJJnVT+8irYVA7YHd22rde3 gDB74fFy9fI4tHI7ll0wAfX/43QRLwGNPDSYyRmEfhEZ/JmFy8BjjKkx/cXhAdCjTv3VdLN1xfrF3 iQD1EZkhY+IpRF2d0CnZQvBMkLPzwy3UlgOYGSaI61fCpX08+Ywj171PKlX5Kp7IhJ3ptoKvnVDK4 rJp1FhuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SaP-00000003GLS-1LD7; Mon, 29 Apr 2024 15:06:33 +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 1s1SYp-00000003FOW-02qg for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:04:56 +0000 Received: by mail-qk1-x731.google.com with SMTP id af79cd13be357-78f049ddd7dso369256185a.1 for ; Mon, 29 Apr 2024 08:04:54 -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=gXU4Y7bJFg3YOWF0F5ARoReheQwvcRHdgdhELqelHCJE0dsq2WyzQ2pn6wVvbE8krZ QKZxiwJIPXm20jOMBlzah3odiIuuVi502Bhbe/Ta/fKtBHx9FfPxHp8enHjq+0KPWMB/ Zb4jAAdBZtwvrq1MCCOG2v9pBhW0fXQ1sLYiiU34n0hJ0U8K7PiQSRzw0mtsCABJieLw 1yzPoQe4SaV+QS/lCJf6y8pRFbj0zGH1/DStUeIfStpVheqs25yXkZeyxyfO23jXXbme 314URxiY+h74ZnoDgcOaE16xyOP0NBgIPgu87hWtg3HCdoiFR/B+x3BmK+jZg91Q+ySt Wemw== X-Forwarded-Encrypted: i=1; AJvYcCWZ1PLCNJt3A3Ks0Vx5gNQ33+k3oWT1ds2TO1buiGhTXsCfUbFuT1L1XWeDWuxABzeB4b6C0Fa5VBHEKluXTYUe4XGKlwdjYWOeHOHPSZLDhIBU X-Gm-Message-State: AOJu0YwLA0I/5+rnM4LBr8myDofvInNXSZ198dPvnY5Q9UtckaP5gyDb XLFTk0MF3D6srP8r5EsNmzsB3x/aoByAQFGt/e7aA9vPlApUtiozp05o3+g2AA== 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_258958_180A2E24 X-CRM114-Status: GOOD ( 11.44 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647226 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 18C33C4345F for ; Mon, 29 Apr 2024 15:11:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=M/K5Byxt1ig+CQr/X/PeYwmg4ty1EjIby+WFZ625f+g=; b=t1Sb1Wt2nyBeeWRze4p6ETo+Dh D/NsjmfILsxRAjMOykXBXuh/Jk0Sp1rkFJz0uQ9YbdVlQ267IxKsYtHYOJrnY4rSUiou8/g/n/I2z 4+8J3w2CW4eMBpT3W4QvU/ldg0OnNCt55B0DWt2AN7R+XfIwLWWWgWj75ygWEHn2wCCZgjEkaezI0 z6+1Zskw05V5sjtqvi81OL7X55fsLDXCuSJ7TJ/9vV7Gx1ryAOx6R3+o5IsXsv5NQQrGVyHK2wQFq Gxh7+AoBQuBa05nZcJ2tTUFwM35yxTLvd3Vo7NBxzolERWqsrNYqHMnqqmPSBttQVM7Mje/nzyOEB qJw2hIlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SfP-00000003K6k-1d5y; Mon, 29 Apr 2024 15:11:43 +0000 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SfB-00000003JvT-1RUO for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:11:40 +0000 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6ee3a7cb9f1so483040a34.1 for ; Mon, 29 Apr 2024 08:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403487; x=1715008287; 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=Crmydna2M9xBE3lKwK99ATQTAFgAhWLP1J/l/HP+7/YpCebDbPJSFZsi/C3H5/IN7i y9HZ5MXIOxCIlkGxzQuFdrt/8/82q1KxaUrwb+oQTi4UEMSGC9B4zG3oqPFE44CkNUrw C1aTo9ZCDBbtkXfMJ4jiEKWUzpcZjAEQRh+JI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403487; x=1715008287; 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=ALSc3NhPquNDXWciXX+QszFZb5jo2lPBKTscCdiBWL51bv7jH9HZN0+oMcTcgC8Uya LAqQ5JnF7fCirC2Cl3T2ROTS0v2kOUCxoM3TeKSimaQWL2Q8aPCgF3JgczRaKKEI/2ZE cHwUCp3jIRoq26jjjPgndCYau1RC6QQrlQEKi0bBd2Zbq4x/M+kN67A+OA+j9fiIhv7J /aDuCnJrfE9kmizCyVs+/NldiYrHriMKkdaBiHuhDTTNAyMuTVKI/0uuQaeq3R7UG7Ew HV3vUZS9xj62/KiOsFPd0ZybqDitkfS0QXTqObt+ZZ9Y/16SLlTAb8kdLzkXMvkb/8Bo lz4A== X-Forwarded-Encrypted: i=1; AJvYcCVAeVzFRUpjFl9j9nF4jXAOWw3fG6AzmQD08HI/y5SYFdiEqdKjtaCM50CwWlwxE5SlhpIvDMVlTXd5Z7n1nxyrZCv8Kn76e3Khi9VemRzCufij X-Gm-Message-State: AOJu0Yz++0NLhTtY/syvBkdvdfgGBHo+3dIkJDtDCFo7/nSq1K9vXKYL MA6nm0mcewL/oClQJLs+y61clWRhCh8xp6GQWhz6RcMCXV3grekJgsMsrpPF75Fc2/N9KkkXUWc = 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_081129_580672_7FF496A6 X-CRM114-Status: GOOD ( 15.40 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647341 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 499EBC19F53 for ; Mon, 29 Apr 2024 16:15: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=X5IbU7HBHK5ZSrS81fN3o3XopIPldfFFy8PdyHH7F6Q=; b=QVyPoqeDgTMo9/md/aaRNjN6Jw qI7pUsWpur1W/sUgnv25mSe3Hb+I2IzER6WwwHJHSg80kAB15a8iQH97KRfuBzq2DZpxYXcNW9d5x mpN3CTumDmZTBzCb8zDW7VrsCKEhCdaEkx0pm8wviqarvqe3+IPf+7BGra4ZlVGfzvu1P+8TaWQ1Q Z+X3Iw3l1svwao+Bo1LG8PJWkdCzU9FZt5zuGtZoHupUDXMrrgMUqI/nPy7rQABc9ze7G2nDj1XSv HKfipAbWztNSdObdGfyc7t0i+IhdODUeluSOwkG8geMc/uNbHdi8vjgH5xDp/ctaUceSgNx1nMAWU rhVpMeUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Tf4-00000003YAx-0X6K; Mon, 29 Apr 2024 16:15:26 +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-00000003FQ1-0ZFf for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:04:59 +0000 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-2351c03438cso2009470fac.2 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=AuwNE83OrG846vmtnrtnG94+oEoO/ve2h0Dui/9uPyp/8fwV8waX188EC1RIphSyVI HuT8I7ZLIIcWovlnL6Dsu9HpN9Q2oC93qfrWEBFGduTIfAVudqe+1XRz8qX3R3ZziKus Wndcak9x0TuqNZ6aP2Hdz7vZ2kKAs9gToLgXA9CGX1+zGS3dMop6dv7aMNDXVNjBepbx p8DcA94AVJvlwKDJSTJdoNg02Uxrguq3YYzfNs4Phg0LM3Dy3EDRxRgf9Lmq/tfLHqmT nPkJhNPUg8jTpaB889dnSOr9UNlBO1L2lzFi1oUa76Uphg4iv1+mXWLeaBTrbzlqAc48 zltg== X-Forwarded-Encrypted: i=1; AJvYcCW/gPXpmNCAscINSPC2qZ9JqMjHomcO++Rz1F0lfeU1exytOMMLqwZJ5bG1iggNtWPPlKX9swY54yk+khtvPq+OwhiEguIIN3JvXhwkhXzmAO8u X-Gm-Message-State: AOJu0YyhjFoqhCEgkB8gmSfmFlkh4WVNx2GoWRXrvE9/mjWgl0PeYjZG 1U+yw0ZWJ73rG6CD/0QZMOqXgfNIQdX9uidgOceZWipDDsDkuxDjx2qLNb+5/w== 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_344671_361E1AAC X-CRM114-Status: GOOD ( 15.05 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647190 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 1D44CC4345F for ; Mon, 29 Apr 2024 15:07: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=ouc75z4uJmyNonUkF5EXar7vMPGdSwUxTwWXSBMXCBo=; b=xvDGqc+QtR3kXO8dl+VOTpDR3U geaiEY28DSiO+hd5WcXmDVORJPAVKlbHgNK+QHmBPMTDJ51I4jKSENvC9zG528xRJ7WJOJRTFVAX1 Svx2scTRtgEixJKeGZs1QQySuoDYzDKEdf44VFU6buaDFaOZ/bJxncIsD0uheHdcipludMPpm5aE5 SDW8wKJdTFC8WVgJI9lp6yyt3KKKWUjXjlvayBdPVaE1uoWVe5U9MJnMt+uT4ln4Gr/2BlaIUt4I5 YDWBMlcohwhNYeeJpASgeN+/BFZUzvXfSWGq/HF2KaGQg7XygH7MIavzDeKHXaUzMzKK+44U1kppW 9oIvct9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sap-00000003Gd6-2x8T; Mon, 29 Apr 2024 15:06:59 +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 1s1SYs-00000003FRK-1E1h for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:05:00 +0000 Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-79100a90868so29700085a.2 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=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=ouc75z4uJmyNonUkF5EXar7vMPGdSwUxTwWXSBMXCBo=; b=brkT1KUg3Vu+80irgnN0D+JNtMBmA6XO9dHzlG0lz/RyHZwcBRPu5XmLB+ade66L7k a1e+Jovda4qfkpcygSXo6R5CbgOwJF8ZXPgVu8D4dIid4LUkuDfFTq9rAt+tRVUmunwz R8pRk2E12UarII6x4wE0PdmXPXywaeh+CQR0k= 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=ouc75z4uJmyNonUkF5EXar7vMPGdSwUxTwWXSBMXCBo=; b=h7AtxZ7nvd7s/ZJkWiYWQ0uYSkwSceLXdH9gpSgQkbNWz2ZBnv30CvNh3Gm3hpOfZB zSQH7YISBN9uhBkTvLaPo1yGIPvw0CLkjwseTsinx3+mC5lkESjRZUY0MsynxPW5LVI8 zHaBk1Nfb85onrROeXf5nKf2gxmB9UlG8Jl9SJw3Sabl2ahZVcjaILbi2HpBrjuTnxam RCA8w/2CBt03xNusCTZiSbJU+Hn5Txgyw1GV3nocIhjr9rxjgWBQr6wDY7z55KvoSvkV AVEE8gCzN7QEhEzr6NtZWfWNp1Jc6SrOontFQc6IQBdhfwl7eAT69duwACOYjeHvu+9m G6KA== X-Forwarded-Encrypted: i=1; AJvYcCXI8UDYaaJoVvJvpuiiN36rKOJYeMPYnA/XUh6y1aeLwtVHMLLwJXF9vs7RolAXtCbAQJJLVI9goc8dQ7P2DyOx84ghUEEEbWZTsVF6lUiPjgpe X-Gm-Message-State: AOJu0Yxa8fkuUM9OIQXVqcqyEwAHboMkfwL1CrF63OLv7ZuuUe/nlptR cPtz4urPYnlgLdqErCUeWBxreL6zZi6qfBd5A/SVFChWHEvg4YnTcjqKEVxGwQ== 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_080458_506945_B280F80E X-CRM114-Status: GOOD ( 12.59 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647191 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 25FB7C19F53 for ; Mon, 29 Apr 2024 15:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=B7WgC2+IPrCSABKNTDoDmq5evIyXV522VQOG0leEbcc=; b=LmhK9yc1z3pUHbWY2PkvFwecMS WZcHQ4ffEbfj2b7P0t/TuML1biAIfM7WG+8MMKSUdaNrhgQeG+qp3qc2LmQuKNvXz4HCbAO7UTnLX Cmu+Q2EsB6sNUhWyQRIbo/qCD9HithIrUO9sUSt5oRksdUm1YXYhCnhz+/PtTSGt/9VEp4E1Sv0iQ OnUpV2LVAJ53URvLTxN79YH0wXU0rdFtKmKVTTQFtmwJMjMci514kK9p/PNH/TCK8lyyNn1z1IBGh j7dtlBXZEX4iDdY4ingt82Pd7af+m7v6fSr8JCmT+KaHmQwp1L2vLIoCdx/76nY+q4RvkVNZCMmVf HC0nNtYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SbA-00000003Gtf-0joV; Mon, 29 Apr 2024 15:07:20 +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 1s1SYs-00000003FRp-3D6I for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:05:01 +0000 Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-78f02298dc6so392253985a.1 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=UKuQsgkYcbr971kTTw+DT+pUGZkIVS15bjlbm9eR9sAO66zEHhsyRuwKMO3UZRIQwZ cti63xzf+tu36yvaAIn+qJmgPDaUwhIM/W+efYo1Pgmp9GdsirYdBaXBGLgv/E9skG4x 2kdRBKfgv7sI25NARqvWuo2DaMb2hfw7pldbjYJJllvDe/b0x917VhMLYFUSbd5y0vFT guIZwlzUv8dXpPrptzBEdXkraqNMsu3GzHMBVxASMhlwn09udjTRdahkOL4OAgZ/MM0R pzZkBZID1vVD4fAoLvAivHddwr5gk+p4ckog5flFV8zrwmEoOsR8YTNW/o0ILHZfE1gz t+6w== X-Forwarded-Encrypted: i=1; AJvYcCVYLNfG5Vjg9xIKmdQ5fWnK9jhqMXc1sqXl0esKs7xx6C/sm6HGYfjNFwNwtddQZdMxYfcugZJv3wie4/RvHzl2EUlTQfeWfTaWAxqJ/LVyqY6E X-Gm-Message-State: AOJu0Yw6PL+hHb7WYJqyAKgGGLPHzMIqN9v5N3xuoRxnkndJ5bzXIYhy rcI66rNgEDfKW4KwYVOnYSNeOXEaibpZGSlGYp9lMvdr4otU0zRd0ajhj60M2Q== 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_299828_45C49CED X-CRM114-Status: GOOD ( 11.61 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647193 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 79DBBC19F53 for ; Mon, 29 Apr 2024 15:07: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=oXXgUMwvGuh/bAZ05Vu9f2lIZUwmSZiJ1Ue2E9QmyGE=; b=LkemA5O+wRUYhe6ilM4mHXFiV1 wAzWD+fsNYzaXc0dTTp8kuCBEt2O52BXfzyz4ndHTB2kt05Nza3qF6NIp8Zq9kjIIk1aliJlNQs23 lmgokGo7ko+zx5aDtKBAJkLm9XIYKZr+u1zUJbQ9bdt/LCDzkiAAj2UN+8JzhVzZN1P84+qbq7/EN CHWudW+E6qe9/WLdTNJpESENR8UFZjIFozOONSKVmz0liaTfRGyVxDpQCvxkhx++/SMvKH8CdDrza blfOaVWrNte8CGEvf7aN+LBDUbhpcNUw8+l0+ueQos7+40ZC60yb4uglk+fGJx44vwVfZvsJHoH8b Yzft4umA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SbO-00000003H7p-2jQu; Mon, 29 Apr 2024 15:07:34 +0000 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYu-00000003FTF-2dCW for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:05:04 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-78f04924a96so385483485a.0 for ; Mon, 29 Apr 2024 08:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403099; x=1715007899; 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=k9LwUVj6prOT49RldE2hVcm5Y4X9EQ1ZxywGcdaTvM684fWyTFFZpLpxrAruuqBRFW F6OKMILCFjYv8dmiD5NNMmuFKHkPTAj1QLXI3hXDWJgeQtuYaTuWb47HjPBOa9ONty88 EOLmDHtnnCoFj5oQyMKlq8s95yDtxFob23Ivg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403099; x=1715007899; 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=r1CQr+Y3eb79e+FfAlVL2f6lzQss9Cok3axt4h7YjjY9HhuF3YortODTwXTrkdnugO GSj5s7KRJYsO047VQZ+op4FlOKqp5KbkkVbb3G33KooT6I/9Q30rVMvpCjzwt1l8YrhI 5ZPhzaTDGO3VVdM8bFF1F4LaxN3MjZCOMeIEvqgKL6GI5Wxwsb6ryc96QG2TWaylK4oF EhRj3hYNTmCYFeIG7/izenl2w+2Gox7d2uDJtfRGMQkeAJxWeYcm4td4DiUN/EIVuv0m MSdqzuRHO2NZi61YDXQDeZf9onsviA0wRJ7kNsMZS9ejYzVZfev/rNlUgq4f/VtFnvHR Z2cA== X-Forwarded-Encrypted: i=1; AJvYcCWhRuM3NjhpHs8kWYMuzIxctmtW51S3eOzEbMPLN2z/NTzhxjvIOFaQAedTXZkf5BOGOvaX4cKUZvMED7QqcDbLhd0EoF7M/2urUDnnDrwDABaa X-Gm-Message-State: AOJu0YzRfodIKs/Dm2EjXaWAGXxXWJ5poDyNtN4Q+YvYdU/nm6MmeRoe m0Do9IORVDyATrMWE0PgyLT0cfTFQhi+H1mma6BaQn1T1E0n9uXL8ah6f7jG+g== 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_080500_786595_8CE7AF3C X-CRM114-Status: GOOD ( 11.61 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647192 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 9EEFDC04FFE for ; Mon, 29 Apr 2024 15:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=M868xcge+vjTb4vcqz3d1wlm8C5wkLs//kWdILTOdIY=; b=Ifr2+2DrkNsgXC1E+R9Kv7tK8N /9P/M+nqDQ0XY2LcVm6wqrWPMfkxO3YvpPwxBGGvermSYnJTSro7RjWAWIyPfLP1WYMjgEpXc0T+/ YRlnYLLYq4hp7W6NEqB5l0rXERvCMOYzmzLbCy0T/ktSEBwXeySyOvaTdnMo+gJpaZSz5pBeoxZNg GLRxr/oEiDVrAagq0ALjD91GcK8sQAIjeAyoiKP9jkEI5GL/n7LAV4x8o7NmiEetm9BwxZVR6Azcb a1dg6xL8KOE/aQMBX6VF53ea5mcWEY64M4GHAtTIzW0J2K1jZbbsx/UDLchzn2j2P3aGgGy3BdJOe sgHNa9UQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SbN-00000003H72-3Ig5; Mon, 29 Apr 2024 15:07:33 +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 1s1SYu-00000003FTX-1jKo for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:05:03 +0000 Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-78f02298dc6so392259485a.1 for ; Mon, 29 Apr 2024 08:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403099; x=1715007899; 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=IJsiq6J1roo2XxqMgRN1AY8GZeUz2soaWXI43NNX95g4CUp+QOtsOtUQwPRA3hNSPm Md+cXUABorq1V/VtPgYbf+RUBRp4fqtDViIR1KDesqSjRA4jisUcx6aYNONkuOIogXtC H9TEBjHbkaYwb5ZMoTBmVgSyn8Ul6VWzQXEmI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403099; x=1715007899; 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=t/gsydOUWahZdXAz8UJGaN22BnuqaMIzoeS/s2pf/mcGCNdlCZ4nTqXGgfg6KvaUCJ ziCmWqVmAGx+zctO0hDrivT+XPnfuv4dRjpBJjQv+Lp8hbB5Gs+dpDOmOL8D/+Nfm7s2 TrtDyCjTt3gLt686lJo3K4cgZv5lY1Yx0tPPzizzA8JOawaTChitQRy2yondkuWXa2or 4K7Simo++MJMKzah9RwxRolnbxNRc1rzMbWFypEpKwGi+ClumrJpdQSTtxMDOtdW5J+D 8FKgBl9lgmpWcfYmByZh2OMwF4xyQRU6xoc1vL9GbVQXka51+O83DJEjcKrli598yyiq 004w== X-Forwarded-Encrypted: i=1; AJvYcCUGh7G2jgcEf8cychJJKHFOItZ+UxPsbGdGN5/WcmrMRuoBH+u56BJULaEEunJhwL5n7Mu4RjK+5tJsfC9cnATnD9mMhgXf1noQ0YQeR5lN/R08 X-Gm-Message-State: AOJu0YxjQl4jtCY/Jw0G3nbUC7JWWYk0X/cihiipXoJfFwMJhkEMep9l oH7kb2dmrXx72gBGiMrnROJXad3kAJOWakciR0qay45pgP6U4hwosRwhHw7ISg== 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_080500_679923_AD0ED265 X-CRM114-Status: GOOD ( 10.64 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647227 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 6371AC19F53 for ; Mon, 29 Apr 2024 15:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=7GlL3qsiOGQC7mYG6gX2GhOJ6HGHUo3zfWR8UxyLbWA=; b=mfPo/RWyh8hN1bZUuYnf/pVeMH dQy8ze2o9f3SL5ZhjdOgC9j8dULSO4AZHcuW39BXF2KnIFGDZNlOShkmMO7agv/q4eynX0b3NzbFh aDXH7jVhYa341b2KjWs2rM08ytphBJWRBMCvOaAOC7hfADVBlrbK3KZkWcZ9LEl/OjNAkuEeS9x46 8PvSlVnoFQFDSrndYzM1qkllv7n7FdyPEeZpka9tEOjnVRnJg0chIzaI/lnLMR+c7EdDcTQsid8PN 52Ze7VNoiLCQbCodZOA1G6unLind2LrPo7w0RDzUTcjvmstO/E9oo1aiKvfEVBvw16ayKNwkErZVN 8faVYOCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Shr-00000003LBt-3OYi; Mon, 29 Apr 2024 15:14:15 +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 1s1Shp-00000003L9G-3uzN for linux-mediatek@bombadil.infradead.org; Mon, 29 Apr 2024 15:14:13 +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=7GlL3qsiOGQC7mYG6gX2GhOJ6HGHUo3zfWR8UxyLbWA=; b=gmQDLNYlCOCTAAzV8HFLfxuGOv Mbyvf3nVC04CgBFJzxr3X3BnGgmtrneYSeAnlMDT98Jw9eFJBrrqqNLU2t8AYNFYj+qC13NIdQHYJ L6SDeqO0/8gc7dVcyKwGDukzFa4GVY51egRFCESLSRj45by/GcvWgaNKUPz9GjVPVjJgMVYk3pI+8 1U9eaR45rR3V0uobpX3LDKWwC34geK7O4SmMxa12mtai1Vfmj0+G0zHLuAGCZs6rMC48Svc9vHCfn ZOkeOI3v8wuTg2LMFELT+n/AaXADljdwl4tdROwbC/ek5MmlGFm7+RxCQmZfuStOmIpJDvOP8lv6B sx8xMx1A==; 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 1s1Sd2-0000000GYM7-2uOW for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:13:40 +0000 Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-790f699eb2cso103545585a.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=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=GjvOzNxU+HQJmrxPm3159YZht4O7u8H7DywRf12gmE9OpK+Ne7eTOySGIXduQ2TQdG Bia+qZkkeY0+Ty5OymtkJ2VCCtGEF4ZtXgOWGTH4h+gpMVA9YbNTa/D2aBCE7v7q0FXZ 5S42Wq9WVNQl1PsWj2Y5RTWhU08HnapPQn9PgrMRQxipvCtemeyXgKMc7TmqyCjXtrCh Fkc8x4hBF5tK+Vc2tzi77UvS9D8adQ4PjNPzJyPNtfHc66/yj/UaRSIJO8J/cqcDXXJI FD53mcDrRtHFMpI1HQvP75KycYFKpvhA1RRwxZDQfaaiXNhfVUBl15/bsRNob5Dq2f9W IWEg== X-Forwarded-Encrypted: i=1; AJvYcCUwI5YjDkGV0bmsjnc1OcDL1Bxtx/ZevLNDKASZFu6C6uhUg565yEuTWxJT5ScHMflsV4XV85wc9pMlU5cXvlDwFOxFFInFx71gRfrHs7XooinP X-Gm-Message-State: AOJu0YxPt2aVRQITmTxElrRf9ahfiuz1vpW/Dbdj+W2DKteh+5gHUmne vwikvCOpuIlKqNAL8sqJArz6WK9Dmw23pPJaHm+veMabdnUkN819wynhPlk78w== 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_161056_576063_3403BD6C X-CRM114-Status: GOOD ( 10.59 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647229 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 B50E1C4345F for ; Mon, 29 Apr 2024 15:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=kyue/FRqn/p1WnqrFE53P+Zy+G2t8IVLierFxkwHoc8=; b=EbjrqMIH/AsozXzTfBGH/W6ufx vuOyPMwj9STXVyqhQiSBNCJRyybjUEnf/TQMiAOdnQw+TS+cta1X1/0abue+eL6T8zqccS61Ll3dU cyNX6jGk3uI5SNhCF3PzknF4YK7Ef+t9JTPhyKoi9kW/VuVfkLtA+jQ7yN4NExmYmODAXBZOjJLw7 Vmf0eYkR3ZvyG1TySKpyFvKIH+opfuVZPsgQSFZOlcKtxf4a3XgkWSOblw3G7xOz9iLY/M70YRasB zcNGwIB5v7FsDRbI+KRvgu0qiEK+qsMuUwG/4Z0UjelWJprh2086Ah/OK8O/ISr5lhr/6ireU1GI9 qlB9YBRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Si5-00000003LMM-0AGf; Mon, 29 Apr 2024 15:14:29 +0000 Received: from mail-yb1-xb2f.google.com ([2607:f8b0:4864:20::b2f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Si0-00000003LIa-1pUj for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:14:26 +0000 Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-de596c078c2so4285486276.0 for ; Mon, 29 Apr 2024 08:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403663; x=1715008463; 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=gm4nInBBxn3tEkx8bUXAvj/IV5lUhQgB+g797ZKc0qiMfhTG1Lz1jfseQxfOCtfy8p wVEgAdF4cl9jSM5/jC8elJFbJ3ymCtmzaBxMPn3VjuGDfSs0K1Kly+9kTl+3CYriWtCa qWZ2uKxAkMCI8Gh8B2i2KkAghN75lJkx2Vvuc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403663; x=1715008463; 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=vgLox28d3RvYgSMquI7ZZlnSPXeK4ZNa/zW/MtuvYTqCvLRV3KsNVirjjn62mMAxcX 3uaSy5T+VVkpoVREXiuR5jDC/9ZaUUoyB3R21wdvk9tnD9bx3nsHQvnTnY2Jrpq8X+U1 MNLcu8JD8oNsCMditzqaYVo0EwLP6FiJl4LDAudt7oAB2QEUsrAhqesNBjlPBA5t90F4 A/TfzAiTV8I9lm784dOrQ/VbTdZ3uARIm0KOn3453ujKSdggBdT/qZ/1ugtxTd75qgJj GaNUMa2Y1QP3X1jgo47OFhoAdTxnHC4yVTSgtWS6HK8W/xeVYFLbQ36AxCVR4hCdgcO+ WTBA== X-Forwarded-Encrypted: i=1; AJvYcCVruGAo6W3yBgjKI5+w05i3ofTMkfRe+Dx/+0gPCU5nPOxVuSC6O7bT4KJo6tZFmwdTVAu/Ox5oxUrnliMDNdZHjtWJf5WVwuOwL2TmLX9sPIz/ X-Gm-Message-State: AOJu0YwIeh8o0Q9lFYGqCtaOsEbwc9cKwqbZPWNFOOoTbHWwAoREKGa4 gCFsYaTbwdA7Y9RdwinBa19bznITebTTEgp8oUo5KMkL+hpacF1RkKQ7S9G4CGhUAlbU58DB+KY = 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_081424_533083_466A656A X-CRM114-Status: GOOD ( 10.59 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647194 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 F0F2FC4345F for ; Mon, 29 Apr 2024 15:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=WOR8+WeMkxm0czNaQrlO8zy4rfkYFKnx5dqFso5t3cA=; b=Ck3EjsS+I98mp0SXT241xX6Cr0 UVhF6kefFXiF4Iyrc4v8R5b+KSQE1Nq9Hx1+w7hRe+7D/tgwZCWr9BGPE3VlE/rvlSolyBqrwc1ym pg5qNIJ3QDf1KnSHGa0xHP6qnQpnqfPsGn4JLaNbJKpz8BumMahRc1bjGJNST8n2JSaVIVmR0bEQ6 1WIpU/8eeWoXgVe++CMHr74VRYUqTA8Mp5zogRZIdIx/sUAxsiMJQAzLOJhnV0z1A02BTLySSUK2U MB/w7e5elwtO5iZW2p4iK5l6pWvx3IwBCJ4CqA2g2e1Ut0x0nj5OsMVBvFiuHVaQje8xRzl6jLKuP MFYHoYMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SbX-00000003HEo-2PKw; Mon, 29 Apr 2024 15:07:43 +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 1s1SYx-00000003FX3-1oS9 for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:05:05 +0000 Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-78f04581a66so304373985a.2 for ; Mon, 29 Apr 2024 08:05:03 -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=lQErmco3fRVjb4X89NLrdGi4FIGVSrfyRiqOWHyIDdbJNDYXQJM0/9t6fnQJw6z0wd Me74+CcxoBG0600x0pOcybDxvDIOT4z6lkBUhNLfbh05x+vl7dV00CDbr1dCD19PN+Me Cc1aKJb0P/zBodHaGADQd2LptPx4XlPh+jgNsEq2JD2ZELgVhxsft3ymDWCGqQ0P+Xho IXrQIhfyzpBL1W6fkuccrbPNKuf2Q4mNaK2FqtaBSRqpHgMAXH4TxTC8fvB6WVIzgFr0 qR717NLonEW5a9NDjrFy1qxmX5zMcoziT8TygamsuCWtKI/hkQC4SOITQeUjwSAaA34v NJAw== X-Forwarded-Encrypted: i=1; AJvYcCW8jeDEi06ieRY4YbAzIrZCAvCwz+AM1Fpad0LvZYzgLNhxIpZgu7mKJ0RLDfTt29AtYRfhPAqgv4oeS5vNoAt6j3MZQhBgcg/TCmwKznqJydTd X-Gm-Message-State: AOJu0YxDNI03BQOY4GjnuSecB36n8xfK09xHkNkKa4gLmZoMVs13gWDc R4csVZixqF+JqnK4wV3GiWLBWoeLX7vjY522DltT5cpY7tQarqtPYy98JOfCew== 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_080503_737822_716EEB30 X-CRM114-Status: GOOD ( 13.36 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647195 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 BFB99C4345F for ; Mon, 29 Apr 2024 15:07: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=gMpzOFCFY/OFyCB78Iqov2ITRER3c7lueX7XaC40UJk=; b=ngmlzOUbw6RdbR9WR2CYVTOuSn 3YuadSCE1l+yGxmyaWbB9egpqnakLKqoFStRaLANgApwWApNmO6AWrbQ+b788sR/ltfrTDS+4mqX+ IpPxX+Xx9A0l1HhBuhkSd2wDE3cgcXXlGK4S2KpFwpfTCsTs5MsGgCs5nO+TjTUhB7XQT11wKJxwr pqz9NxgWVDTKHGBSRzlOJmfJ+PHvSLW7YUuK725zSav9s+UN10c4L1loYhfTthQJHlv+vg108UpLC Dl4YxyYPiiPJA5Kid1V/3+qWhQ5YiKYILJGzSsk/y4pG4QpBh359o2nR/YWchTVB04JvaJDFhtzqF O/qnpPHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sbi-00000003HLy-2qo8; Mon, 29 Apr 2024 15:07:54 +0000 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZ0-00000003FXa-2Dye for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:05:08 +0000 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-22fa7e4b0beso1700978fac.1 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=lt1thu1ZXiLZ/1ZJBlM2iZy/QaomTODmMdsqCFI5/Ja+GD4r2Db1ApJsZcj7IpDMma H6UxY2VHGtev6KSPTnRSQVMIU7abVfIu+h9cvyaGOP7BnHXmWwo/qzowScMvMSBOd4fK Yj6jsYjpCXFOLtadls8koOtGvhydNmmNzs26SlE6dvvbdB2omXKw31Z2Z7FGayXjpAcJ rBlpBDHvDfg3VRAol92G3634PMZjmAISc0yMGdkFEh6eSxQGu+PKxGl2GYlHXRdhNe7b +hmlj20LiyiWjl3y76c1XPPdg8dEVAQb2WU0tQuPJ5gFraex0bIerehCK1Hps8ayJE4+ W+nQ== X-Forwarded-Encrypted: i=1; AJvYcCULeokVLtSlx/NY5rWKI2OyEBzGUkNtS9KzQQKGHpFCq2Sra/aKT95sQsZ4ZzMP4e/Djpd+NlXPYkgLIjXbfAtwCM7SASoZDec0EjvnGEWOQg0o X-Gm-Message-State: AOJu0YyLOW25M8SObXBai+ZhKbzJ4sV9F3SUqFx8bTKEmIsqB/wLaLXJ TcbfcLgCJAl/2t9xbYFWDwMppmhjgOjlNuuXsi5by+/bNff4RCUyiGqSoW4dZA== 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_678288_5B24D8BD X-CRM114-Status: GOOD ( 13.36 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647199 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 17C68C4345F for ; Mon, 29 Apr 2024 15:09:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=8OKO6D6+Uymjr7y5phUxNbL6FrIK2B37/+KaDSdt/b8=; b=fvA2PVPfBjaSTIf/QJIVWuHi4D Zfu6b/TwpB9oEZQqvCPH36i69fDCplKii3mw1cxVBc26BrvBzG2KlQUrzE+hKXoEjEc5sA54LK0g4 FjNRFqiD/y9qTrvPQsmVJNKPkDXDSYO+4B62FYus2KaBYR5gqZKTftsd1M4kOx29BBIh/EJJmQJG8 I4fR/G8uTn40NxVp14wI3Od5QzYQbmUMyXKbJJ94WgFJpGY/ODaPkJRG+7LqL6ull7XSF7aGviPyJ h6+VEJUxOm8HusyPK9dhgez04OADj6FdTXE6ure0nIxS6x0235JWJUPiD5KYd06ZSbjDJ1m53A3zF 6LF44KhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Scr-00000003HuF-2BnU; Mon, 29 Apr 2024 15:09:05 +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-00000003GFc-1Uzn for linux-mediatek@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=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-x731.google.com ([2607:f8b0:4864:20::731]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SaC-0000000Cfma-0afy for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:06:22 +0000 Received: by mail-qk1-x731.google.com with SMTP id af79cd13be357-790f699eb2cso103554085a.1 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=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=icjZoqj9Nqbs3gY5hJd49Yum7HlZPdppqXlfOlLlKdkJI4n10sHqBNqTswx6xvwfqc KuaUmx5VEOGIgbbYSVzd6jhugT9Oj7aWUkrFmJ6ZVihP8yd6H/6TpSZYVyJ/vy53eDKk KTKuSJgnOT0EcTqCDt+0kIpYP79CKY+4ukGM0rzuantXJR2zaMAqdIDC4CqX51J7RCBp 8D5NsDKCwAXzqJAmYC4HJvSqNxL+IPADiICyc0gOR4zQclSVradM1uKjkqwzD2UAG7se QzxQtoyUJ4Bltaq9ig+9/kHT5RIwkVbxqSznQZ5JS6sfVnnQygvFvMqz5FN38wB/TUkr aCAw== X-Forwarded-Encrypted: i=1; AJvYcCVNNdvCQp0HlDtRD+Ls69z8qCkvVmGyzP1HW14RcSAodzwrmL4WFZ3n2zgz/+26yZCrU4l9Wn75hSLUhqkA1tbFQtTpoOM5/WKTbTZ18Zx0iHKF X-Gm-Message-State: AOJu0YwRSuk8rp1VhgW9vBFqFbKbUzNC5YKdRWehGTO1nycx4O4ptA7c diKwM+YlTxa23duTaz+K4HgT8To77vjHp8ILC05R1DaIKgeP+R2xbz/5z3A3ow== 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_160620_242399_24C304A1 X-CRM114-Status: GOOD ( 10.70 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647196 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 B4566C4345F for ; Mon, 29 Apr 2024 15:08: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=H+ICFE9T0WtFgFxAAIzneJg+RkmVbFrs0mrpkqFICS0=; b=Q8Kr876B6JPSvexCv2ekDVxRfL dPjTvktVnADuCshqTUebs+zQq5KxBEqDbDiu48LMeyE0Ot/9ZzVpcglUOHmLJfW3ztKccZjv3nNoC 0+UgkyuZHnLKal6ynJ1tLT/tec4SrSgmDFPjdWUxIb8k4J6R4quD12Sq0XM4FSvcjV8hBW07Q0Gke 7jIbYISJavZkFP7OdgxUafYP96gugPCH9s57r8NCnaDZ/g+xtktyTl5zcJpM9YOcmPjxRLuZUPMlw 3lz5EFprIkhdmdOwDY2+9f3CMgG1GdzxjJyziqkSO0hF6isIW7DGwbAaoqlX7ei3nFjPvV5CnksEf 0Wg+Omug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sbt-00000003HSR-0mrF; Mon, 29 Apr 2024 15:08:05 +0000 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZ1-00000003FZv-19HJ for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:05:09 +0000 Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-790ff1fa7b3so45309485a.2 for ; Mon, 29 Apr 2024 08:05:07 -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=VnIgR/9d5be2fOBRS9vuYiviZGsqd5hEYb3Kn5fUiGGc6YFnbE+mwb9Q3+gImY9FuL XOY7jEZLTqqbMbO0c5/vVlJiELy0SVuGoeoiIfQlrR+tmAZSs1PYDXzLvBb26vxABspH lIzz6ujMfM6bX6VKRI1fFeKr2YXp6GmXod5GFc+IuDg4PmIfh690zT84wbJqkkzyckF6 coF9skVD/yn60bWRaBGyWlyd6i5l8fLcCNEPy30n2H32Xy1zQuwiToMkzvMo8x3lkEk0 wsSarPEP0BvNOLN1SRiyIDc5zBbDTkjdxgIwzed1GFE4CEqQtl294twjaApXDmLiUTnl 2H5w== X-Forwarded-Encrypted: i=1; AJvYcCXKNqk7HWWMmXPLrJ80d0+FtzCE1evYZ8p7pkawY/zExu5re+lu/PCN7j5V83f+EzKLilMqBvgiadOvwS4psudbAwgnbJKTvTyqMCeuCn4Ut/Cz X-Gm-Message-State: AOJu0YzLcU0M5Xvz4E/nWUB0xR54kx+j4PqIjX77vJo6wBet99tC0iEt SWYX/RkxSKOZJyTStrbPWMRQroBK7dr6ftp7pO3w4Hl6W5bMX4xJyius1NqWbQ== 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_080507_572276_8FCD0F88 X-CRM114-Status: GOOD ( 11.01 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647242 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 97DE9C4345F for ; Mon, 29 Apr 2024 15:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=sSE1LZ8RJP6sIAmkq+8umDfF5CuS0FK0HNlyLUmOHag=; b=yJnVxoj61hUhGJsEzt/DN/BT2W TZgqXVki/uKYosxISH6gciXLPw8xyBTSpsV3GW/Ok2pEm3wQNHXO926JOUsBxsmRd0y1ixxYOpK3k 6EqzfA+OXll86oqJ+vTo9XaSHRgDyQ/5pnmErM9Nx7LUxJjhb60qmspKGMM1PpbxScIhaFxKDBXG+ tiNNGXUtj3o6Zu3uEKji0em+a3dzNYud2hhEHnpyPfQGkkCe5wfX4Oq2JhuFfz1qkV/FY69DgtEGN 54aF9V8/81isYZzqHwYDhaejvc0UPaRt6G65I2fa4TH31YZHUOHnLe2eCL6qR9faY7hYH7r6Xg+9q yNGFO5Tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Smo-00000003Mpc-0ieE; Mon, 29 Apr 2024 15:19:22 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sml-00000003Mp9-3SNN for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:19:21 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e4266673bbso40797215ad.2 for ; Mon, 29 Apr 2024 08:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403958; x=1715008758; 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=Nn8/+zn9N54iwWFf92kurrDbW+5K3wxn9kgHSDkHuJeJj1p08PXn+0YGdpTS5XY+vR ypHrCuCG00lCU5iVob+gmQIL1JV3Q2r8eg1P588s0TTz0oFD1TDykObCL03eIju8SCoU 7T4JA8XdKe8k/cCTVmFdfqaL7dpk5vJV62lWo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403958; x=1715008758; 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=YeK6TqvZCrNpr42v3GxMdv2bpKiwyKkfycLySAmB2DvzeI2CBLJxn2/xXs2ymXGDID PiADGsd/S8MN5kqHkZfFawnHYx9IEBZokfOKsQnQNnAqoBicebf4fWjlZUdgVS+UTPjq aAzcXPAAGqo/kXdS/TaKtkfkcqBiM7ZbjIevVdvnraLp3DZ8sD8Qga0piT2sxfM9j3qv LQ6RpcAKpFMx3y8u/wNrklHpe+mnh4rdLv8EvU2BZPRozwvynaBMD6hAM3nSHlRXYoXF Bgs8VDvltF84biimef4Cyw6t/nmH85k+vECrkM5abeUKd/xHOlkI+fArgA7ReQzjQeFC nSYQ== X-Forwarded-Encrypted: i=1; AJvYcCWcZ340iyGwUOapcRLzt9u8cPtFg3FBzZO6/nI9fktgqyqpKDEBSGUSipolYmc6Y0rYxZnoCCHgYaEuWJpeOFOh4y6WKlQ+GEj6hgk0F7StBaID X-Gm-Message-State: AOJu0YwQLAYnpS2udA+kVbyoFbMoaDFAehkC8A5eY4LZZsffnPkKct6v JMu34fi1dXP/Qp2ZXqpWB1Rpsh6UTg7sOgSg0+rVoBouDFeObmjof5SYepvcA9iRl6iHOufwTMA = 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_081919_870589_029B1381 X-CRM114-Status: GOOD ( 12.31 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647197 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 861EFC4345F for ; Mon, 29 Apr 2024 15:08:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=WhbcF3TWQTA5MkpkxmSIX7qa4yJQy6aIRpdafwtebNs=; b=Q1l6t0ReLh4inXkN35uWf67+ly 5nj0JUnEQOkdGWOlgDqw8xXM0CQisUKoMBCauHELXORQvtv91avnJit3lK/qcjb9LSsXGTWpBgKOD kofPmDkFvtByu9/SJM+su9g/b+12fjGy9u3Q1N4qvm27XEkZSx7/B4AmUbspssFgHe+aV8HqgPP8H 5+5640uvBO+uVUPJBQY/Fxp/lU4W2fiktv/uFuEVov/VHwrgYfqsb5w9BwBsV8I0U3uQ8DchfauN4 C4RSwXdOJ8z1kzjHKkOveEJTOw/gAWNavEZqShDqeLybL34bfQHDHp//H2Inq4ZRp1UXiel43d4e8 xaaPneqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Sc4-00000003HYL-0vFu; Mon, 29 Apr 2024 15:08:16 +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 1s1SZ4-00000003FcX-0CdZ for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:05:11 +0000 Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-790ff1fa7b3so45315385a.2 for ; Mon, 29 Apr 2024 08:05:09 -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=JuCuWIpwQbZLm4zRYha1NcCI8SywBKO/6R6LKSdR+xiw/y6/yi4kVbV4ezbR7GqJmg apsOXv2EGJo6lCb8JSlCVd765v42mb3pCfmaJpR/oX829drt7xCm3RkqcvYDjJmMrtua l9Ww6VI1FL5oFTuyRTdnGY7wZmVOfcEhpkXzXu8Z8Z003feJyCWZ5sZVEJED16O9CU8f RkS/5g7LCxivuFTLd2qMmZQjJaLzYbR8mB5PEqsk9v47lhRXxjE+LkzPduTqYmUpRvoL 8LYejQPz3RfGjeXTe7o4Rc5XdS5cUW5X1CkG6sw17bmECdDbOKpORSbHfZvfCidxhqSu PiQA== X-Forwarded-Encrypted: i=1; AJvYcCVQebeakRXZmZIg3M4jA78ovi3/VwRIHl6cwYLOOjCEWh3PKQvoHfRbRhY8pIl44fmcublK35uEShKVR/PtKA7k++NWbwVkWwNGyJ9N7H9gQQf4 X-Gm-Message-State: AOJu0Yz6TQRimR7AVPMDLoO77k+SCbfH0Tb8IzwNX3o3eEgs3x1lFqJK o4b6XWHU63UFyWE0wOXX9dcYz2723Rb7j6t0CmN/8wlJ/U35glWKX4rO5dy2fQ== 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_157099_344F166F X-CRM114-Status: GOOD ( 12.30 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647200 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 2D4EEC4345F for ; Mon, 29 Apr 2024 15:10:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=vmuUSFnHzqjHSVO6x2xCi4IdU77yIJvh23Ivq0XCHvQ=; b=ZVRiTpLhPbmEN+O4NHEyJCUl3x eyY2j3POhRnWwuP3zXeNEgdTxxRJ5gv0nFVJ5upbhJ0P1k/oKQou9n81znMfYh8GAa9vSeUS6HSOl 0iuqrCiv8FgjrantQJnPRXKz7715By1dPXLWiFt+SA9/auqn2yZoh8mFMwf37vxKMP2yd9kk6fViB OkNURmxpxUplWBhy9NlVZy2zEvT+4sI9kQNNGgXqmeRkM6Ty0TmXYz/aNIbVaXm/XTELr6HwYAS9A qDXyUspUwRpRNEwd5eRKyQasWO0yL0VzgOvrI6s6o/V8XShOhmRhx+79nV/VEqs5+YIyoEqu5QYSz 77XccWmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1Se2-00000003Iug-2dJW; Mon, 29 Apr 2024 15:10:18 +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 1s1SZ5-00000003Fds-2b3m for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:05:13 +0000 Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-78edc3e7cd9so346884785a.1 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=eGS2pTgldsHt4icwyJBFex+bdClBj8wpUDwbzxnr5kR0g+/kikoUkJXatRSZtdFTVH s8DrNClTQcjawBg1Q0mfX0HqDI0N7ZsVS9OCm7k/gbe6AKS0NZYCIfUalMMQeej6NDw4 vLuxGcKj4zvnn7HA8KDUu12rR8NtdV6uo2/2+lQE4ccNh4a+kUZwpOwA9A6whcnsvqLk aCKGClaL+RurFjMsIWYS7jLtdbquj0Q2y9REXcxOa8OKfC0DRTVTt4w63ZeL4bvZn4TM ZFM4iaB/OT2j/aydxLUqYyWI+IyuatXE7sXZtwLaHaem9kMVkhrzPcKMyX21rPPs4SkU pSZA== X-Forwarded-Encrypted: i=1; AJvYcCWP6X1IVIRV3es/bNU2hY8u3VgVFqHxgwXFFkV0ZtrCTd5ukSceLfw53GtpUtAaxIEX5+JkEbH000rOFU0BcDGS8OL42ZwBfTAmazi9n1FhbvaG X-Gm-Message-State: AOJu0Yxj2pgMZfCAks47pP70Wyuxb7/kfryjwjbRlhPUHysMuCJdcdry 4FGDBU9zhitoylspvAl2u4afiUbqWGWcLx9JAASrSJNArNKkugykZ2GydI3ChA== 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_781561_C7482A3D X-CRM114-Status: GOOD ( 11.74 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 13647198 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 30AABC4345F 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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type: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=STqazHEagBxWlHC69lQFp5WbvQ2Sdx8rB6+uKcUB0cU=; b=s47FDOkY81zjp/cTXIyNJryKpU BB0inkeLBwfJZqfqIwpYhnCp/sFMaFxdYNJTKOuAwMsoWufkPXw38IDz0pd0eIzFU5WE/u1Klxxo9 sMqSWr07q4GjEJIorw1+6e5vIihoDMQfBmPHLqUU0AnqtIBNlRYyptI5fT2XJGlX2xlKQ/I628F/O tWmUUTUlMIjsJkdolNzDWFSmgXcNEUDOnpAKTrvGD3Pia0pIMEHieq53E9OHdGvevXu7i1MF5AeId 8Dwz4nCCwJHktduSGwB/ipYB2elSMONCNzXwZX4C20nWbyCuEWiSehQG29MszvYOERDqFQaXLe7k7 6hWQ6F3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1ScQ-00000003Hgd-3Cgv; Mon, 29 Apr 2024 15:08:38 +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 1s1SZ6-00000003FfB-1I5v for linux-mediatek@lists.infradead.org; Mon, 29 Apr 2024 15:05:14 +0000 Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-78edc0f9636so308060785a.2 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=kzxNF2RVCPJhLy1rpZUsfQCPFndOwUNvhqpc5bQuaw1GKdpsse6mGakQ7pg5tJNqMu DmnSnlyE3ofd7T2Zm6WOM8ZmnxOBIqYs8TUt5y+zXRG95198iJ0mL5FX3lS2GXvs8/Pb xY8nSuVTF3ECGUzcN/pbskXVOuKEr/e4UfBjAGVV9U99Wd86FXfC45UTzNx7vgZiXShJ oOVpMjAbmwjT/9ydG0zID1eRcNvEoDDdVMms0Wv7OVtO00wwAXU1R3GcDQf6ZP3WacYe +rBMqrggel5bA6TXEKdsfgGfEuY2d6B4AFmGeeM7UL47JbG9c2SRGRrDHfFtHIBPlhHl 6bRw== X-Forwarded-Encrypted: i=1; AJvYcCWGXhM9bd2J9Ba5Wjd5ekYbu97nB+MLGJC5gJ5FdKlSMuFCmjubZCz4P4c1n6aEp8NLqd3QudDe1Y8OGwWOO143aU1tBFOrey2eHnTpqNYrt0f1 X-Gm-Message-State: AOJu0Yw7/SC85pacIvljG4/QVvdkac8ibQFC23FRZltXyLhCxRIhouCF 8+jhdh2cErD8Tbj5yozzcULVzAjwqdG+fr4XN6gKd7faq79vfkmfQxtgvsKwYw== 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_527750_9329FA62 X-CRM114-Status: GOOD ( 11.61 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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;