All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff LaBundy <jeff@labundy.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org,
	Michael Hennerich <michael.hennerich@analog.com>,
	Ville Syrjala <syrjala@sci.fi>,
	Support Opensource <support.opensource@diasemi.com>,
	Eddie James <eajames@linux.ibm.com>,
	Andrey Moiseev <o2g.org.ru@gmail.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Javier Carrasco <javier.carrasco.cruz@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 15/22] Input: iqs7222 - use cleanup facility for fwnodes
Date: Sun, 8 Sep 2024 19:12:10 -0500	[thread overview]
Message-ID: <Zt49WnZBar2D822M@nixie71> (raw)
In-Reply-To: <20240904044825.1048256-1-dmitry.torokhov@gmail.com>

Hi Dmitry,

On Tue, Sep 03, 2024 at 09:48:25PM -0700, Dmitry Torokhov wrote:
> Use __free(fwnode_handle) cleanup facility to ensure that references to
> acquired fwnodes are dropped at appropriate times automatically.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/misc/iqs7222.c | 30 ++++++++++++++----------------
>  1 file changed, 14 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/input/misc/iqs7222.c b/drivers/input/misc/iqs7222.c
> index 9ca5a743f19f..d9b87606ff7a 100644
> --- a/drivers/input/misc/iqs7222.c
> +++ b/drivers/input/misc/iqs7222.c
> @@ -2385,9 +2385,9 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222,
>  	for (i = 0; i < ARRAY_SIZE(iqs7222_kp_events); i++) {
>  		const char *event_name = iqs7222_kp_events[i].name;
>  		u16 event_enable = iqs7222_kp_events[i].enable;
> -		struct fwnode_handle *event_node;
>  
> -		event_node = fwnode_get_named_child_node(chan_node, event_name);
> +		struct fwnode_handle *event_node __free(fwnode_handle) =
> +			fwnode_get_named_child_node(chan_node, event_name);

This leaves a newline amongst the declarations, but not in between the
declarations and code. I don't feel strongly against this, but it's
opposite of what I understand to be more common; please let me know in
case I have misunderstood. This comment applies to the other chunks as
well.

>  		if (!event_node)
>  			continue;
>  
> @@ -2408,7 +2408,6 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222,
>  				dev_err(&client->dev,
>  					"Invalid %s press timeout: %u\n",
>  					fwnode_get_name(event_node), val);
> -				fwnode_handle_put(event_node);
>  				return -EINVAL;
>  			}
>  
> @@ -2418,7 +2417,6 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222,
>  			dev_err(&client->dev,
>  				"Failed to read %s press timeout: %d\n",
>  				fwnode_get_name(event_node), error);
> -			fwnode_handle_put(event_node);
>  			return error;
>  		}
>  
> @@ -2429,7 +2427,6 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222,
>  					    dev_desc->touch_link - (i ? 0 : 2),
>  					    &iqs7222->kp_type[chan_index][i],
>  					    &iqs7222->kp_code[chan_index][i]);
> -		fwnode_handle_put(event_node);
>  		if (error)
>  			return error;
>  
> @@ -2604,10 +2601,10 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222,
>  
>  	for (i = 0; i < ARRAY_SIZE(iqs7222_sl_events); i++) {
>  		const char *event_name = iqs7222_sl_events[i].name;
> -		struct fwnode_handle *event_node;
>  		enum iqs7222_reg_key_id reg_key;
>  
> -		event_node = fwnode_get_named_child_node(sldr_node, event_name);
> +		struct fwnode_handle *event_node __free(fwnode_handle) =
> +			fwnode_get_named_child_node(sldr_node, event_name);
>  		if (!event_node)
>  			continue;
>  
> @@ -2639,7 +2636,6 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222,
>  					      : sldr_setup[4 + reg_offset],
>  					    NULL,
>  					    &iqs7222->sl_code[sldr_index][i]);
> -		fwnode_handle_put(event_node);
>  		if (error)
>  			return error;
>  
> @@ -2742,9 +2738,9 @@ static int iqs7222_parse_tpad(struct iqs7222_private *iqs7222,
>  
>  	for (i = 0; i < ARRAY_SIZE(iqs7222_tp_events); i++) {
>  		const char *event_name = iqs7222_tp_events[i].name;
> -		struct fwnode_handle *event_node;
>  
> -		event_node = fwnode_get_named_child_node(tpad_node, event_name);
> +		struct fwnode_handle *event_node __free(fwnode_handle) =
> +			fwnode_get_named_child_node(tpad_node, event_name);
>  		if (!event_node)
>  			continue;
>  
> @@ -2760,7 +2756,6 @@ static int iqs7222_parse_tpad(struct iqs7222_private *iqs7222,
>  					    iqs7222_tp_events[i].link, 1566,
>  					    NULL,
>  					    &iqs7222->tp_code[i]);
> -		fwnode_handle_put(event_node);
>  		if (error)
>  			return error;
>  
> @@ -2818,9 +2813,9 @@ static int iqs7222_parse_reg_grp(struct iqs7222_private *iqs7222,
>  				 int reg_grp_index)
>  {
>  	struct i2c_client *client = iqs7222->client;
> -	struct fwnode_handle *reg_grp_node;
>  	int error;
>  
> +	struct fwnode_handle *reg_grp_node __free(fwnode_handle) = NULL;
>  	if (iqs7222_reg_grp_names[reg_grp]) {
>  		char reg_grp_name[16];
>  
> @@ -2838,14 +2833,17 @@ static int iqs7222_parse_reg_grp(struct iqs7222_private *iqs7222,
>  
>  	error = iqs7222_parse_props(iqs7222, reg_grp_node, reg_grp_index,
>  				    reg_grp, IQS7222_REG_KEY_NONE);
> +	if (error)
> +		return error;
>  
> -	if (!error && iqs7222_parse_extra[reg_grp])
> +	if (iqs7222_parse_extra[reg_grp]) {
>  		error = iqs7222_parse_extra[reg_grp](iqs7222, reg_grp_node,
>  						     reg_grp_index);
> +		if (error)
> +			return error;
> +	}
>  
> -	fwnode_handle_put(reg_grp_node);
> -
> -	return error;
> +	return 0;
>  }
>  
>  static int iqs7222_parse_all(struct iqs7222_private *iqs7222)
> -- 
> 2.46.0.469.g59c65b2a67-goog
> 

Kind regards,
Jeff LaBundy

  parent reply	other threads:[~2024-09-09  0:12 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-04  4:42 [PATCH 00/22] Convert misc input drivers to use new cleanup facilities Dmitry Torokhov
2024-09-04  4:42 ` [PATCH 01/22] Input: ad714x - use guard notation when acquiring mutex Dmitry Torokhov
2024-09-04 18:47   ` Javier Carrasco
2024-09-04  4:42 ` [PATCH 02/22] Input: ati_remote2 " Dmitry Torokhov
2024-09-04 18:49   ` Javier Carrasco
2024-09-04  4:42 ` [PATCH 03/22] Input: cm109 - use guard notation when acquiring mutex and spinlock Dmitry Torokhov
2024-09-04 19:44   ` Javier Carrasco
2024-09-04  4:42 ` [PATCH 04/22] Input: cma3000_d0x - use guard notation when acquiring mutex Dmitry Torokhov
2024-09-04 18:51   ` Javier Carrasco
2024-09-04  4:42 ` [PATCH 05/22] Input: da7280 - use guard notation when acquiring mutex and spinlock Dmitry Torokhov
2024-09-04 19:02   ` Javier Carrasco
2024-09-04  4:42 ` [PATCH 06/22] Input: kxtj9 - use guard notation when acquiring mutex/disabling irq Dmitry Torokhov
2024-09-04 19:03   ` Javier Carrasco
2024-09-04  4:42 ` [PATCH 07/22] Input: drv260x - use guard notation when acquiring mutex Dmitry Torokhov
2024-09-04 19:05   ` Javier Carrasco
2024-09-04  4:42 ` [PATCH 08/22] Input: drv2665 " Dmitry Torokhov
2024-09-04 19:07   ` Javier Carrasco
2024-09-04  4:42 ` [PATCH 09/22] Input: drv2667 " Dmitry Torokhov
2024-09-04 19:08   ` Javier Carrasco
2024-09-04  4:42 ` [PATCH 10/22] Input: ideapad_slidebar - use guard notation when acquiring spinlock Dmitry Torokhov
2024-09-04 19:09   ` Javier Carrasco
2024-09-04  4:47 ` [PATCH 11/22] Input: ibm-panel " Dmitry Torokhov
2024-09-04 19:11   ` Javier Carrasco
2024-09-04 21:56   ` Eddie James
2024-09-04  4:47 ` [PATCH 12/22] Input: iqs269a - use guard notation when acquiring mutex Dmitry Torokhov
2024-09-04 13:53   ` Javier Carrasco
2024-09-04 18:21     ` Dmitry Torokhov
2024-09-04 18:41       ` Javier Carrasco
2024-09-04 18:53         ` Dmitry Torokhov
2024-09-08 22:05   ` Jeff LaBundy
2024-09-04  4:48 ` [PATCH 13/22] Input: iqs269a - use cleanup facility for fwnodes Dmitry Torokhov
2024-09-04 11:13   ` Javier Carrasco
2024-09-08 22:08   ` Jeff LaBundy
2024-09-04  4:48 ` [PATCH 14/22] Input: iqs626a " Dmitry Torokhov
2024-09-04 11:10   ` Javier Carrasco
2024-09-09  0:02   ` Jeff LaBundy
2024-09-09  1:31     ` Dmitry Torokhov
2024-09-10 15:12       ` Jeff LaBundy
2024-09-04  4:48 ` [PATCH 15/22] Input: iqs7222 " Dmitry Torokhov
2024-09-04 10:50   ` Javier Carrasco
2024-09-04 18:26     ` Dmitry Torokhov
2024-09-04 18:46       ` Javier Carrasco
2024-09-09  0:12   ` Jeff LaBundy [this message]
2024-09-09  1:34     ` Dmitry Torokhov
2024-09-10 15:14       ` Jeff LaBundy
2024-09-04  4:48 ` [PATCH 16/22] Input: max8997_haptic - use guard notation when acquiring mutex Dmitry Torokhov
2024-09-04 19:12   ` Javier Carrasco
2024-09-04  4:48 ` [PATCH 17/22] Input: pegasus_notetaker " Dmitry Torokhov
2024-09-04 19:52   ` Javier Carrasco
2024-09-04 20:59     ` [PATCH v2 " Dmitry Torokhov
2024-09-04  4:49 ` [PATCH 18/22] Input: powermate - use guard notation when acquiring spinlock Dmitry Torokhov
2024-09-04 19:16   ` Javier Carrasco
2024-09-04  4:49 ` [PATCH 19/22] Input: pwm-beeper " Dmitry Torokhov
2024-09-04 19:22   ` Javier Carrasco
2024-09-04  4:49 ` [PATCH 20/22] Input: regulator-haptic - use guard notation when acquiring mutex Dmitry Torokhov
2024-09-04 19:27   ` Javier Carrasco
2024-09-04 20:55     ` [PATCH v2 " Dmitry Torokhov
2024-09-04 21:41       ` Javier Carrasco
2024-09-07  3:40   ` [PATCH " kernel test robot
2024-09-04  4:49 ` [PATCH 21/22] Input: rotary_encoder " Dmitry Torokhov
2024-09-04 19:32   ` Javier Carrasco
2024-09-04  4:49 ` [PATCH 22/22] Input: sparcspkr - use guard notation when acquiring spinlock Dmitry Torokhov
2024-09-04 19:33   ` Javier Carrasco

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=Zt49WnZBar2D822M@nixie71 \
    --to=jeff@labundy.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=eajames@linux.ibm.com \
    --cc=hdegoede@redhat.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --cc=o2g.org.ru@gmail.com \
    --cc=support.opensource@diasemi.com \
    --cc=syrjala@sci.fi \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.