All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: arizona: Add sensible return value to some error paths
@ 2016-08-12  9:27 Charles Keepax
  2016-08-31  8:43 ` Lee Jones
  0 siblings, 1 reply; 3+ messages in thread
From: Charles Keepax @ 2016-08-12  9:27 UTC (permalink / raw)
  To: lee.jones; +Cc: linux-kernel, patches

There are some cases in arizona_dev_init, such as where we don't
recognise the chip ID, in which we head to the error path without
setting a sensible error code in ret. This would lead to the chip
silently failing probe, as it would still return 0. Fix this up by
adding appropriate sets of the return value.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/mfd/arizona-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index e4f97b3..34a2c26 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -1121,6 +1121,7 @@ int arizona_dev_init(struct arizona *arizona)
 		break;
 	default:
 		dev_err(arizona->dev, "Unknown device ID: %x\n", reg);
+		ret = -EINVAL;
 		goto err_reset;
 	}
 
@@ -1280,12 +1281,14 @@ int arizona_dev_init(struct arizona *arizona)
 		break;
 	default:
 		dev_err(arizona->dev, "Unknown device ID %x\n", reg);
+		ret = -EINVAL;
 		goto err_reset;
 	}
 
 	if (!subdevs) {
 		dev_err(arizona->dev,
 			"No kernel support for device ID %x\n", reg);
+		ret = -EINVAL;
 		goto err_reset;
 	}
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mfd: arizona: Add sensible return value to some error paths
  2016-08-12  9:27 [PATCH] mfd: arizona: Add sensible return value to some error paths Charles Keepax
@ 2016-08-31  8:43 ` Lee Jones
  2016-08-31  9:13   ` Charles Keepax
  0 siblings, 1 reply; 3+ messages in thread
From: Lee Jones @ 2016-08-31  8:43 UTC (permalink / raw)
  To: Charles Keepax; +Cc: linux-kernel, patches

On Fri, 12 Aug 2016, Charles Keepax wrote:

> There are some cases in arizona_dev_init, such as where we don't
> recognise the chip ID, in which we head to the error path without
> setting a sensible error code in ret. This would lead to the chip
> silently failing probe, as it would still return 0. Fix this up by
> adding appropriate sets of the return value.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/arizona-core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index e4f97b3..34a2c26 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -1121,6 +1121,7 @@ int arizona_dev_init(struct arizona *arizona)
>  		break;
>  	default:
>  		dev_err(arizona->dev, "Unknown device ID: %x\n", reg);
> +		ret = -EINVAL;

-EINVAL doesn't seem right here.

-ENODEV perhaps?

>  		goto err_reset;
>  	}
>  
> @@ -1280,12 +1281,14 @@ int arizona_dev_init(struct arizona *arizona)
>  		break;
>  	default:
>  		dev_err(arizona->dev, "Unknown device ID %x\n", reg);
> +		ret = -EINVAL;
>  		goto err_reset;
>  	}
>  
>  	if (!subdevs) {
>  		dev_err(arizona->dev,
>  			"No kernel support for device ID %x\n", reg);
> +		ret = -EINVAL;
>  		goto err_reset;
>  	}
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mfd: arizona: Add sensible return value to some error paths
  2016-08-31  8:43 ` Lee Jones
@ 2016-08-31  9:13   ` Charles Keepax
  0 siblings, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2016-08-31  9:13 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, patches

On Wed, Aug 31, 2016 at 09:43:27AM +0100, Lee Jones wrote:
> On Fri, 12 Aug 2016, Charles Keepax wrote:
> 
> > There are some cases in arizona_dev_init, such as where we don't
> > recognise the chip ID, in which we head to the error path without
> > setting a sensible error code in ret. This would lead to the chip
> > silently failing probe, as it would still return 0. Fix this up by
> > adding appropriate sets of the return value.
> > 
> > Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> > ---
> >  drivers/mfd/arizona-core.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> > index e4f97b3..34a2c26 100644
> > --- a/drivers/mfd/arizona-core.c
> > +++ b/drivers/mfd/arizona-core.c
> > @@ -1121,6 +1121,7 @@ int arizona_dev_init(struct arizona *arizona)
> >  		break;
> >  	default:
> >  		dev_err(arizona->dev, "Unknown device ID: %x\n", reg);
> > +		ret = -EINVAL;
> 
> -EINVAL doesn't seem right here.
> 
> -ENODEV perhaps?
> 

Yeah that does seem better, I will fire out another version.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-31  9:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-12  9:27 [PATCH] mfd: arizona: Add sensible return value to some error paths Charles Keepax
2016-08-31  8:43 ` Lee Jones
2016-08-31  9:13   ` Charles Keepax

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.