From patchwork Fri Apr 19 09:47:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13636055 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 7F8C0C04FFE for ; Fri, 19 Apr 2024 09:49:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xshWtdN0db7Z/fEZXpEU3RcxSMGKqnL6zopOVfXefXY=; b=O+l1NKuLNw/1+e ALR9W7hDVJedLrXXbwLT/DTTi9Fzp21l6LJuMh8ZtGVVXq0+av8UK6PG2POpkHdP/c51majSgMVOM i6e0rXVZnQhMavoeMwohz3lGxuLS5VzeBp9hWxOn6ftC4C9RD75li9EMl+K/Dfexj3d+OEi7P7Nz0 NAhCT4dxG3d/ncGT+atdlbgluaDViV7sratqlmljcJHkD1b1cCNwl0q8zMQ7Bj1neg/V2koxj9OKY P50BUtd899hb0px7N3/zMYLi9t6L9eEY75kPe4e/AccmHlTI7/9cnHXPOpVErY7HR3buDg8FIJHCY XhNsP41TtaxyXmJ8s5Mg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksF-0000000591e-1MRm; Fri, 19 Apr 2024 09:49:39 +0000 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxks9-000000058qK-13vI for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:35 +0000 Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-78efd533a00so105604785a.0 for ; Fri, 19 Apr 2024 02:49:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520160; x=1714124960; 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=TtlViaUk+ppF2YvB3wdQyftKniyUzK8Ej92YBlwMILc=; b=Wk0NTS9TlqBJOjnEII/PeGUvRBZO25ZAWK29Fp2BJeZQIc9bN4mtDRYXvmLcrBlqML fANhTAABTRaFXZ9iv9nPYgJE6GupMbC5SYdpbRTCo59RLUMbAdWpgJmJ9J9+N2onV/9C 1O9Nf11eWtyC1nOzM7mLdMPIfC4xwJdbFkbCU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520160; x=1714124960; 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=TtlViaUk+ppF2YvB3wdQyftKniyUzK8Ej92YBlwMILc=; b=h2JVh4ryOLhfBlyshEp0rKAOXVAbprfh3SOV6M22lCBDCwRKQvisVocoO3oRRFOPUs 82TfRbUxyUExM5MJ48hiAzDh1wRHZYIOSOeiLx87VSJMAHs3IiFbD+FrTK1JJE5QozMm Ohbw4ynKqd0O2I+5rjLaEYKlxytZrrgPfw7XLdmllA6tJj7+Fqixl6kgotOwzzC7LMVk 86w6zhPtPw572GItC7UnOBUvsEpTn8PC1IXWty8yVX+R+fL14BU1JD0e34ceOpLHSzUN pWReEE/5skK8BEhnSxW0nZ3hn4VK0/yEMDWVdKo88iJZ6252dICG93t/UPdiijwZGptt 7PKQ== X-Forwarded-Encrypted: i=1; AJvYcCWVZXp2zD5Pais29QloeZmpIJWNnttFeawpq800vGF347fdkZ8AkaU04GFBnDpNFkd4zmKN7vNP6eQH/K7OfZBgzBTQ+P/F3oHy7X6AQEQYnt4RXdc= X-Gm-Message-State: AOJu0YxfazicAEsqD9z/uxmBRg7MfKkf4t5bcZQd0TYGax8BPiZ2B+Y7 l9gfI6b9FG6zZzT0Ovu1JLcUlCyniUwXwsp7c8txIl2rXuqlMONQcA1KeTO+Zg== X-Google-Smtp-Source: AGHT+IHcSLXPGR/K0waZNqFgMaXNzaf95X9YYFUFUCHgvEpSUHJvLAV/8QVHrr+4o4OmwTvG9tzrkg== X-Received: by 2002:a05:620a:1da6:b0:78d:5065:c5df with SMTP id pj38-20020a05620a1da600b0078d5065c5dfmr1595944qkn.18.1713520159351; Fri, 19 Apr 2024 02:49:19 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:18 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:47 +0000 Subject: [PATCH v2 01/26] media: pci: mgb4: Refactor struct resources MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-1-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_024933_847107_43C4AB57 X-CRM114-Status: GOOD ( 14.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The struct resource end field is inclusive not exclusive, this is, the size is (end - start) +1. Update the definitions and use the generic resource_size() function. 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 Signed-off-by: Ricardo Ribalda Reviewed-by: Bryan O'Donoghue --- 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 Fri Apr 19 09:47: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: 13636222 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 10CD3C4345F for ; Fri, 19 Apr 2024 11:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4a9Ir8a9Relbtn7LFw38dpx9FNqVYGwjT/E4EDwF+2o=; b=EVGRksufzZyBZR Qq7JTRVhooroB34r+ttwwUNi2NFc5azKlsfwIvA44Epl93XPb9QySqSbEVnoXSwNtCs0H6PPWIrDr 6IfVXWq+c1+2JNhwC8hbi0LjAVeTUm5Dn8xp6RIKNLkXy+PY49FCspE/0dHPfm+MNX1vOl5WhjDo3 Bm8MpIcQR5kBnaDWmioADYeYmrEgpPa8d3gA+xEOh6OBRZpJPDFNLv9/z6xGbkrFiurQLCFKqX9MG 9J2r8Wkv2WtGk/HJWI4eSi/SE0+qmSbWlOeqA49HuTqUkBAwrhh17I8gKeiq/BzXI81Zn7XfhAwL8 MuYgBzQTNXvLrotDuaoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxlzk-00000005Nls-3qVs; Fri, 19 Apr 2024 11:01:28 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkrz-000000058qD-2kPT for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:27 +0000 Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-78efd533a00so105605985a.0 for ; Fri, 19 Apr 2024 02:49:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520160; x=1714124960; 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=xe5eM9+2rh+qYMrEZDkgx2/xN2LnDn/yiZVZC6+s6fs=; b=L9wgI1EGmQucC8S/gJ4dhAw3YRw+mu1YsHSx/d2rLcqGzoVkXrQ2wRJVt6in34o/Sm r2hzbbEA2ox+ylKyMdbUz+kDOHkFz9vCUa31YXWvRR0/mmo/3FW4F6v2HW72jygtG2pf d2Z/n9H1X6TNy7mmhiuAMB61Muh3oxZe8EF20= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520160; x=1714124960; 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=xe5eM9+2rh+qYMrEZDkgx2/xN2LnDn/yiZVZC6+s6fs=; b=dZfPKOezGHPhqewf0cIK5V6BQr15YTmBWTg8EhH7bWc9X08ne1f1SnNTvrOh6gKhud loTQUMLtAS/Vj1qqjmzPl1pTjGbrjzarqTMUe/JY0+i+pmvVdSGvWJfwwdMT+82YgbYo zW+xOKdcRyJD2eoc1eka5r0i/Y69Ocb9PI7lVaXCvyx2oifb1V14VoKg5gzJoUJ+q8CJ cEyGHjFG3+OUek2CMGkeaX8CXIQfkw1JH7vZ7lKAmRRAuBzkkuyYHnayfi0g6aFEVhU6 hE4Ai0vAcgULEY4+MuFedgynAW/aqKfW9IPK6KtAGDGoupMU5EV8pkPVF736lMLpUJgr OHDA== X-Forwarded-Encrypted: i=1; AJvYcCUQ7n3pOUGwl9GVSof4WcYEdZyKWMMNLwRbV0C/5L+IBEXGp3ccRaM3E/RevfQ9LGgFEuzqctvTsq5qN9MfGoFznAYwAzJNgZhjx/36CgpHTJLvmi8= X-Gm-Message-State: AOJu0YyCFje4dCTWni6WTfK9rDP2w5+PUCT4fvw2jrPdhLE33NbZsXv0 9BO5u6AvuV5wHr6zoQI1DtPhaNkXMcTV5lsRTaCx6coqsHn0U8YzHBoYBQcGmA== X-Google-Smtp-Source: AGHT+IHKE5I6bNN/ygxYDQdIMuWr0dmGCsznmTcTgLl7Ioa5cL0u9qYtPjL85KqnZCORUNl4F1qURw== X-Received: by 2002:ae9:c119:0:b0:78e:ca95:81c5 with SMTP id z25-20020ae9c119000000b0078eca9581c5mr1646405qki.77.1713520160591; Fri, 19 Apr 2024 02:49:20 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:19 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:48 +0000 Subject: [PATCH v2 02/26] media: stb0899: Simplify check MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-2-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_024924_047084_5D78B305 X-CRM114-Status: GOOD ( 13.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org chip_id is an unsigned number, it can never be < 0 Fixes cocci check: drivers/media/dvb-frontends/stb0899_drv.c:1280:8-15: WARNING: Unsigned expression compared with zero: chip_id > 0 Signed-off-by: Ricardo Ribalda Reviewed-by: Bryan O'Donoghue --- 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 Fri Apr 19 09:47: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: 13636224 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 40CFAC04FFE for ; Fri, 19 Apr 2024 11:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sfo0iM2eHw1fSqYwx52VgfUncVEx/GOextdrvZCGbus=; b=xgu1SsOL6WHHzY /tIecCzVxQAx44fG07Gm/YcXF7AjwBIbeKMnblVanEtgYAx58u9/Cxfc7poRZgWAVSDAJug7jL58i E/haPVzD5cUHlEEDFpb/eE0CCzt92vdPQExBrAYhoHp9Ait1CeiTzDGPeliGvlgNTItev2NzYDag6 Kp5XjGNbEnwV1qye5MOCimnl5uZWzkUxUIfp9zOZc2kjVIk5OWgOXlJA8Z1CaiERVVH3WEdmojJdx 8QZ643GdhnWftxJk0/hYfrz4E5jSeilc224p3ZAOk8ZczFyn3q50EUYrI6duhhlaMmUhaIMfL8KJW BgmzsW9YaWpqGKzqh7hw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxlzn-00000005Nng-3zek; Fri, 19 Apr 2024 11:01:31 +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 1rxksB-000000058qt-0WBc for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:38 +0000 Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-78f02298dc6so151324685a.1 for ; Fri, 19 Apr 2024 02:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520163; x=1714124963; 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=2ozatrqAUW665TsgI+DgE6yWy8Evw1+ngHGTHDukygk=; b=cYzd7AR+I0kDzZxmUOUBO7rkmvOlZ1IERsxkRG+PSGAMSSB+vRpVW6xk5g+TwPdPx4 BmowT1Hx9KJM15grRacDI0iOc9JEcbAt3A414bdTWILrUAbSH0c3JJKFWBr6N/gKM41R S8LLeV3md4IpDJA26CfMHGh5XWhqi1R8eyXYI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520163; x=1714124963; 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=2ozatrqAUW665TsgI+DgE6yWy8Evw1+ngHGTHDukygk=; b=P+Y0CeWnOHEnNKUvAAWsHXPb6cMs+s8khF7PPLCXPutOPYu/Jutx1iz1ft+Inlt3Zh IY8p+lNhADsQb4hP1wLlWVS8q1wbImL9EM/iXOhA6A75Lf+SUoPJiRZfy3xGLNSKlBd0 oSekHrXxyEKOilkJ5wHduwAF+AbCSHFHtOnIwsXltc4qfdhgMhw7s4+WSXC6pgSY5nWV OdyNULpYrzbQjs2EYVss/Ek7uMZxr6pQBAE3vzJ5AlhrbtVryReQDmnGBCql8MCzCN7D PN2gTsWjdwQyueLU7gE+yjMYGjTlHBGb6YgahBFlWjP4UGorIiOZdFMrk9XMa6HwGTTr Q0Yw== X-Forwarded-Encrypted: i=1; AJvYcCUe1rjdLnLuJlnYn0Mlf96ve6rdPzz4GVRvZ/gWGEJKfn+co9Hbx9kzGtsSYe26khytINDN35XRZzhbg1yUBlhFlPWkjUJELV4FpQvzDPFvt46ICX8= X-Gm-Message-State: AOJu0Ywbc0PDHz30G9j7WSDaLcmMpJ9KhKzbJps7jvkm+vP3+1jBLP8O +bUIE/d3HQUZYjIoztW2b02W+P1iNYh3TlErbgIEJeDWoF9MZ/d54BcpWQipMA== X-Google-Smtp-Source: AGHT+IGs3CfAvghko2vWhqg08VmqqoJ6LlEsRGr+WfzIJbh8ON10G5msy3tcDSad7YCzEwumD2LtKA== X-Received: by 2002:a05:620a:44c3:b0:78e:e679:23cf with SMTP id y3-20020a05620a44c300b0078ee67923cfmr7789538qkp.1.1713520161754; Fri, 19 Apr 2024 02:49:21 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:21 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:49 +0000 Subject: [PATCH v2 03/26] media: uvcvideo: Refactor iterators MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-3-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda , Sergey Senozhatsky X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_024935_337000_7F765F0C X-CRM114-Status: GOOD ( 17.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Avoid using the iterators after the list_for_each() constructs. This patch should be a NOP, but makes cocci, happier: drivers/media/usb/uvc/uvc_ctrl.c:1861:44-50: ERROR: invalid reference to the index variable of the iterator on line 1850 drivers/media/usb/uvc/uvc_ctrl.c:2195:17-23: ERROR: invalid reference to the index variable of the iterator on line 2179 Reviewed-by: Sergey Senozhatsky 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 Fri Apr 19 09:47: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: 13636056 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 67FF1C4345F for ; Fri, 19 Apr 2024 09:50: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f9PfJLA/RjPqF/RaRea16xpMTEWBs0fSYxEHCTYu0JI=; b=jmJxojXXbX53Sr EcoVt0WEubYVY8RY3TkFuJQCaR5V9qox677KhB8Tj04kpqpYzXPRmVvBGnb5xCD45E5nMCOt5+IKN K8085evH+nLCvrVfK5JoriCgjkOBSkBqfi3fYqxYNQc9hmnB0Yg65OlyizQRLXUKcooyJqAhuzSx/ ZUoClfgeIvc181iO95MQKmacQFs9J/7Io3mv2c6XxvBSLLMtma7vePPcJrpyrYzU0HgfNyK3kkU8s noxPHnt0rtHqdqTOiy3tLcWkdSbztmJP8ZYfVaowttOG75fwH1odZQXLKdvf/PkDNZrofjKJrDy7Y 1jKpDBHp59L9OokD8e7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksg-000000059PT-0Xe3; Fri, 19 Apr 2024 09:50:06 +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 1rxksC-000000058rm-04hw for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:40 +0000 Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-78efd0fcec4so114622185a.1 for ; Fri, 19 Apr 2024 02:49:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520165; x=1714124965; 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=kFlJt9OXRDt4H25V+OeXIj5d0OeB5gTMPQ8UKFCjlEEaQ55og0bptyQ+zt01DZ4uVw Yiydaaq8jxGfBlWHibKowzRBkL45efyns8ikkedGVXU2S1UiehrHb/AiVXk+eN79jtC+ P2a2q/guU/ph5J3HUx5D+krvV5n1WsY+fuclg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520165; x=1714124965; 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=WU8iC7Kve/iorsMb33MO+YJg03qON7866flAjXJ1UnqnHLH/R+wHd6gZSuLEiOEVOm T3eWbPVUveAHIpyzlc7lCXga4cZ+DjaLsJ0/Y4zL6jLg7na6T0jB8Lz1iwPnXM4FKoST XuhgXAwYE1nlPiFYeLWqAJ+LnBZrCzbVIWhg65lez6mv4GZuPn8WyNjOLkxwtTffU3Q+ kE96tyL2UQmtpoXh/6bvgJY1xUQAyX9LRZXDK19Y8TqNnD8cw5cXOGYP86oHvlr7SYXK I+cyn7z09BTZuuXWEvjDNQRHUVx+d8L08sp44g9hYq7jmLY8usV6qAi2VUUq08r+bwNs eFAQ== X-Forwarded-Encrypted: i=1; AJvYcCUeDRSz9ejfXKEuay1UVfwQnkMOlPracAXjWsPzJoarReQR5YU0/LfDzuyn5eNO6/SW3310AD+dbGV6ocmOEVcozqXXyBoyzFVBI07gIoY4bRCBw4w= X-Gm-Message-State: AOJu0YzH/2zjZIY3qqHffLtm8q51lTbq0ptu0v4lGveJFRPM59DqUCCR 67w7EOzYD8gQ3auRtxtgHfIMzOJoGAcoFuJlD+EQn9ocY0d1FoLmieDSJxlDSw== X-Google-Smtp-Source: AGHT+IHomIgtJUPKBWZHNjcgUxdMC59m2s0CnNC81cRH7k5Yf23XSr3oTpLeoFOU8oA9VPTqHwEHeQ== X-Received: by 2002:a05:620a:984:b0:78d:6b8e:18d with SMTP id x4-20020a05620a098400b0078d6b8e018dmr1691369qkx.64.1713520164849; Fri, 19 Apr 2024 02:49:24 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:23 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:50 +0000 Subject: [PATCH v2 04/26] media: uvcvideo: Use max() macro MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-4-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda , 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-20240419_024936_339703_26E7CF29 X-CRM114-Status: GOOD ( 12.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org It makes the code slightly more clear and makes cocci incredibly happy: drivers/media/usb/uvc/uvc_ctrl.c:839:22-23: WARNING opportunity for max() Reviewed-by: Sergey Senozhatsky Reviewed-by: Kieran Bingham Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index a4a987913430..4b685f883e4d 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -836,7 +836,7 @@ static s32 uvc_get_le_value(struct uvc_control_mapping *mapping, while (1) { u8 byte = *data & mask; value |= offset > 0 ? (byte >> offset) : (byte << (-offset)); - bits -= 8 - (offset > 0 ? offset : 0); + bits -= 8 - max(offset, 0); if (bits <= 0) break; From patchwork Fri Apr 19 09:47: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: 13636063 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 E6D3DC4345F for ; Fri, 19 Apr 2024 09:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5QNcFU1KFPNy1+BZGmhPhjA1YqpPHwQL6m6TUaLCcYA=; b=DH0LWIYvW7TYLj xd4ifDlIq9QkLjbKP3llR4hwDv9xUizBThLLjkiSul9fu+VzSqZd/3+2hGAfuufRjJmybiY7Lisc7 pP3rbTWZPjpCy1VtL2Y4/nYHBq4Fk+ok+R+Gek+YS7+a+tCNrzas6hb2mqAsIVe91ZDlqYqxIsP+I kw4FDaRnADN0m8asjP5jRIBFE0jijROnaf0mDCV44wYyM9aFAkiiKv28+CYyXE6oAgYa+sFu8pJ8C bouG8BlNUDQ/67TwlHRWrvotxlS7yFK+AJwnrzIBmpoCaCCQLRXT43+Y6wJKcA8KNLBWGM/I7i98Y s1ZSS2Ma9khXhvaLFg7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxktv-00000005A3b-38ly; Fri, 19 Apr 2024 09:51:23 +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 1rxksC-000000058se-06GL for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:40 +0000 Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-78f05aec21cso124222885a.0 for ; Fri, 19 Apr 2024 02:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520166; x=1714124966; 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=r6LFW19gEC+T0JWPpzdeGsrE8gqRTr2t8fOHXzLwHuc=; b=e+7PDr9S2S7tmhp4QiXhYYy3Etun+hBg8R3COzxeVc9FSwKOpsS/aOsM4UnN1Wrn5p +bWJWvLv8KuKr/k2ARkMjErumQ5XLXwmXdumqaWltmtGNxP8AQ1JiKa6N6OYJENe6SsD 5bfd0fS8yh2MzzXTETTBqv8p+5NLNyLpsDxKM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520166; x=1714124966; 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=r6LFW19gEC+T0JWPpzdeGsrE8gqRTr2t8fOHXzLwHuc=; b=PSnsM2c1AsJHs7bRRZCmMuV+ok93zx3iXeMH430PbsnCG1QNs0Jc4WEZQbNq5rX7OX 2cp8KxInw88Imz5l8M3l1XJPRrjo7Cnwnu0JvM0MZgJ6IqrCDmcSpi8TvNuSH9cpZ5MW gD+3CTSwhftkk4Uh5Xj6XufLECvWSu9xWWGmwqHP5bJ/aMUW14Ij9wnrZ4E1USqDGWnr tO9JWbIq2oe0P16aZfAaJjxJ1g773QS2K96JNUGEu+7+MsSaFT4I7/z7fuSJo0JTNN5O K5CdNnIij/6MSL3Z9aJLZ0o19jAHbtsr1gHJPopsP6qfhQIennj4S/RxuIA4yyvfwteN OCTA== X-Forwarded-Encrypted: i=1; AJvYcCUi582/Usdy8Oaxa4gF3kUv6gZ+ceYoYJZJqMLVkP0ldA+hhs5w9hZ9WhQCCGolJPbhccXwIx9sV52JuQJjn6SUu5a/QIjXFL4NpthahQ8UaI+M+6I= X-Gm-Message-State: AOJu0YxsK8n3z6qBbu6OpIiTRTlAh+kc+Z+qlXeXxm2rznJz2IppqdVn Bo3jeC28t93K80KQCRFGXrW2QK+huK1XOPS3Vt+3bqGlwEYWtogJ+gGter8M6A== X-Google-Smtp-Source: AGHT+IHUtLmGGbi8XMjkj1WeDSrpOuo1PYSYaSFswG+8Ppa9nSbCTEFJOTOGzt08rmRjKE1fcvdYDA== X-Received: by 2002:a05:620a:4586:b0:78d:70c7:af with SMTP id bp6-20020a05620a458600b0078d70c700afmr2461486qkb.13.1713520166155; Fri, 19 Apr 2024 02:49:26 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:25 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:51 +0000 Subject: [PATCH v2 05/26] media: go7007: Use min and max macros MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-5-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_024936_229758_58F67923 X-CRM114-Status: GOOD ( 12.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org It makes the code simpler and cocci 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() Signed-off-by: Ricardo Ribalda Reviewed-by: Bryan O'Donoghue --- 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 Fri Apr 19 09:47: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: 13636096 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 9F05BC04FF6 for ; Fri, 19 Apr 2024 09:52: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZU32m1txodhKfxE10fy4Y9OV75yiqH9KpnrgTCrG5pk=; b=vqyCTNl310ycwl iv3qiuMYepJTp2D/l286R8DHE0TRVQ4nj2qFBKmbIM0sc+GlJiARUEPukyV0IwFWIJGhfx2uqJKPc Cmy3CpYFSVptNQvufPL3e8npZNHqSatLFHgL/Nis95jh3qAxxtOYPWZWr7jCUW+DfxZTa/vDSBaa0 riDW2FIV/aeF+n6mMvZLISQuDFdp6+aZ4MwaJrh569oaQOf8B7NZfwozV+os2X4TeSv7VfPy5J6Zp xvoxwX94FVBgJ1bEAObDG3fy3f3L7IrXC/DCTlt5p8haKCzG46iR+aIeLj7QuduFoRyqhNbj5TLAZ nX1n42s0qxYsUxfuhiQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkud-00000005ATx-0dNw; Fri, 19 Apr 2024 09:52:07 +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 1rxksO-000000059BX-2UWU for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:49 +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=LtYl9w0rOEhkj26cvWhCGa7iaXgSAClc12fCrbixCRY=; b=M3Uyy3okNIYPkjIHtQV6uFIlpo WG2ZN6+Xp4hWqkOrHcX67BU1IFaGOVKF80huxG+cULzmcMDcYoXckEHIIaKSM9wvsde40d+/5zQx+ ygTawaH04+FroMHOTploEXkGg7t+/Op/vBqLQQeiYnOxCyXZJviG0aPRpG2TtFJoteH/78Y3OLFMK To++xvfTiEaoT0E2w5kyzPYNLYGK5DGOTT/IPM0UNdKTa7ppwVC0f7msrhLgUDACp7QAuh9n5eHPg P6O+7nwN+ihOc0sofc+Ed9x1D73sNUWs0+PiYpR14DYbZUV2mSGVs5UvmFCDPrHaHsHg4kqyyxysV 5b1CUF2Q==; Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksG-0000000COPC-2lXT for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:46 +0000 Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-78f02298dc6so151328385a.1 for ; Fri, 19 Apr 2024 02:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520167; x=1714124967; 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=LtYl9w0rOEhkj26cvWhCGa7iaXgSAClc12fCrbixCRY=; b=VieoLwg1yXcpGl0JmH35TuMTY2iX/k60AXpOkjC4F/xhPF8BNp2CQ7Vpp8wpicMjYo 5o0wmTkbuQsQs0FCjEEAYsmVyWN2GzIITqxIlqwM/PD9bfykGdptqJJ46t2b2ExO4P1V LC7mEWmtK0i/1k1/NSenlbhDCWA4Hr4GiEB58= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520167; x=1714124967; 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=LtYl9w0rOEhkj26cvWhCGa7iaXgSAClc12fCrbixCRY=; b=W1c6y58QkRx/auBlx7utZQ14LXv5rdEgmzokkav3YzOF2RzbCoxwlGMnESiw/+OaNV HWTs0coWiaEaKsEe9kCIQaqjMIsVtmlTvZdx6Cp3YsGalji1m9AuiVoJr/4XAa4j1tDX WL9WweWGDHJE1oGjOQpzvmoRNtTs1a+hUWP5UAPo7QmJPT7wFAh0CyekSfJJbK8lTC5J 3SswoQbEUu5lZVd+yelDOBW+UeI48vpfJTgS+x9Cuny4O1EDEjQwXBlpyzunDWFxsNq6 RIz4M5OVpYfTQHZXTqe1lUNf0roBNnnilC/Ryrz90L0ZvrRqEsKjpruuH1cEMCDQ3M9l 6LvA== X-Forwarded-Encrypted: i=1; AJvYcCWXyopkMjGoLBPdJMbgb/JP46Sg+5TvAXVlDAhj9vYZ3PXC1bY74lhfrWvfmW01Mk/aKpHf9kgKNuXSOva+GVmWR2G1dxNX4z9QaWV0uxtdrWs97Kc= X-Gm-Message-State: AOJu0Yzl+dbxD9ujGhB3Mvficls7PSZpqUyjAU44w44Cs4TVe6B9hacu tgEmtB+/RQv3+q+yITdeW3rlQhhqLngtn1Rk9cEroMZiGdSoZEhKqfimBSxloQ== X-Google-Smtp-Source: AGHT+IHJxWxlXkvVgayg/8KmEPlEYrjGm6s2oAW8VlNrxH8CHO+X8RZjNxTD6ZWD86mZ22X+MElfTw== X-Received: by 2002:a37:de0e:0:b0:78e:eb64:d91 with SMTP id h14-20020a37de0e000000b0078eeb640d91mr2763665qkj.1.1713520167230; Fri, 19 Apr 2024 02:49:27 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:26 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:52 +0000 Subject: [PATCH v2 06/26] media: stm32-dcmipp: Remove redundant printk MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-6-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104942_249748_483DE573 X-CRM114-Status: GOOD ( 14.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org platform_get_irq() already prints an error message. 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 Fri Apr 19 09:47: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: 13636223 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 B9BBEC4345F for ; Fri, 19 Apr 2024 11:01: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7Ofaw8FZbR6I9NiBS36Ui1LvKvQTx1m85Ae/gd1OsEI=; b=PKsqt3NTzr6fVd gug3znb35c/oIAP9wljHaecl34Fzahg4l79ugYwP4+dvfahjIVOeGm3RyYPjOgr1YugMpFQJQdWEL z9RgYmjYGMtGHXanuQRvWskaDg6+qEMtoUaY3uqa6CjgkUMecay4XNSNyPh55tv0hwhCuhTo7NIIU BI7Z02x3c76htkh78l7eFaY31dLud9QCoK7s0CdVWAs83KMzOIRcEMVRtyV63L6xG86W1pJvKJ+ax 98CyOfvbpbYm7efSWucHv7+AEAh3Ox80xofUy8arrzu9HH8zW6i4ebNt14QYuX6n7uZ8XisTeFX53 xvAQunMpVITljujYiIuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxlzm-00000005NmO-20g7; Fri, 19 Apr 2024 11:01:30 +0000 Received: from mail-qk1-f173.google.com ([209.85.222.173]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksA-000000058tS-495V for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:37 +0000 Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-78edc0f9636so124268485a.2 for ; Fri, 19 Apr 2024 02:49:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520168; x=1714124968; 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=Fus2+N70S2qjvVvu0/6vtfUNPOxEf5GrzY84LMmPma3quYiDEentg0gL7HhYTvKHFN Bwfv/vgsyBrSpbQPAyPFgA58bM8s3TLCTtmZrPKaP8pcHB5IeMxHE05RUTyxsp/X86gX T2fuQ2j6BAsQYiP+dRjDwnbco4MOa95p+3N90= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520168; x=1714124968; 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=k7zAHrJrBKxLviAYWTm6NjgRQvKtW0D8lf5qVvoe8w+HxhIl9Kn/slqF6haO4u2AvW q/PuWeMgwfVUISjrV4hLjpg4MNMVqDo70VviErIH87YsoYLlQeAZxRyes8Rv7PEJsqpi RyHJBkWkaj4R0MGcreceXlRdLSPzq+E9YUsKxTz8SCVFMwmFEFpb8tFlxP7qDoIA6N0+ uHchbm47M970on472llHkmFpczC660RB8gJ65Uq4HuQ1fxFwAti3u7HoFys1dj1V6Lpn jwfKUOrPNvlUTBNKlLtHtgAxU520fX4QAfPjAGebZoZ/1YuNt00H+Yszkx3WrdeAj4Pl JL+g== X-Forwarded-Encrypted: i=1; AJvYcCU7EHm218lx3NAsDGQVhqosofMOIihEmbkTZuhLyCXhiKB2U18P4hhUX5GQtLLxnQXkHbWwQIaPCD/9hG2DJoMzNIgaZBBESvxfurEbtdjdRtAQuZU= X-Gm-Message-State: AOJu0Yze2MjfyFWYa2wTc8QKyG1HwY4s/3p05y6XcvzC1k7s4rQyrLyc dLrLfkdzz4mh5xGpjq8KXjYt6BL0rzQxSXbxWFniRLlIi4AQ7ZQYtov9lkKmyg== X-Google-Smtp-Source: AGHT+IGrWT0O4AGlUln/2gm+WlWRdrbCZXYUSj9v1TAvaCupc//lNt4+QKq4Vo16BjNxQ14XM/vY2A== X-Received: by 2002:a05:620a:4083:b0:78e:db2f:2726 with SMTP id f3-20020a05620a408300b0078edb2f2726mr1792928qko.51.1713520168153; Fri, 19 Apr 2024 02:49:28 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:27 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:53 +0000 Subject: [PATCH v2 07/26] media: staging: sun6i-isp: Remove redundant printk MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-7-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_024935_093610_FF434FA7 X-CRM114-Status: GOOD ( 12.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org platform_get_irq() already prints an error for us. Found by cocci: drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c:389:2-9: line 389 is redundant because platform_get_irq() already prints an error Acked-by: Jernej Skrabec Signed-off-by: Ricardo Ribalda --- drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c index 5c0a45394cba..58f8ae92320d 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c @@ -386,8 +386,7 @@ static int sun6i_isp_resources_setup(struct sun6i_isp_device *isp_dev, irq = platform_get_irq(platform_dev, 0); if (irq < 0) { - dev_err(dev, "failed to get interrupt\n"); - ret = -ENXIO; + ret = irq; goto error_clock_rate_exclusive; } From patchwork Fri Apr 19 09:47: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: 13636098 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 8FD25C4345F for ; Fri, 19 Apr 2024 09:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YMcsnzBd93Ou3WahTrZkr6ZVQ4hryPLp64xuQzJu7Ms=; b=shItScG8slTO/e IWvWq2hnlBxJnGYnaCRpWLlxFOvekHWvmD7+xhD1MmoII3gbvFIjhAa/lLUDf18YROpEcMlzNUW2z E69btcM7Kka0+73NScQfoZGUAAY4A3J/OW3fcjyEpwjSUWK5V9NxvCOKFr+DlXl54RPIlPXIqWqvx 2TQcbkJdd+u0KHWIL5QRwoyw5f9xsyNBhGSFjBvY+58cXTFMITC+zR0ahCk1f3GRmVyxjKO/9vhhn gGwp4U4uFWsd9AK8iQ/LaDGa+u5cxSGPLUQIi456nXulESl8KkVvgSNRVBRDQkZkVmLvolFk7cCbd qkNt59HHM/rN3GNgajLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkup-00000005Abe-35Cj; Fri, 19 Apr 2024 09:52: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 1rxksP-000000059CD-31vR for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:49 +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=OI4AOi/6PtgU5zRnLUWjMVWmm8Y+CckVMvMt6qKhGc0=; b=MJn4pbKb0dYQcAJkCQT152EYde szq9WX75/hsjyCmy/RoCepEBXEeP64xq3Hm2VMMi+Tacwn1ewN/d0A5ZPJcFUr6XHZGH2sFWg3UqB QLypwW7N3sEoZD2+e2ELH7C62zwAjGYhNBBwdsan2QzFWgwEMv2DNoO+UdLqCtcZzdw0+9KFTGBZd y2z+zpe5MEuC4U7FOhEcOM/TsOzObgyrCZBnplw/FfQ8qMHOTpH5MQzLh1P8fbaJj3hhDfyT4hpiJ OpWb3GN2s/gRCxY2xViPPBzLDob529BWegkzkHh+cHfPEdJUuL1091UITJ2Cc5j5Tr3qfIJJckQpc M2FE4Dlw==; Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksG-0000000COP7-3KWG for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:48 +0000 Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6eb7a0b3fe7so1118009a34.2 for ; Fri, 19 Apr 2024 02:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520169; x=1714124969; 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=K2NrA282RPrQYhc2MWT6QS1716yrp9wybzQ6wF/RWEPqE5z0J8RutkMJIaDm1VM9Xa qXfTT4cIVYKUxpiPFkbJlpvp2LdOTyuorRWNQdanDmlg3IBN1lVVVDEjMr8svPT1kGwQ pnfOb4lXgVVxO7JC61uJeEGqeb49tzI6PLYwU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520169; x=1714124969; 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=lnop+n3T0OaMBgrRRJVTTt3jNzPeei7cTIKzzzzDvw3Mpddgcz9n8RQlw/ikIGDm2P GgMUzIH+BuyiF4qEcOVBPdvNrpChKsS5J/DU8FrDgV6namIRHS+7MF7mlQeVzbN+b3P3 8RSz57fxBJ2Airaak9ji3CIiGpU+6uzQbkkSAOzNYsnWgzDOXa28WSr92suzjbbDTAY8 aYvSlHK8yb0V8Vm5KvRgNHTSXaFbnBn8MeuffLhVbJA0QQ1h6Ita/XITvDOuCtOcTgaM IdqcNCAnHZAwa3O+bLAJoyRl36SSg9eCgjKM8hTMHkZcQ+svDm1LxSAQxu2cPancX+8g jVFw== X-Forwarded-Encrypted: i=1; AJvYcCXaeQ7EfaQOh51y4IccS7HltHCtGw5+BU/SLzsDeO2uedqreFY7uBPgmAcLdryr5G5dTRSGcmJxdaCbM4bCbXTuIRzylWyCgdPl7TvJNBh20FcN5cU= X-Gm-Message-State: AOJu0YwXP6jxIs0aILrAhQzgeJvKEbRxHL0G8ZJX9rE/oBPrQAIYCE84 pEJ/ncspYgBWa6/dPLIp53V517grE6evtxn4Zn4x1mAfFbYFDG+DDTVLmsDRKw== X-Google-Smtp-Source: AGHT+IEoa3EBjJC9669xc6mPVpvtJwhrzrmUgput3DoBfmRttNa6KJF0gCcMfSkwX6iyc+U8a8TeQg== X-Received: by 2002:a05:6830:1d48:b0:6eb:7a07:8746 with SMTP id p8-20020a0568301d4800b006eb7a078746mr1521944oth.31.1713520169041; Fri, 19 Apr 2024 02:49:29 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:28 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:54 +0000 Subject: [PATCH v2 08/26] media: dvb-frontends: tda18271c2dd: Remove casting during div MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-8-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104943_043525_8B6FAA2F X-CRM114-Status: GOOD ( 13.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org do_div() divides 64 bits by 32. We were adding a casting to the divider to 64 bits, for a number that fits perfectly in 32 bits. Remove it. Found by cocci: drivers/media/dvb-frontends/tda18271c2dd.c:355:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. drivers/media/dvb-frontends/tda18271c2dd.c:331:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-frontends/tda18271c2dd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/dvb-frontends/tda18271c2dd.c b/drivers/media/dvb-frontends/tda18271c2dd.c index a34834487943..fd928787207e 100644 --- a/drivers/media/dvb-frontends/tda18271c2dd.c +++ b/drivers/media/dvb-frontends/tda18271c2dd.c @@ -328,7 +328,7 @@ static int CalcMainPLL(struct tda_state *state, u32 freq) OscFreq = (u64) freq * (u64) Div; OscFreq *= (u64) 16384; - do_div(OscFreq, (u64)16000000); + do_div(OscFreq, 16000000); MainDiv = OscFreq; state->m_Regs[MPD] = PostDiv & 0x77; @@ -352,7 +352,7 @@ static int CalcCalPLL(struct tda_state *state, u32 freq) OscFreq = (u64)freq * (u64)Div; /* CalDiv = u32( OscFreq * 16384 / 16000000 ); */ OscFreq *= (u64)16384; - do_div(OscFreq, (u64)16000000); + do_div(OscFreq, 16000000); CalDiv = OscFreq; state->m_Regs[CPD] = PostDiv; From patchwork Fri Apr 19 09:47: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: 13636057 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 191D6C4345F for ; Fri, 19 Apr 2024 09:50:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KM82oMkmWt4TWykQPh04VOE1ABrq8U5Ac4hZChkqxsQ=; b=MB373JPfY1ubDb wTzm7ZT/rP0D3zQBrcbcEbhul02RO7/f9OsnJsboJA/Cn+IAteHCzZlO71njGMvqksag1zoabyQQc KZ7hgATyrV7mmh+Qmbt35g38bKUgOLu8ODP6rTjsbylXUBkjs8iuEQzGFxn7k/Sl7UkS0o0vn6AcJ mojAIikMxkdNhd0nKF/IJdNv1wUV4pppf43E0UKXXN/Imre7ayAkLk3DHTb51eN4BRjeRAaF4NOyr n/ED7I4WSD5xy8b2uwJUQK4PNcnT8SW8chlBQDQioQ9Ff/v+rdvOJUY32g32JARS38yxus+FHgliW LhQ8rjXW6rFy9Oh04zKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxktH-000000059es-1saA; Fri, 19 Apr 2024 09:50:43 +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 1rxksC-000000058uY-3yRZ for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:42 +0000 Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-434925427c6so10410701cf.1 for ; Fri, 19 Apr 2024 02:49:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520170; x=1714124970; 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=PtHT2dnCrKtU2tz1OyJJw1d0hzBN/YL8p+52UQFaJZo=; b=QbubsKQ0dQ+5noqXTAxNFKR2sq+wOmJTvgqGm5VsF9dBBl9zbx/JAMYpddQJs0K4OW dBospUaOEvX+obVsUlv4RQTenjsed7gSccfGy1Nu8V+VSmzOcDH9SkJQlwfMZ4ruR1/S 42Bxkcxvls/wElR57Iox4ZtJJGdmImkdzAdrs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520170; x=1714124970; 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=PtHT2dnCrKtU2tz1OyJJw1d0hzBN/YL8p+52UQFaJZo=; b=O2ijtNtzT8LuGepcU2/h48ktIGhro+lRSK3r5+kJiJ1dwoDjdg5K6eSfda/F38VR74 323bsYVsAWJEHpdPaAOI8dI3NN80qL9ccIUMYO41uxZMynZ7m9zlP2ZqyUaaJvOklPoP nQaq0A5r8mh93s4hM68D+ko286IGspgJFhricdMq4WhHdnIBxjU8ZUOZ8YvDdM233jjE qFTatb3WnP1EINL8TXNzATqkUbzH17MSikgSuyHn595zJW8A7LqAaFOximMWsUQBkGEL ZQMnpFSstFiDALJWLO4igzeDwQpNLBiQOSGzaaccFmbv7Hlm94ErEgupqFaV8C8hajDT gHuA== X-Forwarded-Encrypted: i=1; AJvYcCUd2RZU+dSNu2nK4GK/o3ltyRJQOZj71Aw88xUU7lt/bQBv+MUEQMXZeZAIZfr8YPwPZORVjG5eZ8hme7KFRhwmwlkCjRQnjl8Y9eMfdEibScKyAJo= X-Gm-Message-State: AOJu0YwidhnqoDrf4WogcvLF9k6TE2230ykdMsGfunMR58hDcFp6zcBM xpuNvR9kEvUPpSbBuadJ/Hm4nb7Dc0Yiuza2a6/LoRbZvrQCuZ+ggLGsvcoJ+g== X-Google-Smtp-Source: AGHT+IEq5/HFwcn26nQnIIJ8VXOEY35h4vBPeSOiEtFFD1Z7vC7s7kPOFrGUrC/lVDARzsxRqq1juw== X-Received: by 2002:a05:622a:1386:b0:437:b995:98b5 with SMTP id o6-20020a05622a138600b00437b99598b5mr1747672qtk.57.1713520170255; Fri, 19 Apr 2024 02:49:30 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:29 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:55 +0000 Subject: [PATCH v2 09/26] media: v4l: async: refactor v4l2_async_create_ancillary_links MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-9-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_024937_155593_CCB5AEFC X-CRM114-Status: GOOD ( 13.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Return 0 without checking IS_ERR or PTR_ERR if CONFIG_MEDIA_CONTROLLER is not enabled. This makes cocci happier: drivers/media/v4l2-core/v4l2-async.c:331:23-30: ERROR: PTR_ERR applied after initialization to constant on line 319 Signed-off-by: Ricardo Ribalda Reviewed-by: Bryan O'Donoghue --- 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 4bb073587817..915a9f3ea93c 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 Fri Apr 19 09:47: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: 13636097 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 4F9FAC4345F for ; Fri, 19 Apr 2024 09:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3xvoe7SQrSYQ7PC5MIbVhV7yGXq9saXfO3UgIQgCivY=; b=P2gO83Ogxg/wLh mH/bWX0Q0g0nA4ILnHBsjm8yZsukOZ/J6EGwA0KezeKplnBy4palYrL7BELoPkUqtRTiZkvneFW+H zxRqLmpzeUvmY7dopi/YYSGUZjjbMGj2YWOxvQiKqN898sVI/tk0j/sMgp5gsOORI2J3KooOxlsd6 E6CGjMGz4LR+O0jKwjwhGFS4C065l8TgIxIB+H3Ee6rWKIVvPazhJZPR6lDiIIcdAFNWGkg9RQQzB IYBBDvhVQgAskNy/lPfsHVMxta0DFGMG8RRXRPyztXyGfXtFKb5vK2k35YxLLg6RFVHI8wCqThhct 5j33gY3BpLlgRwg0aTOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkur-00000005AcM-0QOI; Fri, 19 Apr 2024 09:52:21 +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 1rxksP-000000059CI-3lLi for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:50 +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=I5MK517M661jXeUTMXVPJlov9z4l8/dISyr2IlNuzMY=; b=DZDAz8U2vSviJDvksUncZOB00e Nm8xz5IEk3es6+WuFeX4QehW2suTjuwZpbyl007U3iyStTVERwbK27vuucP++I/Ybplmtf9D3Hq/+ +rBmjb0EUjti+PQnBwuOEmGdr2bdp178sz/cej614UbPOk20RpWiavl09nFE71+vaQRxgWccEzKbA H07dKR6nGlHv4pJ+ULvXQx+x/gGI+Ymf53zh4TQLpMYmT6olvFbM4nDmfQFfUPvqGniALHJCQ0Jcf /zNLvkKhMi1zY2IMR9VEZiuFzI5EQrSZyXxpSHYH6ygB935wK0idJc2EFyTYtrZFmcFVwRml3iEJM wSjDhq/Q==; Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksG-0000000COPG-2lv3 for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:46 +0000 Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-78efd533a00so105616285a.0 for ; Fri, 19 Apr 2024 02:49:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520171; x=1714124971; 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=ScfRIeWrx3GsnNewIWqYmwwb/e6wFe1c4+RE7tTAWlOa1zs2I4livsvgsOuZmEcv3C WJipY/y3G6wIEqkmj6ucDvR/r/N2kd0SG5Jpao3/opo9XqnRrqCclN6PxfcSVGj9sqf9 3qmcJGjKrXNqiWJBnr5e6ooupFFzMCK/yQbj4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520171; x=1714124971; 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=ggr5vql/emC05xkI0HcfxNmhQkKvr4Zrmcxva8DTUSQ3smCSKJJ2EMbgADE4R0IdTa n5P34H7rgUAY1awRFXMrFG/seeYMWX9zzOT9J1fx0p175DNG4anpYDS0qzP4nWTEMJ9y xuvHqa8w8XBYdpzbZJQ/ANRohJUwjEVhx4/qYwommj+6rsBhnWgQjybEIdDmNqRxd3a+ tJsIZYAAGdcHO4cFtFk5Ax/T5BgUw3pE3E4ciH0nxZR32VmX5/RIirQwr/3unGZRvysT fPJSYb4GB6NsYBS5Ob19qi95uLsmWPTgxP2QRWDxd0oQJVp3SE4mE1BvxcceHSD4EIGE mAiQ== X-Forwarded-Encrypted: i=1; AJvYcCUhJ4JYV1VPWoeK6czL5uiRb2fwu4YtNTiK5Cbd51DH/4t/p1Tpfhl2IqpTwLJb+GKigweJ1KgcIyOk4v9SwpHkbzZ7U22mwU+hhrHLNdGoHRMRpvw= X-Gm-Message-State: AOJu0Yytoc0DKIXAN84Gaa60HpTob1gBBktiz5HvwQIalP8+HfEAOatq FPdwQ/iz0TIvxICrHUd06rB8PaOhTnI2jOayBygOPq1xhq7AQnOsR8YawZBdBQ== X-Google-Smtp-Source: AGHT+IGTA8hVputhy9D1xoHe1Hnr3yG2C7dQHpLq8IKH//vLRvJ+A58aCJR9JO6Y/w8HTYrMtJHvqA== X-Received: by 2002:a05:620a:1da6:b0:78d:5065:c5df with SMTP id pj38-20020a05620a1da600b0078d5065c5dfmr1596268qkn.18.1713520171055; Fri, 19 Apr 2024 02:49:31 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:30 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:56 +0000 Subject: [PATCH v2 10/26] staging: media: tegra-video: Use swap macro MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-10-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104943_042637_8FE21BBD X-CRM114-Status: GOOD ( 12.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Makes the code simpler and cocci happier: drivers/staging/media/tegra-video/tegra20.c:324:44-45: WARNING opportunity for swap() Reviewed-by: Luca Ceresoli Signed-off-by: Ricardo Ribalda --- drivers/staging/media/tegra-video/tegra20.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/tegra-video/tegra20.c b/drivers/staging/media/tegra-video/tegra20.c index 630e2ff987a3..7b8f8f810b35 100644 --- a/drivers/staging/media/tegra-video/tegra20.c +++ b/drivers/staging/media/tegra-video/tegra20.c @@ -317,13 +317,8 @@ static void tegra20_channel_queue_setup(struct tegra_vi_channel *chan) chan->addr_offset_v = chan->addr_offset_u + stride * height / 4; /* For YVU420, we swap the locations of the U and V planes. */ - if (chan->format.pixelformat == V4L2_PIX_FMT_YVU420) { - unsigned long temp; - - temp = chan->addr_offset_u; - chan->addr_offset_u = chan->addr_offset_v; - chan->addr_offset_v = temp; - } + if (chan->format.pixelformat == V4L2_PIX_FMT_YVU420) + swap(chan->addr_offset_u, chan->addr_offset_v); chan->start_offset_u = chan->addr_offset_u; chan->start_offset_v = chan->addr_offset_v; From patchwork Fri Apr 19 09:47: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: 13636058 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 EF0BFC4345F for ; Fri, 19 Apr 2024 09:51:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RQ98EmPxe6piqh+9JvNRF9MAUCVzuZ3pQbXJ+CzmRLo=; b=0JGvUC7TJCDyAo Ouu/FeRFpKb7EPCqeQ4fGytuNWaJljVbHMfjsJGmfc/Q1hLaWbmx9h6k05ZYPk2nWBqzgqivj7578 IiVrJG6yRhpTDEXJhKIog/tzt33SaFBnUh/Oo/Wx6rRXKumXSGfjf5EOnZsTvhJDy5C5T3/djC72W umEfYFGoOqzmmVEyPpjS1StAOeGlK1+084kSvQ8w9nIcNhPv02+7Z4SYlIyM2vxtlw1s8Vj6ktale YcMHu2sht1IYdcPeY+Qx6CQKrbaegPVMu1nfvmK6jAoLRqcZk7LSJOHwUYFihJ5r/w5APgFieL8TY RJoFYmroxS+SXX4wWowA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxktR-000000059kQ-3VLS; Fri, 19 Apr 2024 09:50:53 +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 1rxksJ-0000000595u-3HfA for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:43 +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=M/K5Byxt1ig+CQr/X/PeYwmg4ty1EjIby+WFZ625f+g=; b=VRJLGZpfOQGuBZn4zFWCnxEVTw WSo5aeNADyp8qp15pjR0Sfj/QBeKXiYv+FSLx5AhFvin6mpKYVhazGFrthXQp367nZ26K6fszrWKw UnIuAfZA4y6NcTYL8qvXOkcFJ9KPAJeBwVGF0pcP/YlsVQrbU62L/uPmrBDX19poz7HG1YZYXszZx kEmlHGkq8OG0RLQFT7z6EBAMCdRPMh8TIoue5REInetFPlJ1Nt82k3/dZCrkTdddyYy/M7tWw71Ww qrbIoJTld4GzT0gohJJ3Aoqq1SJ2cBw3Tb9gAu5fYcR4bLPqCUdY9ZRX1QYolVvv+UbPQlLyWEofd 8QEc+YoA==; Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksD-00000007Nf1-3b5V for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:42 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-78edc3e7cd9so115830685a.1 for ; Fri, 19 Apr 2024 02:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520172; x=1714124972; 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=azZKoSQOEKkDD3CZW/9GEcnVPo6dcgjqo0J7+FVdQJUgHRBWH66u44GJZwmecI+QWj 4RQExj5zZmCCPOKZED3jWQC89nCLw7qYw3HPBkHHFVuD/xXaGzP3yghWVqm+ghlQ2mRG /YzEOYOk/i1YxfiAgu8ue1Rz1HaAZ//7pP17E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520172; x=1714124972; 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=lrEyuVrYDprZe5fVp4n3K0RHO0uEJtEcr1qYLYWGQHFFC/8k7+ebTkdaTAfBLKGLvG cxNO0XKD3/IZOgM5QaSp7NS4ScamJJI/lPWj9gIRLaM5+8KQCnzjCzRkjrMLX9nOODX+ jxlgf9MuhD0EFm+inxgmGkJNaarPGiZHjN28G6Nj0InL2dokJRIV636fVKBem7A0BRZG Oi0+DmYxUZP2BV00I/lbND4b5XxblSV6LZWC2FFVaCuy2uYK4xdRLHr3wCfwKYAUnVSl lH1ah/pheWiyaKrrH1DM0RzyfTVgnOufzlxZcY5rULNxVFWnRe1ZrIthowpWav3o2EVS ydHw== X-Forwarded-Encrypted: i=1; AJvYcCXKupYw5wcnptRAc1ZYsERrhRcmb8MAuPF4ZDRn1z8uCiBpwh4QnmGhRW09yHlBn1KRHvU1eGMLZMTTs8HqL5M2l8fm1I5uSUrV4OUHFWiq2kOyM1Q= X-Gm-Message-State: AOJu0Yx7T3NSibt4Pe1WCpf1Xj9wk4XIM07XKfmYUnDulMHH2RNYmHZd AceTqI8Cux6PXiYwYdEXemtW/OSsy4v0h8ePxnwOB/eY0ui+DQzh2O3DAkWIjw== X-Google-Smtp-Source: AGHT+IFgAxI3cudbjf7QENem+4os/v4599VNo77B9jF2HzcU/N2a5nFApf/3c3scTYsGro99atnYNQ== X-Received: by 2002:a05:620a:8da:b0:78a:68c3:dceb with SMTP id z26-20020a05620a08da00b0078a68c3dcebmr1504339qkz.32.1713520172428; Fri, 19 Apr 2024 02:49:32 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:32 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:57 +0000 Subject: [PATCH v2 11/26] media: s2255: Use refcount_t instead of atomic_t for num_channels MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-11-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104938_065649_4CD07568 X-CRM114-Status: GOOD ( 15.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use an API that resembles more the actual use of num_channels. Found by cocci: drivers/media/usb/s2255/s2255drv.c:2362:5-24: WARNING: atomic_dec_and_test variation before object free at line 2363. drivers/media/usb/s2255/s2255drv.c:1557:5-24: WARNING: atomic_dec_and_test variation before object free at line 1558. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/s2255/s2255drv.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c index 8e1de1e8bd12..a6e450181fd0 100644 --- a/drivers/media/usb/s2255/s2255drv.c +++ b/drivers/media/usb/s2255/s2255drv.c @@ -247,7 +247,7 @@ struct s2255_vc { struct s2255_dev { struct s2255_vc vc[MAX_CHANNELS]; struct v4l2_device v4l2_dev; - atomic_t num_channels; + refcount_t num_channels; int frames; struct mutex lock; /* channels[].vdev.lock */ struct mutex cmdlock; /* protects cmdbuf */ @@ -1550,11 +1550,11 @@ static void s2255_video_device_release(struct video_device *vdev) container_of(vdev, struct s2255_vc, vdev); dprintk(dev, 4, "%s, chnls: %d\n", __func__, - atomic_read(&dev->num_channels)); + refcount_read(&dev->num_channels)); v4l2_ctrl_handler_free(&vc->hdl); - if (atomic_dec_and_test(&dev->num_channels)) + if (refcount_dec_and_test(&dev->num_channels)) s2255_destroy(dev); return; } @@ -1659,7 +1659,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev) "failed to register video device!\n"); break; } - atomic_inc(&dev->num_channels); + refcount_inc(&dev->num_channels); v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n", video_device_node_name(&vc->vdev)); @@ -1667,11 +1667,11 @@ static int s2255_probe_v4l(struct s2255_dev *dev) pr_info("Sensoray 2255 V4L driver Revision: %s\n", S2255_VERSION); /* if no channels registered, return error and probe will fail*/ - if (atomic_read(&dev->num_channels) == 0) { + if (refcount_read(&dev->num_channels) == 0) { v4l2_device_unregister(&dev->v4l2_dev); return ret; } - if (atomic_read(&dev->num_channels) != MAX_CHANNELS) + if (refcount_read(&dev->num_channels) != MAX_CHANNELS) pr_warn("s2255: Not all channels available.\n"); return 0; } @@ -2221,7 +2221,7 @@ static int s2255_probe(struct usb_interface *interface, goto errorFWDATA1; } - atomic_set(&dev->num_channels, 0); + refcount_set(&dev->num_channels, 0); dev->pid = id->idProduct; dev->fw_data = kzalloc(sizeof(struct s2255_fw), GFP_KERNEL); if (!dev->fw_data) @@ -2341,12 +2341,12 @@ static void s2255_disconnect(struct usb_interface *interface) { struct s2255_dev *dev = to_s2255_dev(usb_get_intfdata(interface)); int i; - int channels = atomic_read(&dev->num_channels); + int channels = refcount_read(&dev->num_channels); mutex_lock(&dev->lock); v4l2_device_disconnect(&dev->v4l2_dev); mutex_unlock(&dev->lock); /*see comments in the uvc_driver.c usb disconnect function */ - atomic_inc(&dev->num_channels); + refcount_inc(&dev->num_channels); /* unregister each video device. */ for (i = 0; i < channels; i++) video_unregister_device(&dev->vc[i].vdev); @@ -2359,7 +2359,7 @@ static void s2255_disconnect(struct usb_interface *interface) dev->vc[i].vidstatus_ready = 1; wake_up(&dev->vc[i].wait_vidstatus); } - if (atomic_dec_and_test(&dev->num_channels)) + if (refcount_dec_and_test(&dev->num_channels)) s2255_destroy(dev); dev_info(&interface->dev, "%s\n", __func__); } From patchwork Fri Apr 19 09:47: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: 13636059 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 06D58C4345F for ; Fri, 19 Apr 2024 09:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PTpFBFMFb7+ua2Yho6Wgm7e2NMPhrXe8y78gH2oylZ0=; b=o5VREdZ7ZRJcPs Y08qfsho7/IQ9HE1DRTERB0DuXz/2B4mJanDNzSt5L5nG8A9t0Xny0tNiJeuqBO9lejns0SH3WN6r 5d3XFHPGadOTxMG0YhoKjamRZtpgi5YyqGuxcY0/Osukd9aL03OlVwFKR9pkLMUUs06XAC39XTUGN HbfselSR4vKOejWmC1izkfIkhx+pvzeQZKvwWPqi2Djf8fdXhegj7FHn/Qje33jQIcp+j9ZZefDxv n8ste1EMqeJMI05zkQMk3I1+UgWkLPK/XDFBh1q26OJE8kRA8T/G9p+6uQQ6EoLs3HofWYI4w0B5S rwf/+mvmm2n6HDoBqb/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxktc-000000059q9-2riS; Fri, 19 Apr 2024 09:51:04 +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 1rxksK-0000000596F-0uSs for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:44 +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=X5IbU7HBHK5ZSrS81fN3o3XopIPldfFFy8PdyHH7F6Q=; b=O0ZhCBTOkfH3+rv1X96KZRok8N ZvdXcdu/0i0/5Y1JnUduKKMldG/kjoXHcTLMEXkQ5c+0q6d34A45VExJQb4smfc2/UFXsGqJh4vuw uM5Bu56CbUjXjejX/X1J57RJ092cyqRZ3osIE2UbCJkze48rMzXymKOidZE6GzovDxDSGBHu4dHTd ei0kLGw7xWtXvW0Kz7qN59XZOtklDxvCDBXcMjps0/Wj9VjHWdQV9aTvbbvSmbWmCXosfj3rKS8/g Xsua3KXlPQLSawktou30CQbwvCNbXwECdYnOk4GnswkWOAjO/vPtUMziJQWxdoaN7st8xPzngVpdn sZxU74Gg==; Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksD-00000007Nf3-43Mi for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:42 +0000 Received: by mail-qk1-x735.google.com with SMTP id af79cd13be357-78f05aec21cso124229285a.0 for ; Fri, 19 Apr 2024 02:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520173; x=1714124973; 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=lRqeUHCJnHE4Lyq6qOoM64wSAUsEwJofqsFLR4jEA43x+3OQ8sJjQ43eUnhPUq98L/ F1QXShJ1Gpwi+/IqE0NFAK9QR96MzDzN5w9xfbrWjV0xGrp8lCRHlJ39zpMbkvPq/w7B vkh8Cx/+qJn0hvk3BIRGrUPXqua4HJXI6y+vk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520173; x=1714124973; 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=fxdSwNNTeWq22lqrfkStVvEdLooHHynBPQuq3SEspdtXBB0bao5uR65LDv5/0vkZ3p jaFSONi1ASqO74s7dJmHKUCtMdfWsxtvmEiBvcyZgUrhiAFxLOrmg3UlfholcSc7gMSq /+am7OD8MsghDRIqiTkZuJX+tTZvmPp1a8pJji8B7RcmvHan6u/YOO+QDWgJZiCJyrrY b9aYUyb43EwddroYHMaU+aWuSaDdoLR10SagezkpsCi6DU6K7nBf6kGUB1GtF796d5MQ DlbfCwaPcPCjhKT6GmKM0of+1QX6u99YxWr/9cIMLbUOsIE7PhVHURWH9PKR+VEPUThZ ohiw== X-Forwarded-Encrypted: i=1; AJvYcCWgwKv3KApIgF0uQYGYHOlmw1YPpoIuLcrY9TpHaheYCZXJlJbHw6u4Av5uZJMUvjFQxpW592jQ/wXhHOMmRDzKwN271gVZa9IdxCn47sicDa3wqcQ= X-Gm-Message-State: AOJu0Yy5U2IRHqwJ9XmNbL6/6kOzjWVJZE8F9FlVHtqupEKGuJf3laju 0vX+C8QndO6jv/3Kq7Au4BxN1qtChrPdPStu0UpAiubzwjF6SXYAm3ELMWnPFw== X-Google-Smtp-Source: AGHT+IEFPc2doe2D5XWkbZvTrB29BF0kfAeaqeMumnsEPsoEkeZEg2M8kAGfVkDU7KVIwRhvnXAZ7g== X-Received: by 2002:a05:620a:3b84:b0:78e:dcb8:b4be with SMTP id ye4-20020a05620a3b8400b0078edcb8b4bemr1649647qkn.6.1713520173590; Fri, 19 Apr 2024 02:49:33 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:32 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:58 +0000 Subject: [PATCH v2 12/26] media: platform: mtk-mdp3: Use refcount_t for job_count MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-12-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104938_163399_10A19BE2 X-CRM114-Status: GOOD ( 14.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use an API that resembles more the actual use of job_count. Found by cocci: drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c:527:5-24: WARNING: atomic_dec_and_test variation before object free at line 541. drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c:578:6-25: WARNING: atomic_dec_and_test variation before object free at line 581. Signed-off-by: Ricardo Ribalda --- drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 10 +++++----- drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c | 6 +++--- drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h | 2 +- drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c index 1d64bac34b90..ea2ea119dd2a 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c @@ -524,7 +524,7 @@ static void mdp_auto_release_work(struct work_struct *work) mdp_comp_clocks_off(&mdp->pdev->dev, cmd->comps, cmd->num_comps); - if (atomic_dec_and_test(&mdp->job_count)) { + if (refcount_dec_and_test(&mdp->job_count)) { if (cmd->mdp_ctx) mdp_m2m_job_finish(cmd->mdp_ctx); @@ -575,7 +575,7 @@ static void mdp_handle_cmdq_callback(struct mbox_client *cl, void *mssg) mdp_comp_clocks_off(&mdp->pdev->dev, cmd->comps, cmd->num_comps); - if (atomic_dec_and_test(&mdp->job_count)) + if (refcount_dec_and_test(&mdp->job_count)) wake_up(&mdp->callback_wq); mdp_cmdq_pkt_destroy(&cmd->pkt); @@ -724,9 +724,9 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) int i, ret; u8 pp_used = __get_pp_num(param->param->type); - atomic_set(&mdp->job_count, pp_used); + refcount_set(&mdp->job_count, pp_used); if (atomic_read(&mdp->suspended)) { - atomic_set(&mdp->job_count, 0); + refcount_set(&mdp->job_count, 0); return -ECANCELED; } @@ -764,7 +764,7 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) mdp_comp_clocks_off(&mdp->pdev->dev, cmd[i]->comps, cmd[i]->num_comps); err_cancel_job: - atomic_set(&mdp->job_count, 0); + refcount_set(&mdp->job_count, 0); return ret; } diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c index 5209f531ef8d..c1f3bf98120a 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c @@ -380,14 +380,14 @@ static int __maybe_unused mdp_suspend(struct device *dev) atomic_set(&mdp->suspended, 1); - if (atomic_read(&mdp->job_count)) { + if (refcount_read(&mdp->job_count)) { ret = wait_event_timeout(mdp->callback_wq, - !atomic_read(&mdp->job_count), + !refcount_read(&mdp->job_count), 2 * HZ); if (ret == 0) { dev_err(dev, "%s:flushed cmdq task incomplete, count=%d\n", - __func__, atomic_read(&mdp->job_count)); + __func__, refcount_read(&mdp->job_count)); return -EBUSY; } } diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h index 8c09e984fd01..430251f63754 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h @@ -134,7 +134,7 @@ struct mdp_dev { /* synchronization protect for m2m device operation */ struct mutex m2m_lock; atomic_t suspended; - atomic_t job_count; + refcount_t job_count; }; struct mdp_pipe_info { diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c index 35a8b059bde5..0e69128a3772 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c @@ -104,14 +104,14 @@ static void mdp_m2m_device_run(void *priv) task.cb_data = NULL; task.mdp_ctx = ctx; - if (atomic_read(&ctx->mdp_dev->job_count)) { + if (refcount_read(&ctx->mdp_dev->job_count)) { ret = wait_event_timeout(ctx->mdp_dev->callback_wq, - !atomic_read(&ctx->mdp_dev->job_count), + !refcount_read(&ctx->mdp_dev->job_count), 2 * HZ); if (ret == 0) { dev_err(&ctx->mdp_dev->pdev->dev, "%d jobs not yet done\n", - atomic_read(&ctx->mdp_dev->job_count)); + refcount_read(&ctx->mdp_dev->job_count)); goto worker_end; } } From patchwork Fri Apr 19 09:47:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13636105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 486B1C04FFE for ; Fri, 19 Apr 2024 09:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4VXJ/I4UqIFJQ+L/GAN8Yr2YsCdr0ClGHjaqRT6+yeU=; b=fjTx8/kH/MTJWC dFFnw5ldMLczZRXK6uQ7jGrCgHyFQRgENLcEpUSbmzXpRqiVgSxezEY5ncLRKS82AKay6YUmLZ/QW r6yZ/Vx6OsigLmSDtNSdPB8lR2+lb2DDoUxPZdXxTjIWK+5aoN6O+IrzYMUMFo/MhFyYYXv39QE75 O0DXWPlGe4CeK+aM2S1BHa57q0QeaGfKv3xGPvg/++McUOWqj3ZJeBeDCyA3Q91ncv/GCbN3MG23Y vH0GD+YMtyL7KWkJQsOgfBVpWB94u5Q9GgD3lZHXrRdAKr19/Iv5jMba/Ud2I+vh2hJLK9KGojiPI W05qo9XsvLu05Pt8sLyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkw2-00000005BMK-3PaL; Fri, 19 Apr 2024 09:53:34 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksH-0000000593v-32iA for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Cc:To:In-Reply-To:References:Message-Id :Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender :Reply-To:Content-ID:Content-Description; bh=0jv41cPIK92ur4lysOBbsHOVURXwH8FRVBK0KQUkRX8=; b=jl8srcobhefH6jIdtQuaGpZ9Yy WmTgBDN0Gy9mcw7u639J53Gy2awIOSRha4+FsSbNrY+Yl67UvqAURKbt1gnm9GYCllQKHEAWQcK6F GNGXJq945K2RI17Hs04eKq43WcUPGzmokifbD9q7UOui23J7ox1+TptGMUnJBTkvp5WzJBMzi3ShQ gHrD4KRlUgA6+JkR/yDY/o0g+UXJTvFRzRFchcV8zoivJOUrZrYYXRaW9dF+dP5cHY1EYtZmrIrBe Gu+TwpvDBmWLiEvSL4eAFN5HD7L90lIo81XAZDGWDClMT5c2CCNIcE9k0TxX5i5UUknMoZBxzGdA8 4pGZbv0A==; Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksD-00000007Nf2-3joF for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:40 +0000 Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-78f05afc8d6so120960685a.3 for ; Fri, 19 Apr 2024 02:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520174; x=1714124974; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0jv41cPIK92ur4lysOBbsHOVURXwH8FRVBK0KQUkRX8=; b=MLb31SWBp4JDBt/WljrDKfo3cxGfLFvCz/Pk4vEqBaKn4np3qKhvQ8G/wSXrqiAnL7 jF5Qh85ywla7lpp9McxU66YLQ1VW+ou8X4Q08v67zGT/3S7b6SO5AHG20TGbWXZOOjq2 rcvGiJveg5v+GsRMGK/d1APhcOhIhZLeA1zQE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520174; x=1714124974; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0jv41cPIK92ur4lysOBbsHOVURXwH8FRVBK0KQUkRX8=; b=usNiq6Zod5IcuNgrOx6pm7wfipWpkX13yWT173NRWbBW7rMAh3SGMAYv3sXJRgQXaz XwJe/zPZ86wtx3iMGDWHqHYSf/NZwIXQ1qp4mof3sZKlU2z5t3FBPqKaq2C1sISU83Sz 8RyjAKgQrqhBjQ9hQ/AwUjDomNZ53EsVgapkCm7A79TN67oVq1K9U56am3s8NCuw+p9v 9CxWM5wc5fLi1GAz7Mh/mVLb8PiK618gIst1RmHbWdAs3nOeDtjECZYqZqBpfZyH6+WA zhgJXg2DtLJe3kQa5Y3XPOjTTNxblI5YrOxSmZhFYfXOc9ZPEMueV2o4V2/oLjW1psj/ O6PA== X-Forwarded-Encrypted: i=1; AJvYcCWRTm4vZnB0y94CAfoatVmnxPEk5oaW+w5oddF1t7ze3p0PdSw3CrWdqdDT9ESc9beXCX5zEHpHJmyCcQJlIRhGDHf3lh6WcbMyEtnlEut7oShpsls= X-Gm-Message-State: AOJu0YwhIee3X/5jV7Pgq9hWQqezdwCao1XEtQ4ZAW+r4L823WLof/p2 RDB+VW1vsmk55dmK5l/i1GLKSxWMHrEzzs3wwc7ON+LB/s+btDParaez6sOd5w== X-Google-Smtp-Source: AGHT+IETv5IUoGgWksFs9Z+Dm4pcXtdl0bT854ihOygqGrbXzgeian082aGVpKk3VnS1RI+F74x9Bg== X-Received: by 2002:a05:620a:4694:b0:78e:d2ff:a108 with SMTP id bq20-20020a05620a469400b0078ed2ffa108mr2287614qkb.0.1713520174478; Fri, 19 Apr 2024 02:49:34 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:34 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:47:59 +0000 Subject: [PATCH v2 13/26] media: common: saa7146: Use min macro MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-13-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104938_066421_37811B2F X-CRM114-Status: GOOD ( 12.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Simplifies the code. Found by cocci: drivers/media/common/saa7146/saa7146_hlp.c:125:36-37: WARNING opportunity for min() drivers/media/common/saa7146/saa7146_hlp.c:154:41-42: WARNING opportunity for min() drivers/media/common/saa7146/saa7146_hlp.c:286:35-36: WARNING opportunity for min() drivers/media/common/saa7146/saa7146_hlp.c:289:35-36: WARNING opportunity for min() Signed-off-by: Ricardo Ribalda --- drivers/media/common/saa7146/saa7146_hlp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_hlp.c b/drivers/media/common/saa7146/saa7146_hlp.c index 7569d8cdd4d8..fe3348af543e 100644 --- a/drivers/media/common/saa7146/saa7146_hlp.c +++ b/drivers/media/common/saa7146/saa7146_hlp.c @@ -122,7 +122,7 @@ static int calculate_h_scale_registers(struct saa7146_dev *dev, xacm = 0; /* set horizontal filter parameters (CXY = CXUV) */ - cxy = hps_h_coeff_tab[( (xpsc - 1) < 63 ? (xpsc - 1) : 63 )].hps_coeff; + cxy = hps_h_coeff_tab[min(xpsc - 1, 63)].hps_coeff; cxuv = cxy; /* calculate and set horizontal fine scale (xsci) */ @@ -151,7 +151,7 @@ static int calculate_h_scale_registers(struct saa7146_dev *dev, xacm = 0; /* get best match in the table of attenuations for horizontal scaling */ - h_atten = hps_h_coeff_tab[( (xpsc - 1) < 63 ? (xpsc - 1) : 63 )].weight_sum; + h_atten = hps_h_coeff_tab[min(xpsc - 1, 63)].weight_sum; for (i = 0; h_attenuation[i] != 0; i++) { if (h_attenuation[i] >= h_atten) @@ -283,10 +283,10 @@ static int calculate_v_scale_registers(struct saa7146_dev *dev, enum v4l2_field } /* get filter coefficients for cya, cyb from table hps_v_coeff_tab */ - cya_cyb = hps_v_coeff_tab[ (yacl < 63 ? yacl : 63 ) ].hps_coeff; + cya_cyb = hps_v_coeff_tab[min(yacl, 63)].hps_coeff; /* get best match in the table of attenuations for vertical scaling */ - v_atten = hps_v_coeff_tab[ (yacl < 63 ? yacl : 63 ) ].weight_sum; + v_atten = hps_v_coeff_tab[min(yacl, 63)].weight_sum; for (i = 0; v_attenuation[i] != 0; i++) { if (v_attenuation[i] >= v_atten) From patchwork Fri Apr 19 09:48: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: 13636104 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 45B5BC4345F for ; Fri, 19 Apr 2024 09:53:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TcV+/bOCNQ3YKqSCP7FnHRo7wTgBzsfzCZysCCqaVEk=; b=U348AP1Lx4R3je PXNSBdTUHhN7G7o7s27nL4sjnmprvyXhveFwZobcy69RvPz7QCyajUnohpMug++ld75U84IeoaScm PaDye+OtxmZfm9DviKR24iacGKAFcUklPig+581BIfAoimcwmcyl4eKRLWW85ZvOgnIumHe3bAWzx kYencpq9qVQCv/XwdcWvwwhnD6m2dllqg4XH1oAya1lGNaMrbjYiz4993gEWC8NhSCET8mc+7VZ7P MvOtZ++URvvF/kUdVzzFSiXsEKro1xwz+tCfD5zXsdRstJBd3iuogoFDADbPXVTN6ym5FTIl4y99a KW7waS41fgQJTUcppevQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkw4-00000005BNQ-226T; Fri, 19 Apr 2024 09:53:36 +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 1rxksC-000000058yP-3jLQ for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:42 +0000 Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-78f049ddd7dso121324585a.1 for ; Fri, 19 Apr 2024 02:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520176; x=1714124976; 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=o87/x+VFy7QdGpzFKB0wOlVC4lrWjoCcMvbEo+2HMvU=; b=e/8Z1mutqE3uIAMWCgdn9L3nvZ+mFWqYul5xiJvBtNNDl3MPOcU4/+YIva1QUi/T2u 0YzqNnX73/e3J3hsh/NbZvO1I1Ajh3Q1w/VRLb+PiS9B4lzgUeqgNOpKfKUk4T47WFTP GkeW2+8qlw5ghym+0BC9VNAY4MnizrX6P6+Ow= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520176; x=1714124976; 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=o87/x+VFy7QdGpzFKB0wOlVC4lrWjoCcMvbEo+2HMvU=; b=Bt5S3Jc2PLfy9mwXv+0I5+ro3uhJJhQhuhdCd5CJ2K6a716enk9Aql1ZHH34j3zEec 24FrdXzWBmWsdv149eUo9PgscUVjw1SWLUZnwYyJTZC32GRQe4NnMQxQfgO889ATPAmL nPcetYodB7K7fnT4ZX31xsDXpvhpeifEktcHUbHWjUyFkzNWTtt/gtPJ/ovBsZKY1iRq Mdapv4Zlqs7UfidtykZE80T9KbbHBl62p42xF+oF5/rj/uNdVXJ8yScbi1q2Myt3BL7W 3Zh5pOkepDeSY+O4fhVtlxJefLaGc75NA+EEC7z81qhXB1wPrew77HGCOurraMoHLgOU vPKg== X-Forwarded-Encrypted: i=1; AJvYcCUfiKkyeIhQMcAaUaLd00+6MiRrzQ6sUXSByJ8jd4qi/E2uhFe0PqNszczzEhuWJ/PNSFy/CUEpdFT+X6GbgQCyfJaOQKc6aixVBipziY9o9BdgxVU= X-Gm-Message-State: AOJu0YxlOhoDReVr8CsZ35qwD5g0yPR7Xy8+ArHZKtc8rvFLs6CpACmV N+ILS+k5E0AEyIZ+IQpPTTd1k02IAi9avjLbYKprtPJNxvrr2m4Pf2uc3v757Q== X-Google-Smtp-Source: AGHT+IF61myZQzLIJtZThv3LhAjLCPCU5PGkGLiYz8SZp337r7gQKsKEDGbkUPSHG1pPHq3o/FKykg== X-Received: by 2002:a05:620a:47c2:b0:78d:6ef5:f10d with SMTP id du2-20020a05620a47c200b0078d6ef5f10dmr1532638qkb.65.1713520175867; Fri, 19 Apr 2024 02:49:35 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:35 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:00 +0000 Subject: [PATCH v2 14/26] media: dvb-frontends: drx39xyj: Use min macro MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-14-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_024937_083937_2AE76A44 X-CRM114-Status: GOOD ( 12.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Simplifies the code. Found by cocci: drivers/media/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() 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 Fri Apr 19 09:48: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: 13636062 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 13DDAC4345F for ; Fri, 19 Apr 2024 09:51:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RdnUnn1DqeDKn9S0llfgkh7xlSlzwoStITrFN5mfIsM=; b=DBDllToi2u+RnZ VtxtJHVEU0xmc7VlNIRnrgyt4qKZXMSGfhWu3LegT5XhRc0SC31Ml1OT5U1K3BZjl5h7162sTRVPW rXnALd51H7ZakzBXsdALz5OfbIdLQ8lkYw9SCI1zNZxUxkhxl6FRafbAX7Vkpj6BcoQ7WH80dqWSc fnb/nNRybHmJZO30IkAjk8ZEGajAA85HyJpukEP1ALGEwTlKGALtAHXhH4fAhBUTGl3KtlXuRoMME Fah5vGipX2wzU8O9Vn7C+qzkPGraMLfnBolxQWtMAHtSKMRJ0+1PQqwCbzS4ItpNzKEygdH+YT3Gl 4fNmNnUH/kGGeD8NVsKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxktw-00000005A4c-2yUL; Fri, 19 Apr 2024 09:51:24 +0000 Received: from mail-qk1-f182.google.com ([209.85.222.182]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksF-0000000590H-1wnK for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:47 +0000 Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-78f04581a66so114768485a.2 for ; Fri, 19 Apr 2024 02:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520177; x=1714124977; 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=AeLQb+7yroz1N85IaLBmgCrfbdpcP3/Kr6zRrTzmvckfHbqn0C1akBhveY2xRW8Eu4 bkG8sdLpAkU3nsJVUm8+DgPEASzHeDFPD/hAdivBNdcE9lRG0nDfprPfHzGTQx2FWJxM OpErqOFz61QcMdnjV75WKnwp8jWGDvF7oX4NE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520177; x=1714124977; 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=ka+Kvyehn6+gVE2J4lzCuouApo9zp4uAV+kjd/WZWbDTAInCITJCzt19PuNwnaV+vi 7BmStE67fbxG43XVjkCjXWPi5HpTimgGXM0/100/8Geo5dXLPhd8Xgyx0Vy+oUKVnpir SKsSap03KAsk/NLT7H8/Ub1Q4f76/mJpcjGs6A6mEKUJ6gOTJVQJSXhyTOQE+zxWJian XE1qJ8jnNGJ4Rgbi3kf0TzpiasGvp39aHzvjuEk3z/Mfnm7LeryK2I72+WVO1oaUn2Y3 EhaECg0Y0DrHdkbEGuMaPPyS11yYBVJYG6Sqt/ZcLwrTsepObede1XHIiUhN1nmWIQ5q TStQ== X-Forwarded-Encrypted: i=1; AJvYcCWIN8fBHw7VDfKtOWuqZcgEzX/64OKEV12m+NP+vjspVZtq+wWXVKvk8V9ZlXd/EQB3XUlfkQ8HesRCTdx38/W16DhyAqp9QcItuGO8sdBPY4KVbS4= X-Gm-Message-State: AOJu0YyGCxtCxLT8Gk9V8zizAfU6pAzKi2Pk+YwIHEGqEre7hN+Otmed yW3Im3rtd8jdrZ1v12cahf0TiQrgYkO4Jm83rggBD7Q8S1s7W1QN+qkUVp9QHA== X-Google-Smtp-Source: AGHT+IHtaefRUDCkJpXsh07H2yA2NeK9gO3xvd3htQb2Rtwe8WSp0MnWmceFe0R4rsJzjkJBUbtDcw== X-Received: by 2002:a05:620a:111a:b0:78b:e8b0:f156 with SMTP id o26-20020a05620a111a00b0078be8b0f156mr1546954qkk.67.1713520176717; Fri, 19 Apr 2024 02:49:36 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:36 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:01 +0000 Subject: [PATCH v2 15/26] media: netup_unidvb: Use min macro MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-15-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_024939_885489_97AA377D X-CRM114-Status: GOOD ( 12.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Simplify the code. Found by cocci: drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c:138:26-27: WARNING opportunity for min() Signed-off-by: Ricardo Ribalda --- drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c b/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c index 46676f2c89c7..1c885d620b75 100644 --- a/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c +++ b/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c @@ -135,7 +135,7 @@ static void netup_i2c_fifo_tx(struct netup_i2c *i2c) (readw(&i2c->regs->tx_fifo.stat_ctrl) & 0x3f); u32 msg_length = i2c->msg->len - i2c->xmit_size; - msg_length = (msg_length < fifo_space ? msg_length : fifo_space); + msg_length = min(msg_length, fifo_space); while (msg_length--) { data = i2c->msg->buf[i2c->xmit_size++]; writeb(data, &i2c->regs->tx_fifo.data8); From patchwork Fri Apr 19 09:48: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: 13636060 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 E07F4C4345F for ; Fri, 19 Apr 2024 09:51:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=abb11M8114OIWGtfTSUNZy/TSVJSWZvpLeA6HDz9Bic=; b=GTsUtCIW6GIRBl naBLOFopKQiR8axL8VT7mtzlcktXtEy1mfRL7cudoRZmdrGJwIBQA8UORtE5VnrjyGlOjA/lr3Jvg kMIwskCRbOeomDcFFyXTmpHIozmCl8Ejn20/x4DLYbKp/FSy/WoWzurq9HogfiLX9xEvkd8OsUFJ2 fs+wj9rfR+ePl5UeOKGEd3rVSedwirz5izifcvTPLx6I3L471NoLI0/4E6/0ZSEujh7ffEoBfITMm jr+ccv+qHRBXzLdyd6u8UOpZXVvJpEQQXk0Cxg63GVGh9Z0ULemMd6kSiJTG2WfWwn5AFTcQH2l3F I+B07BHUuatGnTgl5XCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxktf-000000059sB-2r5T; Fri, 19 Apr 2024 09:51:07 +0000 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksF-0000000591C-12NS for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:45 +0000 Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-78f02298dc6so151338185a.1 for ; Fri, 19 Apr 2024 02:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520178; x=1714124978; 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=cwjfvOc5t2/Rv8qFUttYxYGvFXodHL/LaHscuwkq7i+GErkNpmRuwsKxJYFlkyKaeA 19uiywWsU0w3Wh+RLGG7PLxL11teL5DQEKqx/ilVfkwSOcauWBgLAkykKXGo5i0LOdou bnfCTV/ZM8EA3JoyguDgIkCZPvfGF2Snbpi3s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520178; x=1714124978; 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=XZIUN3aOvR/L+IvWJy+elh6rFfLGjKL61I/WkE2KKswt+YuzT+isv0JtpfPpgTKFWc f3d+GJxwokzoSAnCueqr7U2CHkw4pWx5R17s1PUQXSWl/QWg5Q8ok2uNT9ik11iJhOjV e4aPH88uJinAztwjHzfxakawXmLVaC3VJgmDE08rd2fEoVDr6fWLjl/Wu2xTr/rvYZe+ Vit3x2xli7++bftaEP/Hvbd0dS5CXnm0QMRARUNKgurXOJ1IczKVgPHpVMHpXJjv6MIh c96gD0FYV2F38R/Ilr5wmq3BXDmtPJEEdhPUm/evjnrZChHi8SxXJ1uuCBzC8fggH+Cb xdrQ== X-Forwarded-Encrypted: i=1; AJvYcCX0AMyK0j6ewj6H6g08zCLmrwOHr9x0sawmppr0F6XA7yeGjvMbB9bEZtZ1KR5mQxnkjZR1Wvc0a4EcF1P+P4pTlmJUzt7QRSQBCxHCyyhejmeAoVw= X-Gm-Message-State: AOJu0YxeTjDwGj8+vn73wf9yG5frabWdDYETDNJiwTGAs50OwsxdjGK/ gGIBe8ccHoVpsJbtCRAtgr5Ct6Y9BbN1TCOoG8Qx/oX2j0i4W8BjYeh/xiSdTA== X-Google-Smtp-Source: AGHT+IECi6Jyi4V4xEUSov8CqJCQ4or6T8Il7gtYs1qBNIhEZ0wlq/VmHa5Y/Lm3RCi/7xPm+Pq8wA== X-Received: by 2002:a05:620a:45a7:b0:78d:5d86:ee3a with SMTP id bp39-20020a05620a45a700b0078d5d86ee3amr2694110qkb.27.1713520178140; Fri, 19 Apr 2024 02:49:38 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:37 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:02 +0000 Subject: [PATCH v2 16/26] media: au0828: Use min macro MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-16-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_024939_609714_232650DF X-CRM114-Status: GOOD ( 11.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Simplifies the code. Found by cocci: drivers/media/usb/au0828/au0828-video.c:605:11-12: WARNING opportunity for min() Signed-off-by: Ricardo Ribalda --- drivers/media/usb/au0828/au0828-video.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index fd9fc43d47e0..2ec49ea479d5 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -602,10 +602,7 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb) vbi_field_size = dev->vbi_width * dev->vbi_height * 2; if (dev->vbi_read < vbi_field_size) { remain = vbi_field_size - dev->vbi_read; - if (len < remain) - lencopy = len; - else - lencopy = remain; + lencopy = umin(len, remain); if (vbi_buf != NULL) au0828_copy_vbi(dev, vbi_dma_q, vbi_buf, p, From patchwork Fri Apr 19 09:48: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: 13636061 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 2E4A2C04FF6 for ; Fri, 19 Apr 2024 09:51: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=al61i6Fdz7CGdbkvRRWp58kiudLspOEssFHVMYauiTw=; b=1gnoi+3X5RPV33 YsGs1KR0qWTLEH9HhUpgSD0yx89B4BXs2VZusD0BCtIpihv02djHr/mBN4m4IOuUOuzQGubOtVWcZ qudJXUtkMysP2tVqQ2WrPRuO8JuKDOmPbjReX6Ofp/6Bt2QEDvsmxhlCwUGgb9/ilFXWcjtSzEULf CgQpVeCjpsHp0Yttyr1+feY7mAVD/2ETbf1JjM3BQJ8iyKWyxNUq1BIGcVPZB6wzMSPDR9ijzo+0x PDrPj7l3xZpAIwSMzfRleoeAdxwzuQ+Fq5W+6KIIqsvCgzc2NvbHqQDd0S5S5TtwgnInlFOW9Gzsp bI92+AliMnhDfEgOWUaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkte-000000059rJ-39nL; Fri, 19 Apr 2024 09:51:06 +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 1rxksK-0000000596Y-2C8W for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:44 +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=ejR4SFor1DGbZO07N+L+RxXvAXTkN+sOOOYtcWWVXb0=; b=UKgB46AU5QKTbvT6wHKEbS4Zkv HkK5A2jtrRY9rgQfa9+3iZ5VDzUFcIovi9+wR/KxjtQtI0/Ny7UEzitayuvTMzg7fDMPLLnRw86kr a/k/+7zgsA9s52UlqWpYw8M+3NvyWssuhpS6bwRDnV13674gVydS/kg987YAVniA4MQ3haykvTF10 nPqWHTRB1OqlQr6uVEJnRl2+oyRVvWdXhTvBn4CNpicw5IqI29MowLTsotDxCTmEBUHdatjdAO9bB WQrNrnlG/bOUGMT0AQUzBEsvClVaKyImewz2rKmEBIw4L4JimrEI0iuurfpD7wEvhAsj0mn1SDE80 BBBfDdMw==; Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksH-00000007Ngd-04hs for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:43 +0000 Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-78f043eaee9so106774585a.3 for ; Fri, 19 Apr 2024 02:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520179; x=1714124979; 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=ejR4SFor1DGbZO07N+L+RxXvAXTkN+sOOOYtcWWVXb0=; b=ggPO9ZX7KrSid0vexvetqKBolc5bHVG2VRSu3o7yhmS1CQRaxrKYLMYPNnuUjcW30a 3Yj7aFB4Ek162Av6XHwXTIHfRgp9HmutYqxT5YKvRgZZ+0gZDyXwWtc4daFv0p6v1VC9 zkXUQTi7g579wXne9XnzSFI+A1/xrinJ1ESqw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520179; x=1714124979; 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=ejR4SFor1DGbZO07N+L+RxXvAXTkN+sOOOYtcWWVXb0=; b=xGFbLujGBjS54Yjj6g+46QmwHt7y/qZGBGtON8c7r+NxO6pgmSXAz2gcQ3iROpg/nI 2w/oGTnrqoC1mJvlv1Vxxzpq76bVWqtiDaHh5ywrD2P0fgHR2wmUKQYlMJtfD8h90kNF kbuDjrLRWtWJ9qvQ3hrOTR0X9AYWPGDCcqMP5LLRhK206p1YLYHcsgFPFyWpOjfTbpSk l28YCVZRU+VBmSH+YfXTC0QkG2d0PahZj6r7sKfiKMwNM63GNt/hn9g+/oZAqTT7nWud fNbDCCY7nJueNtfMdPbFi3lZse4F0qay2Mkj1em8mNEYqoItSw81aAqYx6G0juwTvryp iu5Q== X-Forwarded-Encrypted: i=1; AJvYcCUikThP7SqB18NnYntUcefoykAkUbAwBosABhqslTsFm0y2gAY+zue0Dkk14XdjiEu8BZerCda4VBnosWd2xImIkeqS/UDKEJomgiDe3Y2VhTCszsU= X-Gm-Message-State: AOJu0Yw+RY7kn4P5qTJdFpdgdjEOmLAFQJ+kvQHldmzxlIvecaNqvDXc 7Xb5IwWM62pz6DKVC6VxpOfx4MttQ1O4vcukztrF83RDLSwvChpruCOi5hUpKQ== X-Google-Smtp-Source: AGHT+IGpZ3ldVVwdiWjuIy5SwcAIMUaAxjtBaGve9bP2/gGFY6jCFymehsQebGC3Yx4JbEu/ovs54w== X-Received: by 2002:a05:620a:d94:b0:78e:fe1b:a601 with SMTP id q20-20020a05620a0d9400b0078efe1ba601mr2205140qkl.0.1713520179012; Fri, 19 Apr 2024 02:49:39 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:38 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:03 +0000 Subject: [PATCH v2 17/26] media: flexcop-usb: Use min macro MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-17-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104941_473520_8188451F X-CRM114-Status: GOOD ( 10.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Simplifies the code. Found by cocci: drivers/media/usb/b2c2/flexcop-usb.c:201:8-9: WARNING opportunity for min() Signed-off-by: Ricardo Ribalda --- drivers/media/usb/b2c2/flexcop-usb.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c index 790787f0eba8..3ba6a5ed7167 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 Fri Apr 19 09:48: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: 13636108 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 EC40AC04FFE for ; Fri, 19 Apr 2024 09:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lqPDx9h5k8MiuXqaJRc5EVMlYoESh7nyUE3PFYjgubY=; b=3nhzndqSoPayHZ v1qUknWDeLIHpKbQG3zX1ESu2m5aNdULCMmtCL4SexwmY7g42OQvk2wUUrU0D5x7GP3diPvaQ3/v9 4/5Id61w7zXcVgqM8O1ckEakKEgyhCSOogUJ4dAIb/nJf1izenMELEKBULAcdohOCOUPZ4RyKdzSU nSMeylvm+bcAaPdB/Pj5qibQmQCCxRgGfmLbz97bN3HchGeUHiNjrIaffvF8KyjotU/yeiJuCGJ2F +4luouJv3U/qeu//Kv6JKcQHE1J9/0E2fl4wr2JrsXskkqvqJLT2APxE49cY95PQ9KPqSODOoYed/ Yuz6TaGj+OfUasFQRlDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkw6-00000005BOR-0dZU; Fri, 19 Apr 2024 09:53:38 +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 1rxksM-0000000599b-3tBK for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:46 +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=kyue/FRqn/p1WnqrFE53P+Zy+G2t8IVLierFxkwHoc8=; b=RqulXt1aPNJ7T25KxANTHNHEf4 y6KysEA+ZxkJA5RsPQMaukL3r1AaOYzSofhJ09Gpil/r4nOqTnvo6VGB+qNn8baOlkYcQjAJiLhQN fZiuYGfL8KnlTZdouIVSPa3tIDgbMtYoosDN6AsVIB+fWMAm/4ZrDyIKT+0EjDDnpp0kFp50/pPRb 0SxFibO9jz+Gv7/wOsu/ATfOO2SdoiiEQT/IchmLBxG7VqdIrHySqG7J/8t02zeXL2VE+Bd+xPVdB GvvbJRJhl2Ha2jwJ9XpIDfwYpNz69vWwKSwIFXtEn34WI8WtGWg2a0deTBFAzWBseore9aAgZrGxV /8ntqmGQ==; Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksJ-00000007NhI-1gGQ for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:45 +0000 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3c732d9383aso589688b6e.0 for ; Fri, 19 Apr 2024 02:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520180; x=1714124980; 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=O1DM6r9JUUb72i8DojfVGiMxlJVex7h8qadGgMyZ1EwxcmPXy1yoYKANzZpdFKYvuf iqXurFj337FOjvRus28ayJFZIVu8xDURgA/HCsINfqE+vIBl4oH4OXMATY5ad6laIIGM xSIjQh2KBvvHe2d/F1Rc3IBHzt6LGbPNMiGHM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520180; x=1714124980; 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=wkEC6VXrephsbTsVZcYFyBaRxB9jTSBwi3CtzQwNJ06ZkafdIPOFJ3QpZ8qpcr4QHW /2g2GgIxOBWCDikExyH/J9CpGi4WhMP4wd79uqJCJj57t2peB3N0x1jO47I9wc92m7gQ yPBi2h41Qhxn9+2rm0qowPaWGZcQYz42tKWSITOFQLyYnrQz5BIwyMjh4mtEtMzVWJ0G LeJZ9SvwnnxUgluuVCXSBn08KGb9Ls5FGMCDQoKLfr94PLhZKrTUcl2btthr1smti+gP /GJ87d19OmmJXH4O5udCSGCbCGsJuQbpJruFC2fNvs9wWKIiLKtm2ymC6ct2oZsDySi9 qV8g== X-Forwarded-Encrypted: i=1; AJvYcCXIaUb4uUyaICDCL8Gz5gzYPCnUVsvM57cbj2hJhMCO0vMtLCyW4FczMsAbdvFzjpBpFW8iHyOEZlpCA1uZncRuWIYEzUweKMHVcytc8zJ2sGv8aw0= X-Gm-Message-State: AOJu0Yz+d05xpaTQbm/oOEPyhd0wHSc0V3MNsE7UIjBqisCflRnTYnLH 87Ch2pzpmpWXZfkZGi87aWLe3QVCTLG/rb/Z4qQ9Kuq/xeMuR+td9DpuO0UTVA== X-Google-Smtp-Source: AGHT+IF05pxTJqI8q4Gija+5b/6oIu70NmHvysRWeLZw4zGGPxVTDlI+xOCyxI7lSqjlpj1TWOe/3w== X-Received: by 2002:a05:6808:60c:b0:3c6:f6c9:6bb6 with SMTP id y12-20020a056808060c00b003c6f6c96bb6mr1556563oih.41.1713520180310; Fri, 19 Apr 2024 02:49:40 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:39 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:04 +0000 Subject: [PATCH v2 18/26] media: gspca: cpia1: Use min macro MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-18-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104943_488250_3569E2F4 X-CRM114-Status: GOOD ( 10.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Fri Apr 19 09:48: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: 13636107 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 2C5F7C04FF6 for ; Fri, 19 Apr 2024 09:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AA8de8eymBhLi5WVHvDVQevOR0tmE+VXsnz9f0p2ogc=; b=yRdHbP+RBtYmqF KYJjIgSjacXZNpx9xTEj5//fbL+w0KZkzwizqQyO1H/sVPl6bshBPjibhOpI8UWfcP+Dh6QSQ5Guv 6pTOQ1AgWpg3xx8BMS76nzRB77QjdWoccjJs9n5u44CgywQWPgdZaLBE/yIYBUO0k/J9cjhxcbd0a fKXpsDB7RDydkSfg86LSxshuCcU8tDMhzNiCSzFRwsr32Ug1i06y70sIlWkoZssNrkB+lL9r34gsR DPEvl/1ee6QHjVaPaRTnm+3Hb9LxN79AqZOVJzW2/U7knETJpvI8XXRGngWgz6GX7pwC/5YQm+SqE K6eGkNLbH0avD+Cm3UEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkw9-00000005BQt-24Y8; Fri, 19 Apr 2024 09:53:41 +0000 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksJ-00000005950-2ryu for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:52 +0000 Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3c745103fb8so297324b6e.3 for ; Fri, 19 Apr 2024 02:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520181; x=1714124981; 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=hYOJzUnpv9q2D47VjlP9TkFSb49icqGz0TC7JGSn6z0=; b=oNVml3L57tHzFiiK6Nq1VCyJRtCaxfPCeuTTMCeYDkvCHAWUC7X8z+Gj7U55bXrXls arimyZwzWXTkMq/0hPGuE0ndRC94glPWfMz87z917ArRGb4dHGQL+sTSnvaTsvGayZlt m/3VNgdNQzwNO+75HFCigUZNGpRr7lQa0MjSE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520181; x=1714124981; 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=hYOJzUnpv9q2D47VjlP9TkFSb49icqGz0TC7JGSn6z0=; b=nUQcTPC6HFBWbqLaUl2L7SJo59+kcdrUdUXpJEiAqjuKHbhdyom8PNXtuwrh7KyRJR 9XgHQC6Aek0zcbRozkZg5+EsYRlUotxGHs8+u8dSkET7jr3R8qOlWdWvUIO9/tR+/GaF o/XzmOyGw+RE9F2YKU32SNUvPrBu9H5mRarvv4pynpuzKJKvrIfLKFVL/A3sNM+6+vbS mRXKwRmWfqxjzbB/MIvkhGDjbCvghk08NonMkbitoBlaWU85y2OPC0t4PUHg8Jl4m4ou LKl/pXqA4s6tgT0D+oLHUUgWhF4bSlm98kt8HGqHfWddXPvxpLhbEqhVFJPxTSTRZ03R pFhg== X-Forwarded-Encrypted: i=1; AJvYcCVNx542PQ3TxuCm229dMhwy+5NJY2D7XjrJNPFWCTjHeGkJjtZ/39FUST6QFLSoorcirLMqiWXE5hdUnxnq0MWP514tCl3ateEsMSsqe9H4pJ+xwGM= X-Gm-Message-State: AOJu0YwyXe+hyCVEfvRTymVnPF8cG55rtgnpq7Ap08cmHTEFXBEgSLW+ VOjNnLacaKTqlNwIcIYgMv7mzXS66WOXKgtO9QfVO0k/M7j4wDpIofpImcNDLw== X-Google-Smtp-Source: AGHT+IEqg8WI1huh374uXjkgiCfNW5dvf3VCHAQb3EvwSLWOaLDMHldgLr7J0rc8UDIeS/oMY5gCXQ== X-Received: by 2002:a05:6808:2029:b0:3c7:2eff:7dec with SMTP id q41-20020a056808202900b003c72eff7decmr2132218oiw.2.1713520181341; Fri, 19 Apr 2024 02:49:41 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:40 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:05 +0000 Subject: [PATCH v2 19/26] media: stk1160: Use min macro MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-19-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_024944_547988_0655F0B6 X-CRM114-Status: GOOD ( 14.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Simplifies the code. Found by cocci: drivers/media/usb/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() 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 366f0e4a5dc0..0ba0f41fe3f4 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. @@ -173,10 +170,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 Fri Apr 19 09:48:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13636100 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 05CC1C4345F for ; Fri, 19 Apr 2024 09:52:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=G6Q1POLVy87He2CPgSEeLkbvJVlk2je2iObmBrYLylk=; b=mmV+Y1QGOGE28g nnOSjXfbZp4bKjh5QTwa6A2KL0TwGkKoIg3dXsoZEHXHpwmHXVHiy31IB5Sp2FamhoooFL+iQxpq4 hkXnmUgwcz3O+TMnyf5bw/26iKXcF7onDnoOVhyQEqpVN4QoOrOpDqnCFxsmQo2CneBdZRGBghLt5 1nVeD7SnUdU54DKU3YwEag01BJjM4N0lH++BKIo0lOfAv1tLmTdD9QujSByzsCtVClsfznyMH5tX6 2xBft+trrqcFJ/haiXCPmeAqpDJNSKrBjJNVd8v0sHOvHt49IXhufqo4IEDInD+nT+T9kY8KjA01C siqlVCZz5YrurC8ljlcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkv3-00000005Al0-10Km; Fri, 19 Apr 2024 09:52:33 +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 1rxksJ-0000000595r-2pya for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:51 +0000 Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-78f02298dc6so151341185a.1 for ; Fri, 19 Apr 2024 02:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520182; x=1714124982; 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=QKkjF/3ZrmyMjLI6PZxoR71eYFuXqsl1p6Fuz8KRX9DkFrcMN2d6dwujihI52umbvI lUhB4xQAyDW/dE76sa+lWCYRyjthZD88GDfvdsWZ0aW/9++SSDWiKe2oVNLBkjaRDRaX x7m+9nv8oPgF+4j9uy/gzICZcD2E0fIFj3ZKA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520182; x=1714124982; 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=sYkmGJeDYnWEUiy/Nm8HLVMkuHoJX/vvhzXRhJFuHenb8UH9EvTHzUqUZvmQl6fc5X 1DVcpYsxj6YoDZi6hQLrKBa8zkRxWfIBK6JGkY2zgqJjUtREeRN71kj7VA5iWz9hiO72 PQnGUrc+63AtjBSvGhvgB03Idd1wGIYjopdtsDr7CAHGS99sVqQoqQuQjgk72USTKK3b BXnzXi3SlJiMq9wj00tg1YmmCQJ4hMosTMuTC6YP1Jbl2nF0uE0+Lkt73CVy9Wjf5Rkf LDu2L7Zy8NnWs+WCn2GS7EcbF0CcApedLa4+nhkstfIOiVGocdCP+e62V/q1oGGfplis cX6w== X-Forwarded-Encrypted: i=1; AJvYcCX7OMoiV3HlH0BzJpAMGgFJLdJ0OXBCO+NRsxFXoc22+dcmVfeCaL2xV7YCc0K0gGWOepi72VBLe6DdV1Yy1wpJy6fe3fizSXOYjDiYKc5sJ3g/HvY= X-Gm-Message-State: AOJu0YwYh7s5VyY9gpWYKERTTIslqg23p9bw6VoZnWLhu0yoe+71tmUY nM+iB9tnLibTen/24eRvfsHWHP8Uelim2Ggv1MA/kdZqmYecWYGoqzlJTnh7OA== X-Google-Smtp-Source: AGHT+IEXhcUKUor0dxuV3thvzJo2y+QPxtJebfEt+tWOQcWOyhTJf9Fve6oWEuZlRhBFIInhoP8+Wg== X-Received: by 2002:a05:620a:956:b0:78e:bd2f:1088 with SMTP id w22-20020a05620a095600b0078ebd2f1088mr2994401qkw.4.1713520182200; Fri, 19 Apr 2024 02:49:42 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:41 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:06 +0000 Subject: [PATCH v2 20/26] media: tegra-vde: Refactor timeout handling MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-20-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_024944_281254_2E5B8E5C X-CRM114-Status: GOOD ( 14.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Reorder the branches a bit, so cocci stops complaining about the code. drivers/media/platform/nvidia/tegra-vde/h264.c:645:20-21: WARNING opportunity for min() Signed-off-by: Ricardo Ribalda --- drivers/media/platform/nvidia/tegra-vde/h264.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/nvidia/tegra-vde/h264.c b/drivers/media/platform/nvidia/tegra-vde/h264.c index 204e474d57f7..cfea5572a1b8 100644 --- a/drivers/media/platform/nvidia/tegra-vde/h264.c +++ b/drivers/media/platform/nvidia/tegra-vde/h264.c @@ -633,7 +633,9 @@ static int tegra_vde_decode_end(struct tegra_vde *vde) timeout = wait_for_completion_interruptible_timeout( &vde->decode_completion, msecs_to_jiffies(1000)); - if (timeout == 0) { + if (timeout < 0) { + ret = timeout; + } else if (timeout == 0) { bsev_ptr = tegra_vde_readl(vde, vde->bsev, 0x10); macroblocks_nb = tegra_vde_readl(vde, vde->sxe, 0xC8) & 0x1FFF; read_bytes = bsev_ptr ? bsev_ptr - vde->bitstream_data_addr : 0; @@ -642,8 +644,6 @@ static int tegra_vde_decode_end(struct tegra_vde *vde) read_bytes, macroblocks_nb); ret = -EIO; - } else if (timeout < 0) { - ret = timeout; } else { ret = 0; } From patchwork Fri Apr 19 09:48:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13636101 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 66DD2C4345F for ; Fri, 19 Apr 2024 09:53:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=isn+jpdZQNj1KWuFgML2IDkHyK49L6/UNaRtrbvBjhQ=; b=DrpYf2GkQiqg3N dzLVdbGnHHQljuNr/IlSpNnZL0wV76VusbO1mzoYI8nzf3BVx/l+LPr8DUngKEx2rR8Yz3ebS/Tn5 6jB4/RbUwCUEUjRFKsup73bbewfejVDeGg8tSpbt9favYLUhm7HrAbX6yIqv7Pt3xV8t9gFq+azx6 h9duJFUF37JcNk+ymqb/Gxj9j2avO1oLdiM7H31342jTD+CHmvJK2upvic7xR/sn61nktA7gc3wqr RWdomX1gISivbtJ3pX9XOhR2SdiFgnvVYl4p9nRTghLEUOlxGqYNUtbagRGdihlmhzbN0+ya7j7Xs rQKy+UPdX2+iZjCQbcdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkvI-00000005AvJ-3aKS; Fri, 19 Apr 2024 09:52:48 +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 1rxksS-000000059FD-1H9o for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:52 +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=mekpuuLwriZD6IkthqRlN7odC9zWZqgKPV8UcJZ7R9M=; b=b421Ft/YuyMytGAkKnWe+G4wPf /fgyT4kgPVAZapEc8pJv4n/Elu8CchSMfgIJVaWcgsRRQW34W4dzc/GDrYSm6P6DWZXJ37zNjYrIR RmrQETSzaMGNtkpzH5zJCjITh4EYCDuo6+OajbEUT4KwIRue7dojmxSjo+siW4Kt2BUr8Ng3eJRnT OM+nYTqgPHELWkAkhXl4bS9r71kKzY8ijQUPvHewf4OaA9Jvivh+lkZICrM86JXlygd6EY59U/Fx2 vACZDjHHPWqMZ8BEJfVNq9cTzfyOWsImOzEGGkAGLYsmAOv622W3yoNRZfGiPp3odnoK+1JIA+4yW EurIa4NA==; Received: from mail-ot1-f48.google.com ([209.85.210.48]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksM-0000000COSD-1qJS for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:50 +0000 Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-6ea2f95ec67so906792a34.2 for ; Fri, 19 Apr 2024 02:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520184; x=1714124984; 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=mekpuuLwriZD6IkthqRlN7odC9zWZqgKPV8UcJZ7R9M=; b=TdlJUqVdsxsctOWn7kZrmFKVhePSJK8VGYsXuNscLx4dd3PNNblcNQLUZqnGi5+p6Y ob1PmG/NCSwyZ6xzCZUbKpMt8IQAmBrPwcrZhoFnUpSvGnynvBngZ6/MHLsL+Ha9U/cs 4ETSBN1nUDOe3IwIroc7AIWQEbqDmaZ58xjwA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520184; x=1714124984; 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=mekpuuLwriZD6IkthqRlN7odC9zWZqgKPV8UcJZ7R9M=; b=BuAcGxH11TsIePnZTSIAhjPs3kwRlIBRmQdUSA83qt5OPQ/vrSrPn/41Na+NJsKFJO /+Fpr0DYk3PTFL05TFXltCsufPBNWbbHOsG9s0ztTlMwjBFK5Q4B/HOAHz67hApxbJ/w EwIUkqO4gztScSRW0k3Au+TozdZneic1gqmbH83V35ogcvJTD6SVdnpCGw4+QibMETqV 3t00zOhrRSob2slWaYU8hfpcp4skiXnjAaXiEOc5MaINbhE+/kZXWeUVoR1k/6Mu51KV tB/N7mfsClx2KxaMfF9qYBIN7BCPJlCypaERzWj7u4nm5VZ0dGjAdlL8i/vamWIANHFm I0+A== X-Forwarded-Encrypted: i=1; AJvYcCXrwpq4rwsi52Y/PmHKdUu1pJWiC3W7OI+E+AVSOk1U6nHV36sTl5K3a8h3cH0+trj5+5uuJAkVsSF0Eo9V7aL6qJSOuMj3RG3tb2w1JjPsMr/K26E= X-Gm-Message-State: AOJu0YwPv9QzOWMESFmTB+jFBV1ENhz1m/AoR9DMdnKY0x29W2eHR6+8 KeyOjvjk53FxKs9TnyvRiVKWSAw3JGLdf20+ZmKUoVlcElu8r9Quw1Qq0tpWAw== X-Google-Smtp-Source: AGHT+IEYwOxlb1WugYE4t9h28+AXEwcDjQAa28XJBDFMEfi87sd7BKKPg6Joa8eH6oaaPvD2ajlMkw== X-Received: by 2002:a9d:7f03:0:b0:6ea:1dc5:514c with SMTP id j3-20020a9d7f03000000b006ea1dc5514cmr1695945otq.11.1713520183703; Fri, 19 Apr 2024 02:49: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 dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:42 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:07 +0000 Subject: [PATCH v2 21/26] media: i2c: st-mipid02: Use the correct div function MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-21-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104947_636393_98E80C2C X-CRM114-Status: GOOD ( 12.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org link_freq does not fit in 32 bits. Found by cocci: drivers/media/i2c/st-mipid02.c:329:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_s64 instead. Reviewed-by: Benjamin Mugnier Signed-off-by: Ricardo Ribalda Reviewed-by: Sakari Ailus --- 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..93a40bfda1af 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_s64(ui_4, link_freq); bridge->r.clk_lane_reg1 |= ui_4 << 2; return 0; From patchwork Fri Apr 19 09:48:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13636103 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 421E8C4345F for ; Fri, 19 Apr 2024 09:53:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mhFjwTcMOAQ/YpUwuhT1CprISPtVr4aFJBjGD3DIGQo=; b=NnBFdkTWxqR/+8 efZOFHUEfWUwrewFziyfR8vx00wHzacRr9Zuw6EmqPKm/ooaUukmSAcayroWVBy9nSrtLJkHUC6/j /SA/Kx/noj74eN37vFmoMPzhwWbLPKp5hX5DQPkmwYZPhE8P/eunfEMjqUbZkYw921v8ECHzzJE+N R/mRDlRqty0tuz/wSftkUrD5K6F9vZ/W3voCFdy2i6zkud01lMEede23X/9KWr4ogdjFuHcMIwN2q PTvIqGlHrQPp4jhmf+DXFxK2T5lwAPWdoOVjj/nI0ctAiCpfPOiNWpd4UkYVpUjcYuxDq2NDEgpy1 qh54HOml9Ij7zhfJ5SVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkvg-00000005B8x-2eAU; Fri, 19 Apr 2024 09:53:12 +0000 Received: from mail-qk1-f173.google.com ([209.85.222.173]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksM-0000000599C-0ivi for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:54 +0000 Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-78f0e3b650cso84744085a.3 for ; Fri, 19 Apr 2024 02:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520185; x=1714124985; 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=BUe7SwGzZ7wMpCg6yglCc/aD97ISFXBqArZlQmN5vvEMMjnUJEKyLQvTTGB3t6WC9C O36gUOyFo1E1vwb9Tln7aiYt5F2PQbCmgjx+AjKzmQfESxDNILrky1gH7c09FB46EcoR 0o5erMo10B0tRsCT4a1Q8dP1AWTy3z+WdaVW8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520185; x=1714124985; 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=bDCK5UdXxgVnM+ncHKlv7OK0VNWcjZj6Vip09Ba26WCYj5RnAToPAxIJbbYJ7y8emj 0ZrtwbV4ET+pIUZuN8YLBpxTdUwC7TN0X7w54+g4iEdZ1O7barb97LqsADMNO2UKh2LW D9chdW5glQdFUaujOOyAXr7HU7A/6aA9zkPWYBv3TyhOZGiHMOi2lRV8nKwjKqj1nrFB a6+aL7ckq58wOSx4d2BkDk5WtL3bHTrrr19v6tOKnVs0BAofq9PkUCMNq7+C0RVZ/8UX 7Ibozz6BlRc4mBrxzN35ww65jVZjGpZzqrAsylfMku3OLTD1NKrAnvFh2KfD2fliOkgp yWMQ== X-Forwarded-Encrypted: i=1; AJvYcCVSxjVx5rc8CNVhbkOimFRP7FFCBfHj5j0cNtVQheVBHWuV3/57/7ugHGY+1CB+ncADqVDmSZIAvlxEYSIYmqMcPVheeZPeSqOqvNa3ruCqJdIDygY= X-Gm-Message-State: AOJu0Yy26AGYmp0GuDMyWvn0UYMUKDafY60qnTRPB6V6/gX+X+0eDOq2 z0w36XY3VJ5e4T0IcyiEbopCmKaPiqrR+j+NvC5Y34Behe1FZUV1UOhzCkUuqQ== X-Google-Smtp-Source: AGHT+IHphQGghhdnaPa8294fBxI47z+y4xb3Msllejvsy/cEZHbt70Y742XZJgUuOJUmQOPF+5kWGQ== X-Received: by 2002:a05:620a:1673:b0:78a:33f9:908c with SMTP id d19-20020a05620a167300b0078a33f9908cmr1816540qko.36.1713520184948; Fri, 19 Apr 2024 02:49: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 dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:44 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:08 +0000 Subject: [PATCH v2 22/26] media: tc358746: Use the correct div_ function MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-22-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_024946_456736_55E22492 X-CRM114-Status: GOOD ( 12.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org fin does not fit in 32 bits in some arches. Found by cocci: drivers/media/i2c/tc358746.c:847:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead. Signed-off-by: Ricardo Ribalda --- drivers/media/i2c/tc358746.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c index d676adc4401b..edf79107adc5 100644 --- a/drivers/media/i2c/tc358746.c +++ b/drivers/media/i2c/tc358746.c @@ -844,8 +844,7 @@ static unsigned long tc358746_find_pll_settings(struct tc358746 *tc358746, continue; tmp = fout * postdiv; - do_div(tmp, fin); - mul = tmp; + mul = div64_ul(tmp, fin); if (mul > 511) continue; From patchwork Fri Apr 19 09:48:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13636099 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 33BBEC04FFE for ; Fri, 19 Apr 2024 09:52:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=epxPii6pYsCuproZKyPpIqHJQ/Rji/no4jXcsFMoFi8=; b=hKuHxxzFg5w0ar f6r92Nozn7IxYjCdjjnppa7Go4W3btQ2ECOAjeeRWsCHAYSnWfppQgoW5RLrZDrMCADjG8oVPLh2y fl6iOXUrLxfutzxqEk6DMBIrMyDKmjNn7KmIBCH3QTLb8Mk90/xBr/rv4eAbL9i310umA8TtcudWy e7jJIMUdIsdwylmeSC0quYDUstqzQNzZEFoMf8ypxvQBesNg0Xy9axJ/nL0qL1Nt0nEgVnxzKgjX5 TlGLjgJ+B4Fjva0c4Yefe4W/aVlqvyW6u4YkTaN+M6pUrDxLp8CxlMLerBoquh3/kFP07JQ5XBlDl arHSFAvvjshDbyJXuOWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkv2-00000005AkG-0XQg; Fri, 19 Apr 2024 09:52:32 +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 1rxksR-000000059EN-12ii for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:51 +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=G+OLGyPz2NtLOZH/YOdUHJtasX7vVXp+smN0A8Fakk8=; b=snTHB105Jv7zrzbwqF+jyelGtr PafQtey54BmmBMqFMMRxUmgq0ixmyvXtuTm0xklSKDEDwcGrJxFH1PtS5vB9dqiV6x1jRZxj6uFvJ 9SBq/WOqt792AGbw/2MQMereFx7K1M1H9AMkmsBqIrDxDFvnLZTQdR4i6XwturF0IYQeOHoJBDLph CCgxH6pcNjymLm/VuYQSpnhunhtvn3f01J0vemshqnL52L0Jo1KjTriHWVt8ZSyFi2oU5TVF9HZ33 vUPcLSD1F/JSVxSRAjZ0724pDkJM72y5uRUfLvKhXeIqocdZMvAoEPtJBmuC532qX/rqlihytR5AO Fcec5Ltw==; Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksO-00000007NiU-0UGQ for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:50 +0000 Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-78ef59a369bso123602285a.2 for ; Fri, 19 Apr 2024 02:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520186; x=1714124986; 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=G+OLGyPz2NtLOZH/YOdUHJtasX7vVXp+smN0A8Fakk8=; b=Rke3O+G5FbTzDOFTu7HWY/vgiHtp/cy9sIj6/MEbtkGHNx9tVIAykreAy8GJqQK/21 Pw5dZ0hlpQQvWijgpBc2SBJvWiXyYk/C2Qn+XPvE9keIjDccppVvNSTog3L3gseZYqI3 Iek7qNiFvTLWrKZcBcMlOVjiL56WEKOoVyeUo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520186; x=1714124986; 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=G+OLGyPz2NtLOZH/YOdUHJtasX7vVXp+smN0A8Fakk8=; b=qbhJ4jerUOLrqpjb+yfAHXU6DwNs9E638lqGgd+e6whwCB3s7prfWoOLVhG1sJ5doY Yd3T7aWwaI6XBmco91oZLlRL+KVT8U50alxMfhCgLwLRR4U/aFz6fl6d4Tk9ZkuAOepW 8s11uhvos45Hbz8nDy2rwBOqg2CBro5bV1Xezb8+GNtq/JKAK6oUDDWhYynSzr2jJABu 71okEyqL+rFtPFmmBXLS4veCYoF/dPue+RZzKeMsM6T+LWTy7YXBS+W4l39oSJSTXIVm nscOhH/Lszbdb5vlbRhzXNWaupEo7qpFZe58jNn/a9ayX6bQTXNPIgCx8WK/YMbZ5ixm bScw== X-Forwarded-Encrypted: i=1; AJvYcCWNetGEwL4Q50NRiBA+IAjcVrwoYcDgOL0kT676ZLGEre34Ws8b8Sy5hoGLqSI4CF6VgTTit6fMTX2FZ/V1cLz/T/OYILU7N9/CBTyqmkheWQ9jsL8= X-Gm-Message-State: AOJu0Yxzdv6VH+jehQKhDZvGp5pUGaj1rs3s/mg0Y8m57k7/s83I8Uth YqAOLuwanC6jKnNqFp3HUsEbLWbTld9OQrbhPI1tw8W/VlnLYc5qMzzIaRk2LQ== X-Google-Smtp-Source: AGHT+IGmrMUnhFDPACSHoV4O9y/blrNx/1c6IZqAeqIu8A58TfBv2t0AZdePdmIMfSq3rhn78LSShA== X-Received: by 2002:a05:620a:8116:b0:78d:7036:fbda with SMTP id os22-20020a05620a811600b0078d7036fbdamr1727540qkn.75.1713520185768; Fri, 19 Apr 2024 02:49: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 dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:45 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:09 +0000 Subject: [PATCH v2 23/26] media: venus: vdec: Make explicit the range of us_per_frame MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-23-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104948_243895_C5DF0AA8 X-CRM114-Status: GOOD ( 11.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Unless the fps is smaller than 0.000232829 fps, this fits in a 32 bit number. Make that explicit. Found by cocci: drivers/media/platform/qcom/venus/vdec.c:488:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Signed-off-by: Ricardo Ribalda Reviewed-by: Bryan O'Donoghue --- 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 Fri Apr 19 09:48:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13636106 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 89014C4345F for ; Fri, 19 Apr 2024 09:53: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EcmtmlWUk5ECEBEBVkiYA+FxALAlsGW//kSh/Y4GRq8=; b=NP9SiPSe9F8Ud7 HD+4w4YjyrZqhrHNGsdw7AZ7IHGQ1ZA1B/AWanyn9ALGI/kL7RLX//0yAEjQRnXJlgyi81tIt5Gdt b5wZ/bMvhLEYjAzd6LPXeUoBDhy0BL5S68UEa1aiDtdOFwpqKA3QHWlCB4Nv3/eunHpXfEjSeoNMR LYuiU2GYrrvftB/rpzHp94JxZMlxAXSoaLIqE94jZupiAcsZmLUhjmdqm6hRzQu+QUfhylrtfHVcL 8xCIl/+c00pJV+x594TtN3kztPhxuFT7osyPditr26ghOLYVMhvPsQipORyQApc34oxBQMoTDp6hO Ng39FRJhsX+8Ii2OGHAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkw8-00000005BPd-0Wu2; Fri, 19 Apr 2024 09:53:40 +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 1rxksY-000000059Ki-0Ada for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:58 +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=lvwwtJ325ZfoqM3HPbRlOXyIZjp4qomL5UkM84Use0I=; b=GiHDBUm/gSl50IRBvmySyiwcRo hacakxHgk5Omr/wKv8hGuRUtVyfF7a9hwzFPr1/Um5e5zMoqN6/93P8o1eHM+4p7fpSH6PqrS8hE3 JKKEFx+2Qpsu9E4DrDGPeYmcik3fxzkNPrmvDLEu9I/MHS1LgmcBI4VChaBe4b0diHr5UZm47MnCt /wb3HAcjkeQHbmiLLuxQnqcq5x8wh6g+Ef6c0xE8avmTSHhxJyqoOn6mJ6tcmG1QINeZ+zMBvKsMk 58K8Y2ec3SuO9ciK1Va9T/nZRUqIHSi2sSalLZk0O/cC/GfphGX9z5kqyyXkHphVqPG6Xzwyuv99E hoP3FW+Q==; Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksS-0000000COTC-1U41 for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:56 +0000 Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-78f0593f45dso121297285a.2 for ; Fri, 19 Apr 2024 02:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520186; x=1714124986; 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=lvwwtJ325ZfoqM3HPbRlOXyIZjp4qomL5UkM84Use0I=; b=mcC9omfcFrSUs5rKWG1qTBfksUCA2zQLuWJ3lXbE2TwZsENk6kk98u4I+vHQQV/Q9b vg4QXjsrqOUNAhOfVOvb48BagfnH02TkPGa9RK9GfDle+xO7QjMKPe8962SoDSQlBEn9 4qJOQPdtOk5I2XQZxt9vpnN+NrW9smgBvz/2Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520186; x=1714124986; 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=lvwwtJ325ZfoqM3HPbRlOXyIZjp4qomL5UkM84Use0I=; b=c0ycVfvMv7o1XRMYANVugsLZkAukKX/2PmMcOPRc152Hfq+i4tUbFN6lvZQeYO2lT7 R2wHmkror8cZXzjgHYEaRxaU0cuOgimpAf3IAHy/ez38UvtbrgG170mqiyixyNRpyPQQ B3TWbsXvAvOOjtYPqQ/ajHq3piOev2aGPKKV3tnwiTl/tKXtObx9opScClEgV4hCDmXN vdRTJnjbkbe+e+mHmhqY2Gue1pL1bfILT6GuGMgiewFU8NuQoOo9KGGPe35n+94WGliE 8pUy5b8a1q7x5bEK3yzRJqrsrK5acggA6SFw52AGtvEOV3khTsWJIoc1Kav/cmSEOUtH zS1g== X-Forwarded-Encrypted: i=1; AJvYcCXbs0u0BgjGm/aPvOhi8xDYMAQX7YdhcpOpcIn2saQOxW1wBWeVO9RNJfguRFJWWqWG5SZrVhADGI8o0dcWPVznn/uWROm8QOOtgLQLKjbBxPy5qL0= X-Gm-Message-State: AOJu0YxXex1oip9t0ptqUVb24kTyDeF28gFyUA2QdOBTAfeE4H11EsWq OwDeQnxeXc/HfVKmLS54dm0Lu80Btc64LGdZ6Lbs/+yliAC1QHOMYJp11YNWow== X-Google-Smtp-Source: AGHT+IGW/Q/7qXEnuhzqs7M7AiVQTUVEbbMcTlOeO8lJn5AB3n8uUiRJEECQ6N2ghfLB4OyUBOtkcQ== X-Received: by 2002:a05:620a:1238:b0:78f:1622:5a96 with SMTP id v24-20020a05620a123800b0078f16225a96mr1817957qkj.39.1713520186635; Fri, 19 Apr 2024 02:49:46 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:46 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:10 +0000 Subject: [PATCH v2 24/26] media: venus: venc: Make explicit the range of us_per_frame MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-24-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104953_360169_7653DC16 X-CRM114-Status: GOOD ( 13.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Unless the fps is smaller than 0.000232829 fps, this fits in a 32 bit number. Make that explicit. Found with cocci: drivers/media/platform/qcom/venus/venc.c:418:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Signed-off-by: Ricardo Ribalda Reviewed-by: Bryan O'Donoghue --- 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 Fri Apr 19 09:48:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13636102 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 5CBB9C4345F for ; Fri, 19 Apr 2024 09:53: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IcGMDNEQDU9R3leVQWEAb8sk2hAlmfSZJWYPF5l3WJQ=; b=0gITz2oIEOymZx 86UsXBcKw4zfTOFNGFQ6R+ur1/O3DTO3VD27SXULaLyZT/uJV+JXYaRoW731Y1oRaTzqB5JfzCJkm 1U60clw3aXiDGamXq2vihTh/7lLTuKmKvQQRPwCPP4ehyn9e+khVWgkPIs9LkxFvxjyUpO7jc6cKh B5w1+SpWEETC+tNy5b6aoDJm5ZVH2riyxCHMGpdprnPRBS8VO9lWyg1u/0bNn0QhKhN1NpvnRaa7O 8/cbH16raIpIxv/rSPkTX1OCkqOuhR9/sR6ogRjBAUdXnjluA/S2i9I5ZrooKh/FUeS8Sr7DSlUkY Nex0lWQmhs9Vfd+lEawQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkvf-00000005B8L-2c84; Fri, 19 Apr 2024 09:53:11 +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 1rxksU-000000059H8-3Hkj for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:54 +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=vmuUSFnHzqjHSVO6x2xCi4IdU77yIJvh23Ivq0XCHvQ=; b=Jr4piowM4YJJ9M9e8n6UaRMj/4 6KWP2AdJ5LVEF+fIdtPRzyF8B3viwVrkSkZf37g74ZceQxlzUc+QWVZr+8KUWD4PTqByyu0IubqlR 1oNSOA6pSav4DnIJj5RF53IQKfewINlmSLYlQqAbJAYQCaVdJ+VNWOc1ZuLgaoZiLCKwiPcv3dkc2 nomVsbH26bO3udEXuoNAVg6WxZLgXHgyDrI/43KqyAZsT8fJfJPokbsCShOk00mkAQzOrH/bw7hRr Oq07abH3Xbbn0mId1sM/7mgUX197PEHFV+XeOmUmAm1wvMdsIxY0cpn2uCiTvWmXTjdjb/dFnBBxZ KnYvfbIg==; Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksQ-0000000COU1-17ou for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:53 +0000 Received: by mail-qk1-x735.google.com with SMTP id af79cd13be357-78f05aec21cso124242485a.0 for ; Fri, 19 Apr 2024 02:49:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520188; x=1714124988; 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=XJrEwUu97o34kOkXfzNciiwc2iABoLWazViav10YUhBHcd2hYF8EBRDo/uQl36WetG 0Z3Sf9Pq9hYcU2N1tMRkDle+5dci2b8fmXL94UbU7FjLmbd0/CbpSNyGqHwpWzPGzedI eDbljVWqh9BccX2oSMziuwdSIcZ3eBjeqBCUo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520188; x=1714124988; 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=ZLoFi2VEJr0+awlpjbl2nsmZbLKCnKS719gPfYTTPi1E1Rc/iAfzbmwArAHjEiDm26 jCXrWevTua24/mK4GR5DSUwPcGgzCJ5fRTTqJ9kuBukCBcrsnq51EgHtjzcQC/liOleX yc6CAFkfb312AneqXRRMQthibRzQBHE03gY+8nuJZ2DBoDC6pFU1mXpyx5FIXbnd8oEi q+ooJBAL2a6coRdhhTO1j3oThKZjoTlUwagcnQ9kD06L15UxOLmwU+SypvpnvBKMf9Rg S9B47NdObCNoVlNoq/+dwZsIncrVpWC30T9j55/5LxxyedWBeR/Tx3SSF1K7+mcGjtf3 EQ+g== X-Forwarded-Encrypted: i=1; AJvYcCWwgszgci456Hp3Ee6jSLmdcXjXC4w+Q5v/LBGpEP+M/bvshwUzR2o0y2yOE56GAiwJ9/IryTd3+TA6kovGg5zDnc4E0TisT9zheu7nP4hNe4U2P1I= X-Gm-Message-State: AOJu0YzFbdUUQ2WqBeK6gw+UkJMSbj4znUcF+4qSvCNNuGGAz71xmD7E yH/koK7/M3xyAm8CKUECW/C9SI4e86/Dua7MuJ2zryEvc0zNnnIcqYPf94eGaw== X-Google-Smtp-Source: AGHT+IGwmCCN5wh4NaLa8aArMkOF/G4Igcbkk8uWKtclUOXaJ3Z6Gx5Noog7Zc3uSUISJQ5MgoV6TQ== X-Received: by 2002:ae9:f50d:0:b0:78f:1044:bcc8 with SMTP id o13-20020ae9f50d000000b0078f1044bcc8mr1806809qkg.61.1713520187814; Fri, 19 Apr 2024 02:49: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 dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:47 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:11 +0000 Subject: [PATCH v2 25/26] media: dvb-frontends: tda10048: Fix integer overflow MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-25-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda , Dan Carpenter X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104951_510739_3284AD17 X-CRM114-Status: GOOD ( 13.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org state->xtal_hz can be up to 16M, so it can overflow a 32 bit integer when multiplied by pll_mfactor. Create a new 64 bit variable to hold the calculations. Reported-by: Dan Carpenter Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-frontends/tda10048.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c index 5d5e4e9e4422..3e725cdcc66b 100644 --- a/drivers/media/dvb-frontends/tda10048.c +++ b/drivers/media/dvb-frontends/tda10048.c @@ -410,6 +410,7 @@ static int tda10048_set_if(struct dvb_frontend *fe, u32 bw) struct tda10048_config *config = &state->config; int i; u32 if_freq_khz; + u64 sample_freq; dprintk(1, "%s(bw = %d)\n", __func__, bw); @@ -451,9 +452,11 @@ static int tda10048_set_if(struct dvb_frontend *fe, u32 bw) dprintk(1, "- pll_pfactor = %d\n", state->pll_pfactor); /* Calculate the sample frequency */ - state->sample_freq = state->xtal_hz * (state->pll_mfactor + 45); - state->sample_freq /= (state->pll_nfactor + 1); - state->sample_freq /= (state->pll_pfactor + 4); + sample_freq = state->xtal_hz; + sample_freq *= state->pll_mfactor + 45; + do_div(sample_freq, state->pll_nfactor + 1); + do_div(sample_freq, state->pll_pfactor + 4); + state->sample_freq = sample_freq; dprintk(1, "- sample_freq = %d\n", state->sample_freq); /* Update the I/F */ From patchwork Fri Apr 19 09:48:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13636109 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 00C4EC4345F for ; Fri, 19 Apr 2024 09:53: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bK30URgvbTbv/+6RC5dElcsAfzChmheMYFYS9URU3PE=; b=pqsNLN2fgMs7NT H6TeJ5OGVc0r2zyDEztJGRoLjvhACzB6dF1gn4UpcHK/wUsy7WXT26fuC0RkIJVnkhsvH1lHPKo+F GwnK/N5YoSfKW+D0hEk5zjZt+W7ejIykB/EgG3xj70uo20IrUw9J2ekZTvzUHp6v9rBp0oKY+wZ69 FAL4EIXfG+R9Zr8DIUkguBvDMw0ItgQNqV1Z27lLjVz0siOPA6dQIa4lbOhZikkY3Vu5B7TK/CdSh JL4Yik8mqbbaN5KrpJrM9W5WZi0Uy0mbRPsiVktjfjk06nOXZ4mQ8CPxNKH/MEAWt5dj+ObS+laqU lZSb0EvyBvpNFq0ksT+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkwC-00000005BTA-2STj; Fri, 19 Apr 2024 09:53:44 +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 1rxksW-000000059Iq-1EsQ for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:56 +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=STqazHEagBxWlHC69lQFp5WbvQ2Sdx8rB6+uKcUB0cU=; b=DUNe83Fp9v9Z720So59i/GzYZz 1bMD55PSoGUItxpB7GRVBohiUYr6/uND2cRKpysv53KoEp4f422LjMzumndpBqb/0q5h2OgdpqKge AHPdBqYXsZSdL1F8/3nSPerwgTf+oaJ6rkoUExwnpb4u2MBW9cJthT7UEzloCDdqzxkk15XR1rPgD IIX1myBJpzGxeSdpRBWnWkmcoKEUO0zwRL/BW2GRnD7q3ygwJxBOO1ZI9H56qfJMfIx2AIM9q6ZC/ tLGLXSyItSD/8HThlauiCE1ws4bq8DblCbwAB+UEc/qw7FWYksS8Rxen89QrNM8sCK0ADK0/NiiRK E8AK7RMg==; Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksS-0000000COUL-1UGD for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:55 +0000 Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-78f05e56cb3so107464385a.1 for ; Fri, 19 Apr 2024 02:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520190; x=1714124990; 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=XAU9ZmZeXGx7enTxKqJcgoZrGS+MI1WahPhypLf+qdS1d67iYRkMoPQNwB9IVEG/++ h15XnH5+o7C/XeN9O0nbpQTwkf+QGCKciUe8yfJwWdwwd7GaP+H75IsiLxISWQIXug/R 8seF6s/Ol01HHYDlQoSdZtvFQoCY96240ztnk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520190; x=1714124990; 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=nKeokubjB0pboYvNZpus+S/9CbquelDKRCJnenwVM6kXWRp/Wy9cqnW8328FZN2rFN es0vbB6C8CFNbCd/VuhR8sLTEc9lTAp7D3eoaUDcu2+lXoB07eLZUj6+oubeCSh7qCuS Ib0mTDLffY8whjrz6669YVEAnXX/0Qka0kEDPNWca1am2kBRTk4X3ph4jmurGKu1rwS+ Gt8ldfqLfSguckTCFCKbAOrQ+kO5EUeCg0O+KuRXRyuVLnr0a/Ml9s7SaoNdf+NmYoGs EeUYKK/WXvby8wwpB8ed86YdWubLg0zLnOE4WvYGJvQqUcRkI2KogAmT2JFeqxVZ4o1c TZRA== X-Forwarded-Encrypted: i=1; AJvYcCVKtgTyVhato9EVTReymjNVI6PWy2l8Aj4ryTNJqQUk3ze4uAXIrjypoU/aijRwv5DiYkOt7x46sn+Rf1TKuS+SRVh/7ewbCzpvyAut9+R6XApKsWU= X-Gm-Message-State: AOJu0Yxw+CM/FAE0Dufkw6qNfe+pO7AcsDTzSztWgDCw8OZSre/WSE2E pvpSg/r+h1N18StlRU9PXm6vC7JOyPXx6L2X/1aZ6W1fc7edD3fV+K8BVZwwOw== X-Google-Smtp-Source: AGHT+IGB4W3xcDVnLVL+1B0lbE5yrHeQCLWo5Y0evN+/+oC4NuGMNOIMrDzfkEb/6TpNH9rKrh/xtA== X-Received: by 2002:ae9:f00d:0:b0:78e:fd3c:b6 with SMTP id l13-20020ae9f00d000000b0078efd3c00b6mr1503480qkg.40.1713520189085; Fri, 19 Apr 2024 02:49: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 dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:48 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:12 +0000 Subject: [PATCH v2 26/26] media: dvb-frontends: tda10048: Make explicit the range of z. MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-26-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104953_296480_4A908F22 X-CRM114-Status: GOOD ( 12.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We do not expect the sample_freq to be over 613MHz. Found by cocci: drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Signed-off-by: Ricardo Ribalda --- drivers/media/dvb-frontends/tda10048.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c index 3e725cdcc66b..1886f733dbbf 100644 --- a/drivers/media/dvb-frontends/tda10048.c +++ b/drivers/media/dvb-frontends/tda10048.c @@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, u32 bw) { struct tda10048_state *state = fe->demodulator_priv; - u64 t, z; + u32 z; + u64 t; dprintk(1, "%s()\n", __func__); @@ -341,6 +342,7 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, /* t *= 2147483648 on 32bit platforms */ t *= (2048 * 1024); t *= 1024; + /* Sample frequency is under 613MHz */ z = 7 * sample_freq_hz; do_div(t, z); t += 5;