Skip to content

Commit 1ab0b9a

Browse files
javiercarrascocruzgregkh
authored andcommitted
usb: typec: use cleanup facility for 'altmodes_node'
Use the __free() macro for 'altmodes_node' to automatically release the node when it goes out of scope, removing the need for explicit calls to fwnode_handle_put(). Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20241021-typec-class-fwnode_handle_put-v2-2-3281225d3d27@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9581acb commit 1ab0b9a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/usb/typec/class.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,15 +2293,17 @@ void typec_port_register_altmodes(struct typec_port *port,
22932293
const struct typec_altmode_ops *ops, void *drvdata,
22942294
struct typec_altmode **altmodes, size_t n)
22952295
{
2296-
struct fwnode_handle *altmodes_node, *child;
2296+
struct fwnode_handle *child;
22972297
struct typec_altmode_desc desc;
22982298
struct typec_altmode *alt;
22992299
size_t index = 0;
23002300
u16 svid;
23012301
u32 vdo;
23022302
int ret;
23032303

2304-
altmodes_node = device_get_named_child_node(&port->dev, "altmodes");
2304+
struct fwnode_handle *altmodes_node __free(fwnode_handle) =
2305+
device_get_named_child_node(&port->dev, "altmodes");
2306+
23052307
if (!altmodes_node)
23062308
return; /* No altmodes specified */
23072309

@@ -2341,7 +2343,6 @@ void typec_port_register_altmodes(struct typec_port *port,
23412343
altmodes[index] = alt;
23422344
index++;
23432345
}
2344-
fwnode_handle_put(altmodes_node);
23452346
}
23462347
EXPORT_SYMBOL_GPL(typec_port_register_altmodes);
23472348

0 commit comments

Comments
 (0)