Linux-Media Archive mirror
 help / color / mirror / Atom feed
From: R Sundar <prosunofficial@gmail.com>
To: mripard@kernel.org, mchehab@kernel.org
Cc: christophe.jaillet@wanadoo.fr, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org, skhan@linuxfoundation.org,
	javier.carrasco.cruz@gmail.com,
	R Sundar <prosunofficial@gmail.com>,
	Julia Lawall <julia.lawall@inria.fr>
Subject: [PATCH v2 linux-next] media:cdns-csi2tx: replace of_node_put() with __free
Date: Wed,  1 May 2024 09:31:23 +0530	[thread overview]
Message-ID: <20240501040123.7327-1-prosunofficial@gmail.com> (raw)

Use the new cleanup magic to replace of_node_put() with
__free(device_node) marking to auto release when they get out of scope.

Suggested-by: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: R Sundar <prosunofficial@gmail.com>
---

Changes since v1 - Nitpick,  If function is successful,  then it will always
return 0 at the end of function.  so changed to return value as zero as it
reached  end of function.

Link to v1 - https://lore.kernel.org/all/20240429171543.13032-1-prosunofficial@gmail.com/

 drivers/media/platform/cadence/cdns-csi2tx.c | 21 ++++++++------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/cadence/cdns-csi2tx.c b/drivers/media/platform/cadence/cdns-csi2tx.c
index 3d98f91f1bee..1a56bbaeaecb 100644
--- a/drivers/media/platform/cadence/cdns-csi2tx.c
+++ b/drivers/media/platform/cadence/cdns-csi2tx.c
@@ -496,49 +496,44 @@ static int csi2tx_get_resources(struct csi2tx_priv *csi2tx,
 static int csi2tx_check_lanes(struct csi2tx_priv *csi2tx)
 {
 	struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 };
-	struct device_node *ep;
 	int ret, i;
-
-	ep = of_graph_get_endpoint_by_regs(csi2tx->dev->of_node, 0, 0);
+	struct device_node *ep __free(device_node) =
+		of_graph_get_endpoint_by_regs(csi2tx->dev->of_node, 0, 0);
+
 	if (!ep)
 		return -EINVAL;
 
 	ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), &v4l2_ep);
 	if (ret) {
 		dev_err(csi2tx->dev, "Could not parse v4l2 endpoint\n");
-		goto out;
+		return ret;
 	}
 
 	if (v4l2_ep.bus_type != V4L2_MBUS_CSI2_DPHY) {
 		dev_err(csi2tx->dev, "Unsupported media bus type: 0x%x\n",
 			v4l2_ep.bus_type);
-		ret = -EINVAL;
-		goto out;
+		return -EINVAL;
 	}
 
 	csi2tx->num_lanes = v4l2_ep.bus.mipi_csi2.num_data_lanes;
 	if (csi2tx->num_lanes > csi2tx->max_lanes) {
 		dev_err(csi2tx->dev,
 			"Current configuration uses more lanes than supported\n");
-		ret = -EINVAL;
-		goto out;
+		return -EINVAL;
 	}
 
 	for (i = 0; i < csi2tx->num_lanes; i++) {
 		if (v4l2_ep.bus.mipi_csi2.data_lanes[i] < 1) {
 			dev_err(csi2tx->dev, "Invalid lane[%d] number: %u\n",
 				i, v4l2_ep.bus.mipi_csi2.data_lanes[i]);
-			ret = -EINVAL;
-			goto out;
+			return -EINVAL;
 		}
 	}
 
 	memcpy(csi2tx->lanes, v4l2_ep.bus.mipi_csi2.data_lanes,
 	       sizeof(csi2tx->lanes));
 
-out:
-	of_node_put(ep);
-	return ret;
+	return 0;
 }
 
 static const struct csi2tx_vops csi2tx_vops = {
-- 
2.34.1


                 reply	other threads:[~2024-05-01  4:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240501040123.7327-1-prosunofficial@gmail.com \
    --to=prosunofficial@gmail.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=julia.lawall@inria.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mripard@kernel.org \
    --cc=skhan@linuxfoundation.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).