Skip to contentSkip to conversation

power_supply: generic-adc-battery: Fix checking if none of the channels are supported

PATCH Applied Axel Lin 3 participants 3 messages May 24, 2013 – Jun 7, 2013

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/power/generic-adc-battery.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/power/generic-adc-battery.c +3 -1
index 8cb5d7f..59a1421 100644
@@ -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
Signature · 1 line
1.8.1.2
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Axel Lin

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.

I think anton would have already picked up.

Quoted 25 lines
---
 drivers/power/generic-adc-battery.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/power/generic-adc-battery.c +3 -2
index 8cb5d7f..59a1421 100644
@@ -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