From patchwork Mon Apr 29 15:04:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647152 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2D4DFC4345F for ; Mon, 29 Apr 2024 15:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aatYulGL8/eR7YNKB85r75E0V2GzEEcGJEWMjCQnyEo=; b=wWzT8jyNVrMwUc 14p5KXtamutTg67yWDmebUFfHZNrrxb01wQxcE93MDDmIiMRkshrTow1YBmqKCaCrNrV30mvpuY5w l9HnJXclwCOQaSoLpWeaXbQZzgChK7fIBGL4OzX5rDIcEPuQTFOTTFmP+D/v3S7I3uk7k8CEA0F6c 0SZqjTOqlZdVPs9WHLfiCsN+hzUhzMPWvl5o0eOV2Ta1oof+Gcvj0zTvXgu4Gbhn60Y+fxr7e8jGQ rgDlj0RoyxTB8Eg2mCTjLoU6HlxQqoWJLkFCr2QSpoeQU924ZsT+w2JjBN2fla5rELx7ZkAezJodF Uqk2VKiZlpj+JwmFqCcQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYk-00000003FKE-2kck; Mon, 29 Apr 2024 15:04:50 +0000 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYf-00000003FFq-26Kc for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:04:47 +0000 Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-790605809cbso420801785a.3 for ; Mon, 29 Apr 2024 08:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403084; x=1715007884; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=cX0Nt2WjhKwJC/tEnFmYRvlB1MfFk2LmbDG81TIdFVM=; b=VG+osiId90CMFXtEbs7eadJ8eYRfgWhvNm8QugtxWw8aRGwc7vM82Xlg72LxLrV9VB TTgkGJdHRgv694N/9W2c3L0CEbR9oQfNeHFzRSl/9GTogpdrv4XGJfQkCDu5lP6BG1TV bdO5tZdW8Y+ygR7uj7w8ZlDeFr6MU9a/64Krk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403084; x=1715007884; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cX0Nt2WjhKwJC/tEnFmYRvlB1MfFk2LmbDG81TIdFVM=; b=BUViHF9ewFS47CFaMGrEQkHxlQ91esQW921YJaUYCVaXmzjyL8IDQrcXWfyNJZ8yXo q9kRHa1F5OQ2u7GvBn7A8ltLgR+vplHsxdxWoegXByoRl8onNU5glx7n5r/M8Wy3L8lL P4oIKfY1v6IUuPQMhPGgQqypWHwl0d0KO+9pUcyGhe/ydkzrG3lzi+G9IB9k3MorSe36 94OZ4fBHjhxgHabCdqWJxfKJ6HDS7uDTMRUy6OkPHZSa6aXb1In48UlAHhNdNqFSUMh+ CPzDHt/Q5Vk9pSpqgrgJlF+IYRwSVLiKhz3NvrDWWkWJS/Y3pnXLM88RLtKLPm2tFOwh 08iw== X-Forwarded-Encrypted: i=1; AJvYcCXF3qatFaJQB+6ZIDrmXR9/a9rkpRZpI2s0ZUqxb3CpERVpe0HvCAYyGUyw27f0wFB3ceUgangJ48PaxROGpLceo9DQG0oRwaHzHuLT8qyhx15uJCo= X-Gm-Message-State: AOJu0YwmMfVgXdikMXQ6ARXzNnwAA96gxXZfpg6+bQLwujz+ur6yfkzG pxKBWYK+Y3nFj6P1JfjZXLnqZkyBzhwWZ5PndQKlmmfYkCqEij2AcujLXRtncA== X-Google-Smtp-Source: AGHT+IHWuK1oddmDBavr6+ksLu5/g3HWffeblwIQsTBH58X6jA8tyFIvmLIj97Bf7YP3AKSemxlfBQ== X-Received: by 2002:a05:620a:4eb:b0:790:8e96:7841 with SMTP id b11-20020a05620a04eb00b007908e967841mr10130143qkh.60.1714403083799; Mon, 29 Apr 2024 08:04:43 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:43 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:40 +0000 Subject: [PATCH v3 01/26] media: pci: mgb4: Refactor struct resources MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-1-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_080445_575438_88EB166B X-CRM114-Status: GOOD ( 16.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The struct resource end field signifies the end address not the relative offset from the start field i.e size == (end - start) + 1. Amend the .end field to specify the end address not the relative size from the offset as is currently given. Fixes cocci check: drivers/media/pci/mgb4/mgb4_regs.c:13:22-25: WARNING: Suspicious code. resource_size is maybe missing with res Reviewed-by: Martin Tůma Reviewed-by: Bryan O'Donoghue Signed-off-by: Ricardo Ribalda --- drivers/media/pci/mgb4/mgb4_core.c | 4 ++-- drivers/media/pci/mgb4/mgb4_regs.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/pci/mgb4/mgb4_core.c b/drivers/media/pci/mgb4/mgb4_core.c index 9bcf10a77fd3..60498a5abebf 100644 --- a/drivers/media/pci/mgb4/mgb4_core.c +++ b/drivers/media/pci/mgb4/mgb4_core.c @@ -493,13 +493,13 @@ static int mgb4_probe(struct pci_dev *pdev, const struct pci_device_id *id) struct mgb4_dev *mgbdev; struct resource video = { .start = 0x0, - .end = 0x100, + .end = 0xff, .flags = IORESOURCE_MEM, .name = "mgb4-video", }; struct resource cmt = { .start = 0x1000, - .end = 0x1800, + .end = 0x17ff, .flags = IORESOURCE_MEM, .name = "mgb4-cmt", }; diff --git a/drivers/media/pci/mgb4/mgb4_regs.c b/drivers/media/pci/mgb4/mgb4_regs.c index 53d4e4503a74..31befd722d72 100644 --- a/drivers/media/pci/mgb4/mgb4_regs.c +++ b/drivers/media/pci/mgb4/mgb4_regs.c @@ -10,7 +10,7 @@ int mgb4_regs_map(struct resource *res, struct mgb4_regs *regs) { regs->mapbase = res->start; - regs->mapsize = res->end - res->start; + regs->mapsize = resource_size(res); if (!request_mem_region(regs->mapbase, regs->mapsize, res->name)) return -EINVAL;