All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Jeff LaBundy <jeff@labundy.com>, dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, jeff@labundy.com
Subject: Re: [PATCH 1/5] Input: iqs269a - drop unused device node references
Date: Thu, 15 Dec 2022 10:31:27 +0100	[thread overview]
Message-ID: <87tu1xj9n4.fsf@baylibre.com> (raw)
In-Reply-To: <Y4V2OSN35Yio9JN/@nixie71>

On Mon, Nov 28, 2022 at 21:02, Jeff LaBundy <jeff@labundy.com> wrote:

> Each call to device/fwnode_get_named_child_node() must be matched
> with a call to fwnode_handle_put() once the corresponding node is
> no longer in use. This ensures a reference count remains balanced
> in the case of dynamic device tree support.
>
> Currently, the driver does not call fwnode_handle_put() on nested
> event nodes. This patch solves this problem by adding the missing
> instances of fwnode_handle_put().
>
> As part of this change, the logic which parses each channel's key
> code is gently refactored in order to reduce the number of places
> from which fwnode_handle_put() is called.
>
> Fixes: 04e49867fad1 ("Input: add support for Azoteq IQS269A")
> Signed-off-by: Jeff LaBundy <jeff@labundy.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

> ---
>  drivers/input/misc/iqs269a.c | 24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/misc/iqs269a.c b/drivers/input/misc/iqs269a.c
> index a348247d3d38..5620a009bf55 100644
> --- a/drivers/input/misc/iqs269a.c
> +++ b/drivers/input/misc/iqs269a.c
> @@ -694,7 +694,8 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
>  				dev_err(&client->dev,
>  					"Invalid channel %u threshold: %u\n",
>  					reg, val);
> -				return -EINVAL;
> +				error = -EINVAL;
> +				break;
>  			}
>  
>  			ch_reg->thresh[iqs269_events[i].th_offs] = val;
> @@ -707,7 +708,8 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
>  				dev_err(&client->dev,
>  					"Invalid channel %u hysteresis: %u\n",
>  					reg, val);
> -				return -EINVAL;
> +				error = -EINVAL;
> +				break;
>  			}
>  
>  			if (i == IQS269_EVENT_DEEP_DN ||
> @@ -721,8 +723,19 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
>  			}
>  		}
>  
> -		if (fwnode_property_read_u32(ev_node, "linux,code", &val))
> +		error = fwnode_property_read_u32(ev_node, "linux,code", &val);
> +		if (error && error != -EINVAL) {
> +			dev_err(&client->dev,
> +				"Failed to read channel %u code: %d\n", reg,
> +				error);
> +			break;
> +		}
> +
> +		fwnode_handle_put(ev_node);
> +		if (error) {
> +			error = 0;
>  			continue;
> +		}
>  
>  		switch (reg) {
>  		case IQS269_CHx_HALL_ACTIVE:
> @@ -744,7 +757,10 @@ static int iqs269_parse_chan(struct iqs269_private *iqs269,
>  		iqs269->sys_reg.event_mask &= ~iqs269_events[i].mask;
>  	}
>  
> -	return 0;
> +	if (error)
> +		fwnode_handle_put(ev_node);
> +
> +	return error;
>  }
>  
>  static int iqs269_parse_prop(struct iqs269_private *iqs269)
> -- 
> 2.34.1

  reply	other threads:[~2022-12-15  9:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29  3:00 [PATCH 0/5] Miscellaneous fixes for Azoteq IQS269A Jeff LaBundy
2022-11-29  3:02 ` [PATCH 1/5] Input: iqs269a - drop unused device node references Jeff LaBundy
2022-12-15  9:31   ` Mattijs Korpershoek [this message]
2022-11-29  3:02 ` [PATCH 2/5] Input: iqs269a - increase interrupt handler return delay Jeff LaBundy
2022-12-15  9:32   ` Mattijs Korpershoek
2022-11-29  3:02 ` [PATCH 3/5] Input: iqs269a - configure device with a single block write Jeff LaBundy
2022-12-15  9:55   ` Mattijs Korpershoek
2022-11-29  3:02 ` [PATCH 4/5] Input: iqs269a - do not poll during suspend or resume Jeff LaBundy
2022-12-15 10:07   ` Mattijs Korpershoek
2022-11-29  3:03 ` [PATCH 5/5] Input: iqs269a - do not poll during ATI Jeff LaBundy
2022-12-15 10:22   ` Mattijs Korpershoek

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=87tu1xj9n4.fsf@baylibre.com \
    --to=mkorpershoek@baylibre.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jeff@labundy.com \
    --cc=linux-input@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 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.