mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Hans de Goede <hdegoede@redhat.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] usb: typec: use cleanup facility for 'altmodes_node'
Date: Tue, 22 Oct 2024 17:12:45 +0300	[thread overview]
Message-ID: <Zxey3Y9YkFATfwB2@kuha.fi.intel.com> (raw)
In-Reply-To: <20241021-typec-class-fwnode_handle_put-v2-2-3281225d3d27@gmail.com>

On Mon, Oct 21, 2024 at 10:45:30PM +0200, Javier Carrasco wrote:
> 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>

> ---
>  drivers/usb/typec/class.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 1eb240604cf6..58f40156de56 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -2293,7 +2293,7 @@ void typec_port_register_altmodes(struct typec_port *port,
>  	const struct typec_altmode_ops *ops, void *drvdata,
>  	struct typec_altmode **altmodes, size_t n)
>  {
> -	struct fwnode_handle *altmodes_node, *child;
> +	struct fwnode_handle *child;
>  	struct typec_altmode_desc desc;
>  	struct typec_altmode *alt;
>  	size_t index = 0;
> @@ -2301,7 +2301,9 @@ void typec_port_register_altmodes(struct typec_port *port,
>  	u32 vdo;
>  	int ret;
>  
> -	altmodes_node = device_get_named_child_node(&port->dev, "altmodes");
> +	struct fwnode_handle *altmodes_node  __free(fwnode_handle) =
> +		device_get_named_child_node(&port->dev, "altmodes");
> +
>  	if (!altmodes_node)
>  		return; /* No altmodes specified */
>  
> @@ -2341,7 +2343,6 @@ void typec_port_register_altmodes(struct typec_port *port,
>  		altmodes[index] = alt;
>  		index++;
>  	}
> -	fwnode_handle_put(altmodes_node);
>  }
>  EXPORT_SYMBOL_GPL(typec_port_register_altmodes);
>  

-- 
heikki

      reply	other threads:[~2024-10-22 14:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-21 20:45 [PATCH v2 0/2] usb: typec: fix unreleased fwnode_handle in typec_port_register_altmodes() Javier Carrasco
2024-10-21 20:45 ` [PATCH v2 1/2] " Javier Carrasco
2024-10-21 20:45 ` [PATCH v2 2/2] usb: typec: use cleanup facility for 'altmodes_node' Javier Carrasco
2024-10-22 14:12   ` Heikki Krogerus [this message]

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=Zxey3Y9YkFATfwB2@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.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

all inboxes | Powered by JetHome®