summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2016-07-22 08:56:33 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2016-07-22 08:56:33 -0700
commit10b41ef511ab925e2681ef36f1ca01129e9cd607 (patch)
tree9087d0827b10af2d686ae1943ab8b4d1ea4bb73d /drivers/power
parentac21f498404da4170e6e26cb300bf594ebeeea75 (diff)
parentf56fc4b5afcdd11e0a53596b9768b728ed495e82 (diff)
Merge "of_batterydata: Pass battery id directly to find battery profile"
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/qcom-charger/qpnp-fg.c17
-rw-r--r--drivers/power/qcom-charger/qpnp-smbcharger.c18
2 files changed, 22 insertions, 13 deletions
diff --git a/drivers/power/qcom-charger/qpnp-fg.c b/drivers/power/qcom-charger/qpnp-fg.c
index 8660c1f8c3f5..0658f0d3b1eb 100644
--- a/drivers/power/qcom-charger/qpnp-fg.c
+++ b/drivers/power/qcom-charger/qpnp-fg.c
@@ -4772,8 +4772,7 @@ fail:
#define BATTERY_PSY_WAIT_MS 2000
static int fg_batt_profile_init(struct fg_chip *chip)
{
- int rc = 0, ret;
- int len;
+ int rc = 0, ret, len, batt_id;
struct device_node *node = chip->pdev->dev.of_node;
struct device_node *batt_node, *profile_node;
const char *data, *batt_type_str;
@@ -4802,14 +4801,16 @@ wait:
goto no_profile;
}
+ batt_id = get_sram_prop_now(chip, FG_DATA_BATT_ID);
+ batt_id /= 1000;
if (fg_debug_mask & FG_STATUS)
- pr_info("battery id = %d\n",
- get_sram_prop_now(chip, FG_DATA_BATT_ID));
- profile_node = of_batterydata_get_best_profile(batt_node, "bms",
+ pr_info("battery id = %dKOhms\n", batt_id);
+
+ profile_node = of_batterydata_get_best_profile(batt_node, batt_id,
fg_batt_type);
- if (!profile_node) {
- pr_err("couldn't find profile handle\n");
- rc = -ENODATA;
+ if (IS_ERR_OR_NULL(profile_node)) {
+ rc = PTR_ERR(profile_node);
+ pr_err("couldn't find profile handle %d\n", rc);
goto no_profile;
}
diff --git a/drivers/power/qcom-charger/qpnp-smbcharger.c b/drivers/power/qcom-charger/qpnp-smbcharger.c
index 2536f4ec5c15..6c1e58d046e8 100644
--- a/drivers/power/qcom-charger/qpnp-smbcharger.c
+++ b/drivers/power/qcom-charger/qpnp-smbcharger.c
@@ -3507,19 +3507,27 @@ static int smbchg_config_chg_battery_type(struct smbchg_chip *chip)
if (chip->battery_type && !strcmp(prop.strval, chip->battery_type))
return 0;
+ chip->battery_type = prop.strval;
batt_node = of_parse_phandle(node, "qcom,battery-data", 0);
if (!batt_node) {
pr_smb(PR_MISC, "No batterydata available\n");
return 0;
}
+ rc = power_supply_get_property(chip->bms_psy,
+ POWER_SUPPLY_PROP_RESISTANCE_ID, &prop);
+ if (rc < 0) {
+ pr_smb(PR_STATUS, "Unable to read battery-id rc=%d\n", rc);
+ return 0;
+ }
+
profile_node = of_batterydata_get_best_profile(batt_node,
- "bms", NULL);
- if (!profile_node) {
- pr_err("couldn't find profile handle\n");
- return -EINVAL;
+ prop.intval / 1000, NULL);
+ if (IS_ERR_OR_NULL(profile_node)) {
+ rc = PTR_ERR(profile_node);
+ pr_err("couldn't find profile handle %d\n", rc);
+ return rc;
}
- chip->battery_type = prop.strval;
/* change vfloat */
rc = of_property_read_u32(profile_node, "qcom,max-voltage-uv",