public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: anx7411: Use scope-based resource management in anx7411_typec_port_probe()
@ 2024-06-05 17:11 Markus Elfring
  2024-06-06  7:50 ` Heikki Krogerus
  2024-06-06  9:17 ` [PATCH] " Jonathan Cameron
  0 siblings, 2 replies; 6+ messages in thread
From: Markus Elfring @ 2024-06-05 17:11 UTC (permalink / raw)
  To: linux-usb, kernel-janitors, Greg Kroah-Hartman, Heikki Krogerus,
	Xin Ji
  Cc: LKML, Jonathan Cameron

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Jun 2024 18:56:19 +0200

Scope-based resource management became supported also for another
programming interface by contributions of Jonathan Cameron on 2024-02-17.
See also the commit 59ed5e2d505bf5f9b4af64d0021cd0c96aec1f7c ("device
property: Add cleanup.h based fwnode_handle_put() scope based cleanup.").

* Thus use the attribute “__free(fwnode_handle)”.

* Reduce the scope for the local variable “fwnode”.

Fixes: fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/typec/anx7411.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
index b12a07edc71b..9fb52f233a30 100644
--- a/drivers/usb/typec/anx7411.c
+++ b/drivers/usb/typec/anx7411.c
@@ -16,6 +16,7 @@
 #include <linux/of_graph.h>
 #include <linux/of_platform.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 #include <linux/types.h>
@@ -1142,11 +1143,11 @@ static int anx7411_typec_port_probe(struct anx7411_data *ctx,
 {
 	struct typec_capability *cap = &ctx->typec.caps;
 	struct typec_params *typecp = &ctx->typec;
-	struct fwnode_handle *fwnode;
 	const char *buf;
 	int ret, i;

-	fwnode = device_get_named_child_node(dev, "connector");
+	struct fwnode_handle *fwnode __free(fwnode_handle)
+				     = device_get_named_child_node(dev, "connector");
 	if (!fwnode)
 		return -EINVAL;

@@ -1237,7 +1238,7 @@ static int anx7411_typec_port_probe(struct anx7411_data *ctx,
 		typecp->caps_flags |= HAS_SINK_WATT;
 	}

-	cap->fwnode = fwnode;
+	cap->fwnode = no_free_ptr(fwnode);

 	ctx->typec.role_sw = usb_role_switch_get(dev);
 	if (IS_ERR(ctx->typec.role_sw)) {
--
2.45.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-06-28  7:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-05 17:11 [PATCH] usb: typec: anx7411: Use scope-based resource management in anx7411_typec_port_probe() Markus Elfring
2024-06-06  7:50 ` Heikki Krogerus
2024-06-06  8:40   ` Markus Elfring
2024-06-06  9:17 ` [PATCH] " Jonathan Cameron
2024-06-06 11:01   ` Markus Elfring
2024-06-28  7:26   ` [PATCH 2] " Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox