From: Rishikesh Donadkar <r-donadkar@ti.com>
To: <jai.luthra@linux.dev>, <laurent.pinchart@ideasonboard.com>,
<mripard@kernel.org>
Cc: <r-donadkar@ti.com>, <y-abhilashchandra@ti.com>,
<devarsht@ti.com>, <s-jain1@ti.com>, <vigneshr@ti.com>,
<mchehab@kernel.org>, <robh@kernel.org>, <krzk+dt@kernel.org>,
<p.zabel@pengutronix.de>, <conor+dt@kernel.org>,
<sakari.ailus@linux.intel.com>, <hverkuil-cisco@xs4all.nl>,
<tomi.valkeinen@ideasonboard.com>, <jai.luthra@ideasonboard.com>,
<changhuang.liang@starfivetech.com>, <jack.zhu@starfivetech.com>,
<sjoerd@collabora.com>, <dan.carpenter@linaro.org>,
<hverkuil+cisco@kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>
Subject: [PATCH] media: ti: j721e-csi2rx: Minor cleanup of loop variables
Date: Wed, 20 May 2026 19:27:05 +0530 [thread overview]
Message-ID: <20260520135705.661455-1-r-donadkar@ti.com> (raw)
Replace open-coded `i--; for (; i >= 0; i--)` patterns with the
idiomatic `while (i--)` in the error unwind paths of
csi_async_notifier_complete() and ti_csi2rx_probe().
Also scope loop variables directly in the for statement instead of
declaring them at the top of the function in ti_csi2rx_suspend(),
ti_csi2rx_resume() and ti_csi2rx_remove(). Change the type to
unsigned int in the first two to match csi->num_ctx.
Signed-off-by: Rishikesh Donadkar <r-donadkar@ti.com>
---
This patch depends on [1]
[1]: https://lore.kernel.org/all/20260520120022.539913-1-r-donadkar@ti.com/
.../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
index 21388284cbaa..ef74e2da19b6 100644
--- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
+++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
@@ -485,8 +485,7 @@ static int csi_async_notifier_complete(struct v4l2_async_notifier *notifier)
return 0;
unregister_dev:
- i--;
- for (; i >= 0; i--) {
+ while (i--) {
media_entity_remove_links(&csi->ctx[i].vdev.entity);
video_unregister_device(&csi->ctx[i].vdev);
}
@@ -1552,7 +1551,7 @@ static int ti_csi2rx_suspend(struct device *dev)
struct ti_csi2rx_ctx *ctx;
struct ti_csi2rx_dma *dma;
unsigned long flags = 0;
- int i, ret = 0;
+ int ret = 0;
/* If device was not in use we can simply suspend */
if (pm_runtime_status_suspended(dev))
@@ -1564,7 +1563,7 @@ static int ti_csi2rx_suspend(struct device *dev)
*/
writel(0, csi->shim + SHIM_CNTL);
- for (i = 0; i < csi->num_ctx; i++) {
+ for (unsigned int i = 0; i < csi->num_ctx; i++) {
ctx = &csi->ctx[i];
dma = &ctx->dma;
@@ -1604,7 +1603,7 @@ static int ti_csi2rx_resume(struct device *dev)
struct ti_csi2rx_buffer *buf;
unsigned long flags = 0;
unsigned int reg;
- int i, ret = 0;
+ int ret = 0;
/* If device was not in use, we can simply wakeup */
if (pm_runtime_status_suspended(dev))
@@ -1614,7 +1613,7 @@ static int ti_csi2rx_resume(struct device *dev)
reg = SHIM_CNTL_PIX_RST;
writel(reg, csi->shim + SHIM_CNTL);
- for (i = 0; i < csi->num_ctx; i++) {
+ for (unsigned int i = 0; i < csi->num_ctx; i++) {
ctx = &csi->ctx[i];
dma = &ctx->dma;
spin_lock_irqsave(&dma->lock, flags);
@@ -1755,8 +1754,7 @@ static int ti_csi2rx_probe(struct platform_device *pdev)
err_notifier:
ti_csi2rx_cleanup_notifier(csi);
err_ctx:
- i--;
- for (; i >= 0; i--)
+ while (i--)
ti_csi2rx_cleanup_ctx(&csi->ctx[i]);
ti_csi2rx_cleanup_v4l2(csi);
err_dma_chan:
@@ -1768,12 +1766,11 @@ static int ti_csi2rx_probe(struct platform_device *pdev)
static void ti_csi2rx_remove(struct platform_device *pdev)
{
struct ti_csi2rx_dev *csi = platform_get_drvdata(pdev);
- unsigned int i;
if (!pm_runtime_status_suspended(&pdev->dev))
pm_runtime_set_suspended(&pdev->dev);
- for (i = 0; i < csi->num_ctx; i++)
+ for (unsigned int i = 0; i < csi->num_ctx; i++)
ti_csi2rx_cleanup_ctx(&csi->ctx[i]);
ti_csi2rx_cleanup_notifier(csi);
--
2.34.1
next reply other threads:[~2026-05-20 13:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 13:57 Rishikesh Donadkar [this message]
2026-05-20 14:27 ` [PATCH] media: ti: j721e-csi2rx: Minor cleanup of loop variables Jai Luthra
2026-06-18 9:40 ` Tomi Valkeinen
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=20260520135705.661455-1-r-donadkar@ti.com \
--to=r-donadkar@ti.com \
--cc=changhuang.liang@starfivetech.com \
--cc=conor+dt@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=devarsht@ti.com \
--cc=devicetree@vger.kernel.org \
--cc=hverkuil+cisco@kernel.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jack.zhu@starfivetech.com \
--cc=jai.luthra@ideasonboard.com \
--cc=jai.luthra@linux.dev \
--cc=krzk+dt@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mripard@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=s-jain1@ti.com \
--cc=sakari.ailus@linux.intel.com \
--cc=sjoerd@collabora.com \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=vigneshr@ti.com \
--cc=y-abhilashchandra@ti.com \
/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