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;