linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff LaBundy <jeff@labundy.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: robh+dt@kernel.org, linux-input@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH 02/11] Input: iqs7222 - report malformed properties
Date: Thu, 8 Sep 2022 21:08:09 -0500	[thread overview]
Message-ID: <20220909020809.GB3306@nixie71> (raw)
In-Reply-To: <YxpcyY0BAumyaeVR@google.com>

Hi Dmitry,

On Thu, Sep 08, 2022 at 02:21:13PM -0700, Dmitry Torokhov wrote:
> On Thu, Sep 08, 2022 at 08:15:39AM -0500, Jeff LaBundy wrote:
> > Nonzero return values of several calls to fwnode_property_read_u32()
> > are silenty ignored, leaving no way to know that the properties were
> > not applied in the event of an error.
> > 
> > To solve this problem, follow the design pattern used throughout the
> > rest of the driver by first checking if the property is present, and
> > then evaluating the return value of fwnode_property_read_u32().
> > 
> > Fixes: e505edaedcb9 ("Input: add support for Azoteq IQS7222A/B/C")
> > Signed-off-by: Jeff LaBundy <jeff@labundy.com>
> > ---
> >  drivers/input/misc/iqs7222.c | 65 ++++++++++++++++++++++++++++++------
> >  1 file changed, 55 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/input/misc/iqs7222.c b/drivers/input/misc/iqs7222.c
> > index 04c1050d845c..fdade24caa8a 100644
> > --- a/drivers/input/misc/iqs7222.c
> > +++ b/drivers/input/misc/iqs7222.c
> > @@ -1819,8 +1819,17 @@ static int iqs7222_parse_chan(struct iqs7222_private *iqs7222, int chan_index)
> >  		chan_setup[0] |= IQS7222_CHAN_SETUP_0_REF_MODE_FOLLOW;
> >  		chan_setup[4] = val * 42 + 1048;
> >  
> > -		if (!fwnode_property_read_u32(chan_node, "azoteq,ref-weight",
> > -					      &val)) {
> > +		if (fwnode_property_present(chan_node, "azoteq,ref-weight")) {
> > +			error = fwnode_property_read_u32(chan_node,
> > +							 "azoteq,ref-weight",
> > +							 &val);
> 
> fwnode_property_read_u32() returns EINVAL if property is missing, so
> maybe have:
> 
> 		error = fwnode_property_read_u32(chan_node,
> 						 "azoteq,ref-weight", &val);
> 		if (!error) {
> 			...
> 		} else {
> 			if (error != -EINVAL) {
> 				dev_err(&client->dev,
> 					"Failed to read %s reference weight: %d\n",
> 					fwnode_get_name(chan_node), error);
> 				goto put_chan_node;
> 			}
> 		}
> 
> to avoid double calls into property handling code?

That's a better idea; I can fold this into the helper functions proposed
for the previous patch too.

> 
> -- 
> Dmitry

Kind regards,
Jeff LaBundy

  reply	other threads:[~2022-09-09  2:08 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08 13:15 [PATCH 00/11] Additional fixes for Azoteq IQS7222A/B/C Jeff LaBundy
2022-09-08 13:15 ` [PATCH 01/11] Input: iqs7222 - drop unused device node references Jeff LaBundy
2022-09-08 21:17   ` Dmitry Torokhov
2022-09-09  2:04     ` Jeff LaBundy
2022-09-09  4:37       ` Dmitry Torokhov
2022-09-10  0:00         ` Jeff LaBundy
2022-09-08 13:15 ` [PATCH 02/11] Input: iqs7222 - report malformed properties Jeff LaBundy
2022-09-08 21:21   ` Dmitry Torokhov
2022-09-09  2:08     ` Jeff LaBundy [this message]
2022-09-09  4:42       ` Dmitry Torokhov
2022-09-10  0:04         ` Jeff LaBundy
2022-09-08 13:15 ` [PATCH 03/11] dt-bindings: input: iqs7222: Correct minimum slider size Jeff LaBundy
2022-09-13 11:37   ` Rob Herring
2022-09-08 13:15 ` [PATCH 04/11] Input: iqs7222 - protect against undefined " Jeff LaBundy
2022-09-08 13:15 ` [PATCH 05/11] Input: iqs7222 - trim force communication command Jeff LaBundy
2022-09-08 21:24   ` Dmitry Torokhov
2022-09-13 21:24     ` Jeff LaBundy
2022-09-14 10:10       ` Dmitry Torokhov
2022-09-08 13:15 ` [PATCH 06/11] Input: iqs7222 - avoid sending empty SYN_REPORT events Jeff LaBundy
2022-09-14 10:10   ` Dmitry Torokhov
2022-09-08 13:15 ` [PATCH 07/11] Input: iqs7222 - set all ULP entry masks by default Jeff LaBundy
2022-09-14 10:10   ` Dmitry Torokhov
2022-09-08 13:15 ` [PATCH 08/11] Input: iqs7222 - allow 'linux,code' to be optional Jeff LaBundy
2022-09-08 13:15 ` [PATCH 09/11] dt-bindings: input: iqs7222: Allow " Jeff LaBundy
2022-09-13 11:42   ` Rob Herring
2022-09-13 13:47     ` Jeff LaBundy
2022-09-08 13:15 ` [PATCH 10/11] dt-bindings: input: iqs7222: Add support for IQS7222A v1.13+ Jeff LaBundy
2022-09-13 11:44   ` Rob Herring
2022-09-08 13:15 ` [PATCH 11/11] Input: iqs7222 - add " Jeff LaBundy

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=20220909020809.GB3306@nixie71 \
    --to=jeff@labundy.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).