power: supply: charger-manager: Make code more readable
authorBaolin Wang <baolin.wang@linaro.org>
Fri, 16 Nov 2018 11:01:11 +0000 (19:01 +0800)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Wed, 5 Dec 2018 20:25:44 +0000 (21:25 +0100)
Make code more readable.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/charger-manager.c

index a52bc77..dc0c9a6 100644 (file)
@@ -1520,19 +1520,19 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev)
        /* chargers */
        of_property_read_u32(np, "cm-num-chargers", &num_chgs);
        if (num_chgs) {
+               int i;
+
                /* Allocate empty bin at the tail of array */
                desc->psy_charger_stat = devm_kcalloc(dev,
                                                      num_chgs + 1,
                                                      sizeof(char *),
                                                      GFP_KERNEL);
-               if (desc->psy_charger_stat) {
-                       int i;
-                       for (i = 0; i < num_chgs; i++)
-                               of_property_read_string_index(np, "cm-chargers",
-                                               i, &desc->psy_charger_stat[i]);
-               } else {
+               if (!desc->psy_charger_stat)
                        return ERR_PTR(-ENOMEM);
-               }
+
+               for (i = 0; i < num_chgs; i++)
+                       of_property_read_string_index(np, "cm-chargers",
+                                                     i, &desc->psy_charger_stat[i]);
        }
 
        of_property_read_string(np, "cm-fuel-gauge", &desc->psy_fuel_gauge);