2013-05-24 17:41:51

by Axel Lin

[permalink] [raw]
Subject: [PATCH] power_supply: generic-adc-battery: Fix checking if none of the channels are supported

If none of the channels are supported, index is 0.
Also ensure to return error code instead of 0 in goto second_mem_fail path.

Signed-off-by: Axel Lin <[email protected]>
---
drivers/power/generic-adc-battery.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/power/generic-adc-battery.c b/drivers/power/generic-adc-battery.c
index 8cb5d7f..59a1421 100644
--- a/drivers/power/generic-adc-battery.c
+++ b/drivers/power/generic-adc-battery.c
@@ -299,8 +299,10 @@ static int gab_probe(struct platform_device *pdev)
}

/* none of the channels are supported so let's bail out */
- if (index == ARRAY_SIZE(gab_chan_name))
+ if (index == 0) {
+ ret = -ENODEV;
goto second_mem_fail;
+ }

/*
* Total number of properties is equal to static properties
--
1.8.1.2



2013-05-28 06:27:39

by anish singh

[permalink] [raw]
Subject: Re: [PATCH] power_supply: generic-adc-battery: Fix checking if none of the channels are supported

On Fri, May 24, 2013 at 11:11 PM, Axel Lin <[email protected]> wrote:
> If none of the channels are supported, index is 0.
> Also ensure to return error code instead of 0 in goto second_mem_fail path.
>
> Signed-off-by: Axel Lin <[email protected]>
Acked-by: anish kumar <[email protected]>

I think anton would have already picked up.
> ---
> drivers/power/generic-adc-battery.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/power/generic-adc-battery.c b/drivers/power/generic-adc-battery.c
> index 8cb5d7f..59a1421 100644
> --- a/drivers/power/generic-adc-battery.c
> +++ b/drivers/power/generic-adc-battery.c
> @@ -299,8 +299,10 @@ static int gab_probe(struct platform_device *pdev)
> }
>
> /* none of the channels are supported so let's bail out */
> - if (index == ARRAY_SIZE(gab_chan_name))
> + if (index == 0) {
> + ret = -ENODEV;
> goto second_mem_fail;
> + }
>
> /*
> * Total number of properties is equal to static properties
> --
> 1.8.1.2
>
>
>

2013-06-07 00:38:43

by Anton Vorontsov

[permalink] [raw]
Subject: Re: [PATCH] power_supply: generic-adc-battery: Fix checking if none of the channels are supported

On Tue, May 28, 2013 at 11:57:37AM +0530, anish singh wrote:
> On Fri, May 24, 2013 at 11:11 PM, Axel Lin <[email protected]> wrote:
> > If none of the channels are supported, index is 0.
> > Also ensure to return error code instead of 0 in goto second_mem_fail path.
> >
> > Signed-off-by: Axel Lin <[email protected]>
> Acked-by: anish kumar <[email protected]>

Applied, thanks!

Anton