From patchwork Mon Apr 15 19:34:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13630591 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 A6A8AC4345F for ; Mon, 15 Apr 2024 19:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BGYZef+TQDgV/EJ3rc6yDialKCDZWZkSwwbxbmsLOyU=; b=Wf4FW9Bvnpd2dc 4H9/HYMlMqv7Q36mHA8mk71z6WGpLj/S7y/C+wWnSXS4ee6KaxwjS0IoAz/UYcyXz0kpGgIww+rpx crOcCFVzK4tuErAuJ7XQaefISpKgR4speyls6dB4v6L0vtXsYpRUG6AKixkkAsMxmcVCVypcUMHeb aDy3l1yLhoSM5CQBKLG1jvodRNEWi3HOe6qyDTKvgYIoIdGyGuFp2GpttuxfGZiDKpYSLI/h4DGTi rjFOk6jF/YP2+y0WukHCd2Jtt1oHPuNMhui8mxqa2elUP5P2wrdDmFgKs0MsUC4SgeBWraAMi/j/X nWFa5hVbTASXVe9k+DUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwS6M-00000009c5h-1S4H; Mon, 15 Apr 2024 19:34:50 +0000 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwS66-00000009bou-1MA9 for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 19:34:38 +0000 Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-3c7150cff81so243995b6e.2 for ; Mon, 15 Apr 2024 12:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713209668; x=1713814468; 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=w+qS5Z4vkKN1UceEhIkP1myjPLSe7r+1w4SAg1mZwEM=; b=b+5gw1dHyw/pL+JPlvVWR5ZU9o1o0Fcm5Ea3D/d62XTJBiYSXuhnr7eInRXsPls41U y/5YhVItn4e8vjcK4P6NiLY62vO+4k49MyItvFJ39NMAiY85nSHuU/9ZFimPeXhEE7cb SPfGp20RYlQnLw4uCRRoipFyRSh4P2H9+5tQ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713209668; x=1713814468; 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=w+qS5Z4vkKN1UceEhIkP1myjPLSe7r+1w4SAg1mZwEM=; b=XXL8HbIbuEzPkJ4E6KiTSedJECqCDJOx9QmdKjxi+kIT4s3uowI9TDPAPM8N4mP9nr CtcCXwGJZPtNo/RbmJ7k/RcUALfK0XJDR7BaJ4QqggpyGSbROETs0fd+fEIaiFF3/fuU C0zv454AFuEUUW8n9CIdfXxaXldgGG7Ul9rkK9UyOaHaIQlQOgJBo37eqFLoebGw4tYe 4fx/gpxsi5ZYJXPO9uzUVmeXySceqMVyutAy8Yy8B3s6CyLN5vdUSnLVSwtmcfNTZnjD MegVuW0O5tvA0kEHRtvDyQEa4yQ0DclOi2L4OIP/IWjcW1nG3Krx4/OboZus0S8Kszb6 e/OA== X-Forwarded-Encrypted: i=1; AJvYcCXd4uy6w2k0g27zp68/8AQDK+cCPxV8MpOeQfPu2/OaqjaAhaQ4zYWg0AYJyOYUn0SwbNqhSKBJWD1q9ulbnhNHPV17Lif9v3ik4ug7KqMMUfr4xJY= X-Gm-Message-State: AOJu0YxZG1ZdZEiTmyajY7shPaOHhemA3rJ3i6ZLDe5CG9OVfSA1dCFe OwirE7Qhyl/pvXOTNkg26oWdbVhJWdvQFaNpjsf7dHMHDe5xN8DSoPzdsJo0Ng== X-Google-Smtp-Source: AGHT+IGdtkSiZhnfiSTfKFrIX7aC7mQfEfNuaLQ9aOCusHbpbm/GtxuTWZQaZZkHNYhX7JRsmp7ZXg== X-Received: by 2002:a05:6808:4084:b0:3c5:f5a0:3b40 with SMTP id db4-20020a056808408400b003c5f5a03b40mr11232302oib.58.1713209668180; Mon, 15 Apr 2024 12:34: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 s26-20020ae9f71a000000b0078d3b54eb76sm6718055qkg.78.2024.04.15.12.34.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 12:34:27 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 15 Apr 2024 19:34:18 +0000 Subject: [PATCH 01/35] media: pci: mgb4: Refactor struct resources MIME-Version: 1.0 Message-Id: <20240415-fix-cocci-v1-1-477afb23728b@chromium.org> References: <20240415-fix-cocci-v1-0-477afb23728b@chromium.org> In-Reply-To: <20240415-fix-cocci-v1-0-477afb23728b@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hans Verkuil , 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 , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio , Benjamin Mugnier , Sylvain Petinot , Jacopo Mondi , Kieran Bingham , Laurent Pinchart , =?utf-8?q?Ni?= =?utf-8?q?klas_S=C3=B6derlund?= , Pavel Machek 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-20240415_123434_534217_66350D63 X-CRM114-Status: GOOD ( 15.40 ) 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 Signed-off-by: Ricardo Ribalda Reviewed-by: Martin Tůma --- 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;