power:lp8727_charger: parsing child node after getting debounce-ms
authorMilo Kim <milo.kim@ti.com>
Tue, 25 Aug 2015 06:07:08 +0000 (15:07 +0900)
committerSebastian Reichel <sre@kernel.org>
Tue, 22 Sep 2015 11:35:29 +0000 (13:35 +0200)
According to lp8727 bindings[*], charging parameter is optional.
So parsing can be skipped in case those properties are undefined.
However, 'debounce-ms' should be read prior to checking the properties.
Otherwise, 'debounce-ms' property will be ignored even it is configured
inside the DT.
So, counting child is processed after updating 'debounce-ms'.

[*] Documentation/devicetree/bindings/power_supply/lp8727_charger.txt

Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Milo Kim <milo.kim@ti.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
drivers/power/lp8727_charger.c

index 30dc265435ee2457f04821590b94ca5c834d74d5..042fb3dacb461d460817093f61b6b69dc6b62a1d 100644 (file)
@@ -515,16 +515,16 @@ static struct lp8727_platform_data *lp8727_parse_dt(struct device *dev)
        struct lp8727_platform_data *pdata;
        const char *type;
 
-       /* If charging parameter is not defined, just skip parsing the dt */
-       if (of_get_child_count(np) == 0)
-               return NULL;
-
        pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
        if (!pdata)
                return ERR_PTR(-ENOMEM);
 
        of_property_read_u32(np, "debounce-ms", &pdata->debounce_msec);
 
+       /* If charging parameter is not defined, just skip parsing the dt */
+       if (of_get_child_count(np) == 0)
+               return pdata;
+
        for_each_child_of_node(np, child) {
                of_property_read_string(child, "charger-type", &type);