[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260121014508.GB403250@killaraus>
Date: Wed, 21 Jan 2026 03:45:08 +0200
From: Laurent Pinchart <laurent.pinchart@...asonboard.com>
To: Frank Li <Frank.Li@....com>
Cc: Philipp Zabel <p.zabel@...gutronix.de>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>,
Rui Miguel Silva <rmfrfs@...il.com>,
Martin Kepplinger-Novakovic <martink@...teo.de>,
Purism Kernel Team <kernel@...i.sm>, linux-media@...r.kernel.org,
imx@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 3/4] media: nxp: use cleanup __free(fwnode_handle)
simplify code
Hi Frank,
Thank you for the patch.
On Fri, Jan 16, 2026 at 11:29:21AM -0500, Frank Li wrote:
> Use cleanup __free(fwnode_handle) simplify code. No functional change.
>
> Signed-off-by: Frank Li <Frank.Li@....com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@...asonboard.com>
> ---
> change in v3
> - Rollback to v1 version to align guide at cleanup.h.
> - Ref similar link
>
> Link: https://lore.kernel.org/r/20240904044825.1048256-1-dmitry.torokhov@gmail.com
> Link: https://patch.msgid.link/20251208020750.4727-3-krzysztof.kozlowski@oss.qualcomm.com
>
> 452e0adff2618 Input: iqs7222 - use cleanup facility for fwnodes
> 52776177d8b7e Input: iqs626a - use cleanup facility for fwnodes
> 9a540b67a9c26 Input: iqs269a - use cleanup facility for fwnodes
> cc3b18f9fedec i3c: master: Fix confusing cleanup.h syntax
>
> change in v2.
> - move variable define to top.
> - remove dev_err_probe() change
> ---
> drivers/media/platform/nxp/imx-mipi-csis.c | 25 ++++++++-----------------
> drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 25 ++++++++-----------------
> 2 files changed, 16 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
> index ce93d868746f002c22e2f86b1e0aa84ec1a76061..9a43fd1eb0bcee7ac0c47f28ad89012de45a70d9 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,27 +1350,26 @@ 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;
> unsigned int i;
> int ret;
>
> v4l2_async_subdev_nf_init(&csis->notifier, &csis->sd);
>
> - ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(csis->dev), 0, 0,
> - FWNODE_GRAPH_ENDPOINT_NEXT);
> + struct fwnode_handle *ep __free(fwnode_handle) =
> + fwnode_graph_get_endpoint_by_id(dev_fwnode(csis->dev), 0, 0,
> + FWNODE_GRAPH_ENDPOINT_NEXT);
> if (!ep)
> return -ENOTCONN;
>
> 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 83da050a1dcbad1d41c94de0e352dcafe3f25e62..9d946b68cf59d9f4fb3413fc90219efd380d9d95 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>
> @@ -717,27 +718,26 @@ static int imx8mq_mipi_csi_async_register(struct csi_state *state)
> .bus_type = V4L2_MBUS_CSI2_DPHY,
> };
> struct v4l2_async_connection *asd;
> - struct fwnode_handle *ep;
> unsigned int i;
> int ret;
>
> v4l2_async_subdev_nf_init(&state->notifier, &state->sd);
>
> - ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(state->dev), 0, 0,
> - FWNODE_GRAPH_ENDPOINT_NEXT);
> + struct fwnode_handle *ep __free(fwnode_handle) =
> + fwnode_graph_get_endpoint_by_id(dev_fwnode(state->dev), 0, 0,
> + FWNODE_GRAPH_ENDPOINT_NEXT);
> if (!ep)
> return -ENOTCONN;
>
> 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;
> }
>
> /* -----------------------------------------------------------------------------
--
Regards,
Laurent Pinchart
Powered by blists - more mailing lists