diff mbox series

iio:dac:ad3552r: Fix an IS_ERR() vs NULL check

Message ID 20220404114244.GA19201@kili (mailing list archive)
State Accepted
Headers show
Series iio:dac:ad3552r: Fix an IS_ERR() vs NULL check | expand

Commit Message

Dan Carpenter April 4, 2022, 11:42 a.m. UTC
The fwnode_get_named_child_node() function does not return error
pointers.  It returns NULL.  Update the check accordingly.

Fixes: 8f2b54824b28 ("drivers:iio:dac: Add AD3552R driver support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/iio/dac/ad3552r.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Nuno Sa April 4, 2022, 12:34 p.m. UTC | #1
> From: Dan Carpenter <dan.carpenter@oracle.com>
> Sent: Monday, April 4, 2022 1:43 PM
> To: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Hennerich, Michael <Michael.Hennerich@analog.com>; Jonathan
> Cameron <jic23@kernel.org>; linux-iio@vger.kernel.org; Sa, Nuno
> <Nuno.Sa@analog.com>; kernel-janitors@vger.kernel.org
> Subject: [PATCH] iio:dac:ad3552r: Fix an IS_ERR() vs NULL check
> 
> [External]
> 
> The fwnode_get_named_child_node() function does not return error
> pointers.  It returns NULL.  Update the check accordingly.
> 
> Fixes: 8f2b54824b28 ("drivers:iio:dac: Add AD3552R driver support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---

Reviewed-by: Nuno Sá <nuno.sa@analog.com>

>  drivers/iio/dac/ad3552r.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad3552r.c b/drivers/iio/dac/ad3552r.c
> index 97f13c0b9631..59f49b7564b2 100644
> --- a/drivers/iio/dac/ad3552r.c
> +++ b/drivers/iio/dac/ad3552r.c
> @@ -809,10 +809,10 @@ static int
> ad3552r_configure_custom_gain(struct ad3552r_desc *dac,
> 
>  	gain_child = fwnode_get_named_child_node(child,
>  						 "custom-output-range-
> config");
> -	if (IS_ERR(gain_child)) {
> +	if (!gain_child) {
>  		dev_err(dev,
>  			"mandatory custom-output-range-config
> property missing\n");
> -		return PTR_ERR(gain_child);
> +		return -EINVAL;
>  	}
> 
>  	dac->ch_data[ch].range_override = 1;
> --
> 2.20.1
Jonathan Cameron April 10, 2022, 4:57 p.m. UTC | #2
On Mon, 4 Apr 2022 12:34:25 +0000
"Sa, Nuno" <Nuno.Sa@analog.com> wrote:

> > From: Dan Carpenter <dan.carpenter@oracle.com>
> > Sent: Monday, April 4, 2022 1:43 PM
> > To: Lars-Peter Clausen <lars@metafoo.de>
> > Cc: Hennerich, Michael <Michael.Hennerich@analog.com>; Jonathan
> > Cameron <jic23@kernel.org>; linux-iio@vger.kernel.org; Sa, Nuno
> > <Nuno.Sa@analog.com>; kernel-janitors@vger.kernel.org
> > Subject: [PATCH] iio:dac:ad3552r: Fix an IS_ERR() vs NULL check
> > 
> > [External]
> > 
> > The fwnode_get_named_child_node() function does not return error
> > pointers.  It returns NULL.  Update the check accordingly.
> > 
> > Fixes: 8f2b54824b28 ("drivers:iio:dac: Add AD3552R driver support")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---  
> 
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

> 
> >  drivers/iio/dac/ad3552r.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iio/dac/ad3552r.c b/drivers/iio/dac/ad3552r.c
> > index 97f13c0b9631..59f49b7564b2 100644
> > --- a/drivers/iio/dac/ad3552r.c
> > +++ b/drivers/iio/dac/ad3552r.c
> > @@ -809,10 +809,10 @@ static int
> > ad3552r_configure_custom_gain(struct ad3552r_desc *dac,
> > 
> >  	gain_child = fwnode_get_named_child_node(child,
> >  						 "custom-output-range-
> > config");
> > -	if (IS_ERR(gain_child)) {
> > +	if (!gain_child) {
> >  		dev_err(dev,
> >  			"mandatory custom-output-range-config
> > property missing\n");
> > -		return PTR_ERR(gain_child);
> > +		return -EINVAL;
> >  	}
> > 
> >  	dac->ch_data[ch].range_override = 1;
> > --
> > 2.20.1  
>
diff mbox series

Patch

diff --git a/drivers/iio/dac/ad3552r.c b/drivers/iio/dac/ad3552r.c
index 97f13c0b9631..59f49b7564b2 100644
--- a/drivers/iio/dac/ad3552r.c
+++ b/drivers/iio/dac/ad3552r.c
@@ -809,10 +809,10 @@  static int ad3552r_configure_custom_gain(struct ad3552r_desc *dac,
 
 	gain_child = fwnode_get_named_child_node(child,
 						 "custom-output-range-config");
-	if (IS_ERR(gain_child)) {
+	if (!gain_child) {
 		dev_err(dev,
 			"mandatory custom-output-range-config property missing\n");
-		return PTR_ERR(gain_child);
+		return -EINVAL;
 	}
 
 	dac->ch_data[ch].range_override = 1;