From: Frank Li <Frank.Li@nxp.com>
To: Philipp Zabel <p.zabel@pengutronix.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Rui Miguel Silva <rmfrfs@gmail.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Martin Kepplinger-Novakovic <martink@posteo.de>,
Purism Kernel Team <kernel@puri.sm>
Cc: linux-media@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Frank Li <Frank.Li@nxp.com>
Subject: [PATCH v2 4/5] media: nxp: use cleanup __free(fwnode_handle) simplify code
Date: Wed, 19 Nov 2025 16:34:27 -0500 [thread overview]
Message-ID: <20251119-cam_cleanup-v2-4-df732cc83ff1@nxp.com> (raw)
In-Reply-To: <20251119-cam_cleanup-v2-0-df732cc83ff1@nxp.com>
Use cleanup __free(fwnode_handle) simplify code. No functional change.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
change in v2.
- move variable define to top.
- remove dev_err_probe() change
---
drivers/media/platform/nxp/imx-mipi-csis.c | 21 ++++++---------------
drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 21 ++++++---------------
2 files changed, 12 insertions(+), 30 deletions(-)
diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
index ce93d868746f002c22e2f86b1e0aa84ec1a76061..f345aba63936f5ee86ec4c621f3cb434002d7c8d 100644
--- a/drivers/media/platform/nxp/imx-mipi-csis.c
+++ b/drivers/media/platform/nxp/imx-mipi-csis.c
@@ -12,6 +12,7 @@
*
*/
+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/debugfs.h>
#include <linux/delay.h>
@@ -1349,7 +1350,7 @@ static int mipi_csis_async_register(struct mipi_csis_device *csis)
.bus_type = V4L2_MBUS_CSI2_DPHY,
};
struct v4l2_async_connection *asd;
- struct fwnode_handle *ep;
+ struct fwnode_handle *ep __free(fwnode_handle) = NULL;
unsigned int i;
int ret;
@@ -1362,14 +1363,13 @@ static int mipi_csis_async_register(struct mipi_csis_device *csis)
ret = v4l2_fwnode_endpoint_parse(ep, &vep);
if (ret)
- goto err_parse;
+ return ret;
for (i = 0; i < vep.bus.mipi_csi2.num_data_lanes; ++i) {
if (vep.bus.mipi_csi2.data_lanes[i] != i + 1) {
dev_err(csis->dev,
"data lanes reordering is not supported");
- ret = -EINVAL;
- goto err_parse;
+ return -EINVAL;
}
}
@@ -1381,12 +1381,8 @@ static int mipi_csis_async_register(struct mipi_csis_device *csis)
asd = v4l2_async_nf_add_fwnode_remote(&csis->notifier, ep,
struct v4l2_async_connection);
- if (IS_ERR(asd)) {
- ret = PTR_ERR(asd);
- goto err_parse;
- }
-
- fwnode_handle_put(ep);
+ if (IS_ERR(asd))
+ return PTR_ERR(asd);
csis->notifier.ops = &mipi_csis_notify_ops;
@@ -1395,11 +1391,6 @@ static int mipi_csis_async_register(struct mipi_csis_device *csis)
return ret;
return v4l2_async_register_subdev(&csis->sd);
-
-err_parse:
- fwnode_handle_put(ep);
-
- return ret;
}
/* -----------------------------------------------------------------------------
diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
index a007c582b4d91660a97910a6a0d53c9b6fcd73e9..bb9dace0cfac08dc43858b69590f3d73457b3c4c 100644
--- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
+++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
@@ -6,6 +6,7 @@
*/
#include <linux/bitfield.h>
+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/delay.h>
@@ -716,8 +717,8 @@ static int imx8mq_mipi_csi_async_register(struct csi_state *state)
struct v4l2_fwnode_endpoint vep = {
.bus_type = V4L2_MBUS_CSI2_DPHY,
};
+ struct fwnode_handle *ep __free(fwnode_handle) = NULL;
struct v4l2_async_connection *asd;
- struct fwnode_handle *ep;
unsigned int i;
int ret;
@@ -730,14 +731,13 @@ static int imx8mq_mipi_csi_async_register(struct csi_state *state)
ret = v4l2_fwnode_endpoint_parse(ep, &vep);
if (ret)
- goto err_parse;
+ return ret;
for (i = 0; i < vep.bus.mipi_csi2.num_data_lanes; ++i) {
if (vep.bus.mipi_csi2.data_lanes[i] != i + 1) {
dev_err(state->dev,
"data lanes reordering is not supported");
- ret = -EINVAL;
- goto err_parse;
+ return -EINVAL;
}
}
@@ -749,12 +749,8 @@ static int imx8mq_mipi_csi_async_register(struct csi_state *state)
asd = v4l2_async_nf_add_fwnode_remote(&state->notifier, ep,
struct v4l2_async_connection);
- if (IS_ERR(asd)) {
- ret = PTR_ERR(asd);
- goto err_parse;
- }
-
- fwnode_handle_put(ep);
+ if (IS_ERR(asd))
+ return PTR_ERR(asd);
state->notifier.ops = &imx8mq_mipi_csi_notify_ops;
@@ -763,11 +759,6 @@ static int imx8mq_mipi_csi_async_register(struct csi_state *state)
return ret;
return v4l2_async_register_subdev(&state->sd);
-
-err_parse:
- fwnode_handle_put(ep);
-
- return ret;
}
/* -----------------------------------------------------------------------------
--
2.34.1
next prev parent reply other threads:[~2025-11-19 21:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 21:34 [PATCH v2 0/5] media: platform: nxp: Trivial cleanup pathces Frank Li
2025-11-19 21:34 ` [PATCH v2 1/5] media: nxp: use devm_mutex_init() simple code Frank Li
2025-11-19 21:34 ` [PATCH v2 2/5] media: nxp: use dev_err_probe() to simplify code Frank Li
2025-11-19 21:34 ` [PATCH v2 3/5] media: nxp: imx8-isi: use devm_pm_runtime_enable() " Frank Li
2025-11-19 21:34 ` Frank Li [this message]
2025-11-19 21:34 ` [PATCH v2 5/5] media: nxp: Add dev_err_probe() to all error paths in *async_register() helpers Frank Li
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=20251119-cam_cleanup-v2-4-df732cc83ff1@nxp.com \
--to=frank.li@nxp.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=kernel@puri.sm \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=martink@posteo.de \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=rmfrfs@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.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