Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1427459lqa; Mon, 29 Apr 2024 08:12:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXpfwjgCHjVKP1BFYd3CzXwqC2pPH/QOXopiKKMua/sGOGRLjaYp6/R9je+HkcC+Q9bPQO9Oxiw8kqh7knPf7Tkl6c83DdnXMwJixFPyg== X-Google-Smtp-Source: AGHT+IE43NIWmn7Zk2/jSxGKv+pEztQhBC0qGKAB0yeRln1BzfdaArajO6R6U+UPSa2RwP70DtFX X-Received: by 2002:a50:d58e:0:b0:570:388:ee0b with SMTP id v14-20020a50d58e000000b005700388ee0bmr6187346edi.42.1714403529614; Mon, 29 Apr 2024 08:12:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714403529; cv=pass; d=google.com; s=arc-20160816; b=nCTpjXzfR08wAEiSQDv4vlQ96K8l6vy5fVNoqF8zm0HeVIpE1tB8u6hRO5l6Vizztu 9kcnosqW6UhBB05jOkFACTBgY3lTmJYbj7XbMzMgiIhRgivIg7rT41j51Kk6cYWuwLp0 hPVUJgo23dBX7zijXYi9F8dtlOSmN3DsUJKCs1ot0SuxOnCVaxKtAOyUN+Addb0ANDGQ 45SLM1inyLnJUaI1yehA6gRDbzCULQWOATdERSltMkxBHcczW+/UbLxEWh/Qi9vkyFaD 6Bzkj7tNBaR7xKKyxLidqhalynEEeZfSO5uOOHj5oTSbH8eOkP7ptzaBKiy+hrYwTAjE oGmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=cX0Nt2WjhKwJC/tEnFmYRvlB1MfFk2LmbDG81TIdFVM=; fh=l67DfAnWAAJjCxEFTd2QRU1Jqhiw23oGJL9iTne8Qos=; b=M+s632P6NznjVQc2QF8rTILeSa9Aneu1Ywch9SVtGwXwP2XHFZ18z6xpdMdUyF1vfm RkqKW0PQrnT4C/ezWnOvqyX1tWYwySQO1WWpo/dBz/TCL2B7XzX4wtV1xc/EG07I51nZ /r0a/87jDJEzsV7hoJ32feKBnpi/mU5Oq1cRcVaxvoee8wYdQJ8WKt4QjBjuU2iQgZbf hF45jFBTbMsIAzh1V6dMPtrPcpduOWmYCgjbZxo7PsGXhEj4uWxwTKTW9vZvk/1IHvc8 q39eZEAXu16qWSHOyQJ9ZO5VcPPlquG7UFtoOiCimUcHkr9qD7ZY0Pwj0mhL5uCT4vN9 3E0w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=E7pF7Kj7; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-162510-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162510-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bo26-20020a0564020b3a00b0056fd9c5ee39si13885433edb.608.2024.04.29.08.12.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:12:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162510-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=E7pF7Kj7; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-162510-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162510-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 95FFA1F240F0 for ; Mon, 29 Apr 2024 15:05:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B11582D7C; Mon, 29 Apr 2024 15:04:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="E7pF7Kj7" Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28C078172D for ; Mon, 29 Apr 2024 15:04:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714403087; cv=none; b=r5BW6ZeWXGdWXdlZjq2XMhIMaFBea0+xJrbdxW9qSatYSbcYRHU59UahxQjQG+ifcJ+FZa2NLm6aPCF+Rbwaw4xjd54nOmYMs3A84hh0f6TpZL1bv+JlCCYSX0YLhWazsAJymFqh0adUVDfwPVBze/gyvlT6lHd6gG2J1cX+pnQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714403087; c=relaxed/simple; bh=eXbttcpUuvi0IptVhr7LEXzauMF/5khZjI9wxngZz54=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oNlWdaLPkpViMPIMqt/FdABXizCWEzL288VvlTpC2TmkWGLdsxxbwlT0gyn+cpVk3JPYZwtukogAFfynbxDz7M8pIh/29fYPioMreb4ad7eQb772uFO3RnbiFCw3JYgdrONjDs5UnqcVWO7xmsfgPEmTMIkyHHgSwHEuIww4zuY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=E7pF7Kj7; arc=none smtp.client-ip=209.85.222.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-790605809cbso420802285a.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=vger.kernel.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=E7pF7Kj7YHu7v0KeWbK7tlOVH/XNvfCMiesa8wWsDzyV7Dh4J/9toLXFKozDKuCjnv vYzjgitkWDKo1a/7agy0dXwaejfdgFHgMQTOrWKQftefM3pRxBkPqfTyIZUz66NFALGT Q398n/3jOAdyD2V+AxG2HMw972ewx2mu1sgVc= 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=u6ak/FFdTGnNndP9P0l/cpjhhYFRQ6Wkbf3tKouLVlcP5lNxd8sthzjiCAuTJTTDBd ZaDTkBhPNOJ9mx+utZXTyosvyUN+2n/xlMTuawcBSSelUlEcvUo5L+J8n6P6Vh8z4yRX CqgAcVcTpDMIZ1c+ysxuXW+BYqKrxGAwayVe0jNLIb37ZXl0Z3Gv34e7iBv9qDrPRLTi ZCOJii+zNlPIMTars8DTHgc5BqdYQZu8pmHJRpwH7r18pViaZ0xMoCa+IDD3w7JgjuKd /At7kaK3m/3y6rgOqqvKBzSxY7gTrveCT5sfYg5bPEivJg3/fSqAFRwp/b/9ggXUwXhQ JKgQ== X-Forwarded-Encrypted: i=1; AJvYcCXPLeVp4utI+2wP7qU1bd3jE0Ar0t17e9XhEPcI94poM8YF/c2eEynGJ8tz/oSjdQwok/XPo2msT4oS7Qk6gUuLB7N/s99W5dLybhHh X-Gm-Message-State: AOJu0YyOExyX2dIsh2SQbxuCJ4BzwD5tuoc6VfKCgID7/I3Tj19v/wRw EkgPzlQwYHrounpBwRGVm7i4juUEGRDSu7EjDU0n+8pNm4+RLBY0YIPYvkGftA== 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 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; -- 2.44.0.769.g3c40516874-goog