Re: [PATCH 02/11] Input: iqs7222 - report malformed properties

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
> ---
>  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?

-- 
Dmitry



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux