Linux-Media Archive mirror
 help / color / mirror / Atom feed
From: Ricardo Ribalda <ribalda@chromium.org>
To: Martin Tuma <martin.tuma@digiteqautomotive.com>,
	 Mauro Carvalho Chehab <mchehab@kernel.org>,
	 Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	 Hugues Fruchet <hugues.fruchet@foss.st.com>,
	 Alain Volmat <alain.volmat@foss.st.com>,
	 Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	 Alexandre Torgue <alexandre.torgue@foss.st.com>,
	 Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	 Samuel Holland <samuel@sholland.org>,
	 Sakari Ailus <sakari.ailus@linux.intel.com>,
	 Thierry Reding <thierry.reding@gmail.com>,
	 Jonathan Hunter <jonathanh@nvidia.com>,
	 Sowjanya Komatineni <skomatineni@nvidia.com>,
	 Luca Ceresoli <luca.ceresoli@bootlin.com>,
	 Matthias Brugger <matthias.bgg@gmail.com>,
	 AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	 Hans Verkuil <hverkuil@xs4all.nl>,
	Sergey Kozlov <serjk@netup.ru>,  Abylay Ospan <aospan@netup.ru>,
	 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
	 Dmitry Osipenko <digetx@gmail.com>,
	 Benjamin Mugnier <benjamin.mugnier@foss.st.com>,
	 Sylvain Petinot <sylvain.petinot@foss.st.com>,
	 Stanimir Varbanov <stanimir.k.varbanov@gmail.com>,
	 Vikash Garodia <quic_vgarodia@quicinc.com>,
	 Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
	 Bjorn Andersson <andersson@kernel.org>,
	 Konrad Dybcio <konrad.dybcio@linaro.org>
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 <ribalda@chromium.org>
Subject: [PATCH v2 01/26] media: pci: mgb4: Refactor struct resources
Date: Fri, 19 Apr 2024 09:47:47 +0000	[thread overview]
Message-ID: <20240419-fix-cocci-v2-1-2119e692309c@chromium.org> (raw)
In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.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 <martin.tuma@digiteqautomotive.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 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


  reply	other threads:[~2024-04-19  9:49 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19  9:47 [PATCH v2 00/26] media: Fix coccinelle warning/errors Ricardo Ribalda
2024-04-19  9:47 ` Ricardo Ribalda [this message]
2024-04-20 23:00   ` [PATCH v2 01/26] media: pci: mgb4: Refactor struct resources Bryan O'Donoghue
2024-04-19  9:47 ` [PATCH v2 02/26] media: stb0899: Simplify check Ricardo Ribalda
2024-04-20 23:07   ` Bryan O'Donoghue
2024-04-19  9:47 ` [PATCH v2 03/26] media: uvcvideo: Refactor iterators Ricardo Ribalda
2024-04-19 10:01   ` Laurent Pinchart
2024-04-19  9:47 ` [PATCH v2 04/26] media: uvcvideo: Use max() macro Ricardo Ribalda
2024-04-19  9:47 ` [PATCH v2 05/26] media: go7007: Use min and max macros Ricardo Ribalda
2024-04-20 23:11   ` Bryan O'Donoghue
2024-04-19  9:47 ` [PATCH v2 06/26] media: stm32-dcmipp: Remove redundant printk Ricardo Ribalda
2024-04-20 23:15   ` Bryan O'Donoghue
2024-04-22  6:52     ` Ricardo Ribalda
2024-04-19  9:47 ` [PATCH v2 07/26] media: staging: sun6i-isp: " Ricardo Ribalda
2024-04-19  9:47 ` [PATCH v2 08/26] media: dvb-frontends: tda18271c2dd: Remove casting during div Ricardo Ribalda
2024-04-19  9:47 ` [PATCH v2 09/26] media: v4l: async: refactor v4l2_async_create_ancillary_links Ricardo Ribalda
2024-04-20 23:23   ` Bryan O'Donoghue
2024-04-24 10:55   ` Hans Verkuil
2024-04-24 18:17     ` Sakari Ailus
2024-04-24 18:46       ` Laurent Pinchart
2024-04-29 10:51         ` Ricardo Ribalda
2024-05-04  8:25           ` Hans Verkuil
2024-04-19  9:47 ` [PATCH v2 10/26] staging: media: tegra-video: Use swap macro Ricardo Ribalda
2024-04-19  9:47 ` [PATCH v2 11/26] media: s2255: Use refcount_t instead of atomic_t for num_channels Ricardo Ribalda
2024-04-19  9:47 ` [PATCH v2 12/26] media: platform: mtk-mdp3: Use refcount_t for job_count Ricardo Ribalda
2024-04-19  9:47 ` [PATCH v2 13/26] media: common: saa7146: Use min macro Ricardo Ribalda
2024-04-19  9:48 ` [PATCH v2 14/26] media: dvb-frontends: drx39xyj: " Ricardo Ribalda
2024-04-19  9:48 ` [PATCH v2 15/26] media: netup_unidvb: " Ricardo Ribalda
2024-04-19  9:48 ` [PATCH v2 16/26] media: au0828: " Ricardo Ribalda
2024-04-24 11:03   ` Hans Verkuil
2024-04-19  9:48 ` [PATCH v2 17/26] media: flexcop-usb: " Ricardo Ribalda
2024-04-19  9:48 ` [PATCH v2 18/26] media: gspca: cpia1: " Ricardo Ribalda
2024-04-19  9:48 ` [PATCH v2 19/26] media: stk1160: " Ricardo Ribalda
2024-04-19  9:48 ` [PATCH v2 20/26] media: tegra-vde: Refactor timeout handling Ricardo Ribalda
2024-04-19  9:48 ` [PATCH v2 21/26] media: i2c: st-mipid02: Use the correct div function Ricardo Ribalda
2024-04-24 18:22   ` Sakari Ailus
2024-04-19  9:48 ` [PATCH v2 22/26] media: tc358746: Use the correct div_ function Ricardo Ribalda
2024-04-19  9:48 ` [PATCH v2 23/26] media: venus: vdec: Make explicit the range of us_per_frame Ricardo Ribalda
2024-04-20 22:47   ` Bryan O'Donoghue
2024-04-21 13:20   ` Markus Elfring
2024-04-19  9:48 ` [PATCH v2 24/26] media: venus: venc: " Ricardo Ribalda
2024-04-20 22:47   ` Bryan O'Donoghue
2024-04-21 13:25   ` Markus Elfring
2024-04-21 13:48     ` Greg Kroah-Hartman
2024-04-19  9:48 ` [PATCH v2 25/26] media: dvb-frontends: tda10048: Fix integer overflow Ricardo Ribalda
2024-04-19  9:48 ` [PATCH v2 26/26] media: dvb-frontends: tda10048: Make explicit the range of z Ricardo Ribalda
2024-04-21 14:07   ` Markus Elfring
2024-04-24 11:11 ` [PATCH v2 00/26] media: Fix coccinelle warning/errors Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240419-fix-cocci-v2-1-2119e692309c@chromium.org \
    --to=ribalda@chromium.org \
    --cc=alain.volmat@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andersson@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=aospan@netup.ru \
    --cc=benjamin.mugnier@foss.st.com \
    --cc=bryan.odonoghue@linaro.org \
    --cc=digetx@gmail.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=gregkh@linuxfoundation.org \
    --cc=hugues.fruchet@foss.st.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=linux-tegra@vger.kernel.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=martin.tuma@digiteqautomotive.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=quic_vgarodia@quicinc.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=samuel@sholland.org \
    --cc=serjk@netup.ru \
    --cc=skomatineni@nvidia.com \
    --cc=stanimir.k.varbanov@gmail.com \
    --cc=sylvain.petinot@foss.st.com \
    --cc=thierry.reding@gmail.com \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).