]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
power: bq2419x: correctly check for thermal profile data
authorLaxman Dewangan <ldewangan@nvidia.com>
Fri, 25 Apr 2014 10:40:12 +0000 (16:10 +0530)
committerMandar Padmawar <mpadmawar@nvidia.com>
Wed, 7 May 2014 08:16:45 +0000 (01:16 -0700)
The number of entry for temp range on DT node is counted
using of calls. If there is no entry then it returns -ve
error. Taking care of -ve returns on the entry count.

This will avoid the wrong error message as:
bq2419x 1-006b: voltage thermal profile is not correct

Change-Id: I573d392123c15241c521c3c3d80f988b8b1f25f7
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/401497
Reviewed-on: http://git-master/r/405641
GVS: Gerrit_Virtual_Submit

drivers/power/bq2419x-charger.c

index 057c2646fa14014da00c5905fa4b04742b5f5142..fad32702daef97c3ee3b3bbcb82e0fac74680068 100644 (file)
@@ -1299,6 +1299,7 @@ static struct bq2419x_platform_data *bq2419x_dt_parse(struct i2c_client *client)
        batt_reg_node = of_find_node_by_name(np, "charger");
        if (batt_reg_node) {
                int temp_range_len, chg_current_lim_len, chg_voltage_lim_len;
+               int count;
                int wdt_timeout;
                int chg_restart_time;
                int auto_recharge_time_power_off;
@@ -1408,27 +1409,32 @@ static struct bq2419x_platform_data *bq2419x_dt_parse(struct i2c_client *client)
                chg_pdata->tz_name = of_get_property(batt_reg_node,
                                                "ti,thermal-zone", NULL);
 
-               temp_range_len = of_property_count_u32(batt_reg_node,
-                                       "ti,temp-range");
-               chg_current_lim_len = of_property_count_u32(batt_reg_node,
+               count = of_property_count_u32(batt_reg_node, "ti,temp-range");
+               temp_range_len = (count > 0) ? count : 0;
+
+               count = of_property_count_u32(batt_reg_node,
                                        "ti,charge-current-limit");
-               if (!chg_current_lim_len)
-                       chg_current_lim_len = of_property_count_u32(batt_reg_node,
+               if (count <= 0)
+                       count = of_property_count_u32(batt_reg_node,
                                        "ti,charge-thermal-current-limit");
-               chg_voltage_lim_len = of_property_count_u32(batt_reg_node,
+               chg_current_lim_len = (count > 0) ? count : 0;
+
+               count = of_property_count_u32(batt_reg_node,
                                        "ti,charge-thermal-voltage-limit");
-               if (temp_range_len < 0)
+               chg_voltage_lim_len = (count > 0) ? count : 0;
+
+               if (!temp_range_len)
                        goto skip_therm_profile;
 
                if (temp_range_len != chg_current_lim_len) {
                        dev_info(&client->dev,
-                               "thermal profile data is not correct\n");
+                               "current thermal profile is not correct\n");
                        goto skip_therm_profile;
                }
 
                if (chg_voltage_lim_len && (temp_range_len != chg_voltage_lim_len)) {
                        dev_info(&client->dev,
-                               "thermal profile data is not correct\n");
+                               "voltage thermal profile is not correct\n");
                        goto skip_therm_profile;
                }