Loading drivers/power/supply/qti_battery_charger.c +19 −15 Original line number Original line Diff line number Diff line Loading @@ -939,10 +939,10 @@ static int __battery_psy_set_charge_current(struct battery_chg_dev *bcdev, { { int rc; int rc; if (bcdev->restrict_chg_en) if (bcdev->restrict_chg_en) { fcc_ua = min_t(u32, fcc_ua, bcdev->restrict_fcc_ua); fcc_ua = min_t(u32, fcc_ua, bcdev->thermal_fcc_ua); fcc_ua = min_t(u32, fcc_ua, bcdev->thermal_fcc_ua); else } fcc_ua = bcdev->thermal_fcc_ua; rc = write_property_id(bcdev, &bcdev->psy_list[PSY_TYPE_BATTERY], rc = write_property_id(bcdev, &bcdev->psy_list[PSY_TYPE_BATTERY], BATT_CHG_CTRL_LIM, fcc_ua); BATT_CHG_CTRL_LIM, fcc_ua); Loading @@ -958,7 +958,7 @@ static int battery_psy_set_charge_current(struct battery_chg_dev *bcdev, int val) int val) { { int rc; int rc; u32 fcc_ua; u32 fcc_ua, prev_fcc_ua; if (!bcdev->num_thermal_levels) if (!bcdev->num_thermal_levels) return 0; return 0; Loading @@ -972,12 +972,14 @@ static int battery_psy_set_charge_current(struct battery_chg_dev *bcdev, return -EINVAL; return -EINVAL; fcc_ua = bcdev->thermal_levels[val]; fcc_ua = bcdev->thermal_levels[val]; prev_fcc_ua = bcdev->thermal_fcc_ua; bcdev->thermal_fcc_ua = fcc_ua; rc = __battery_psy_set_charge_current(bcdev, fcc_ua); rc = __battery_psy_set_charge_current(bcdev, fcc_ua); if (!rc) { if (!rc) bcdev->curr_thermal_level = val; bcdev->curr_thermal_level = val; bcdev->thermal_fcc_ua = fcc_ua; else } bcdev->thermal_fcc_ua = prev_fcc_ua; return rc; return rc; } } Loading Loading @@ -1392,18 +1394,20 @@ static ssize_t restrict_cur_store(struct class *c, struct class_attribute *attr, struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev, struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev, battery_class); battery_class); int rc; int rc; u32 val; u32 fcc_ua, prev_fcc_ua; if (kstrtou32(buf, 0, &val) || val > bcdev->thermal_fcc_ua) if (kstrtou32(buf, 0, &fcc_ua) || fcc_ua > bcdev->thermal_fcc_ua) return -EINVAL; return -EINVAL; prev_fcc_ua = bcdev->restrict_fcc_ua; bcdev->restrict_fcc_ua = fcc_ua; if (bcdev->restrict_chg_en) { if (bcdev->restrict_chg_en) { rc = __battery_psy_set_charge_current(bcdev, val); rc = __battery_psy_set_charge_current(bcdev, fcc_ua); if (rc < 0) if (rc < 0) { bcdev->restrict_fcc_ua = prev_fcc_ua; return rc; return rc; } } } bcdev->restrict_fcc_ua = val; return count; return count; } } Loading @@ -1430,8 +1434,8 @@ static ssize_t restrict_chg_store(struct class *c, struct class_attribute *attr, return -EINVAL; return -EINVAL; bcdev->restrict_chg_en = val; bcdev->restrict_chg_en = val; rc = __battery_psy_set_charge_current(bcdev, bcdev->restrict_chg_en ? rc = __battery_psy_set_charge_current(bcdev, bcdev->restrict_fcc_ua); bcdev->restrict_fcc_ua : bcdev->thermal_fcc_ua); if (rc < 0) if (rc < 0) return rc; return rc; Loading Loading
drivers/power/supply/qti_battery_charger.c +19 −15 Original line number Original line Diff line number Diff line Loading @@ -939,10 +939,10 @@ static int __battery_psy_set_charge_current(struct battery_chg_dev *bcdev, { { int rc; int rc; if (bcdev->restrict_chg_en) if (bcdev->restrict_chg_en) { fcc_ua = min_t(u32, fcc_ua, bcdev->restrict_fcc_ua); fcc_ua = min_t(u32, fcc_ua, bcdev->thermal_fcc_ua); fcc_ua = min_t(u32, fcc_ua, bcdev->thermal_fcc_ua); else } fcc_ua = bcdev->thermal_fcc_ua; rc = write_property_id(bcdev, &bcdev->psy_list[PSY_TYPE_BATTERY], rc = write_property_id(bcdev, &bcdev->psy_list[PSY_TYPE_BATTERY], BATT_CHG_CTRL_LIM, fcc_ua); BATT_CHG_CTRL_LIM, fcc_ua); Loading @@ -958,7 +958,7 @@ static int battery_psy_set_charge_current(struct battery_chg_dev *bcdev, int val) int val) { { int rc; int rc; u32 fcc_ua; u32 fcc_ua, prev_fcc_ua; if (!bcdev->num_thermal_levels) if (!bcdev->num_thermal_levels) return 0; return 0; Loading @@ -972,12 +972,14 @@ static int battery_psy_set_charge_current(struct battery_chg_dev *bcdev, return -EINVAL; return -EINVAL; fcc_ua = bcdev->thermal_levels[val]; fcc_ua = bcdev->thermal_levels[val]; prev_fcc_ua = bcdev->thermal_fcc_ua; bcdev->thermal_fcc_ua = fcc_ua; rc = __battery_psy_set_charge_current(bcdev, fcc_ua); rc = __battery_psy_set_charge_current(bcdev, fcc_ua); if (!rc) { if (!rc) bcdev->curr_thermal_level = val; bcdev->curr_thermal_level = val; bcdev->thermal_fcc_ua = fcc_ua; else } bcdev->thermal_fcc_ua = prev_fcc_ua; return rc; return rc; } } Loading Loading @@ -1392,18 +1394,20 @@ static ssize_t restrict_cur_store(struct class *c, struct class_attribute *attr, struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev, struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev, battery_class); battery_class); int rc; int rc; u32 val; u32 fcc_ua, prev_fcc_ua; if (kstrtou32(buf, 0, &val) || val > bcdev->thermal_fcc_ua) if (kstrtou32(buf, 0, &fcc_ua) || fcc_ua > bcdev->thermal_fcc_ua) return -EINVAL; return -EINVAL; prev_fcc_ua = bcdev->restrict_fcc_ua; bcdev->restrict_fcc_ua = fcc_ua; if (bcdev->restrict_chg_en) { if (bcdev->restrict_chg_en) { rc = __battery_psy_set_charge_current(bcdev, val); rc = __battery_psy_set_charge_current(bcdev, fcc_ua); if (rc < 0) if (rc < 0) { bcdev->restrict_fcc_ua = prev_fcc_ua; return rc; return rc; } } } bcdev->restrict_fcc_ua = val; return count; return count; } } Loading @@ -1430,8 +1434,8 @@ static ssize_t restrict_chg_store(struct class *c, struct class_attribute *attr, return -EINVAL; return -EINVAL; bcdev->restrict_chg_en = val; bcdev->restrict_chg_en = val; rc = __battery_psy_set_charge_current(bcdev, bcdev->restrict_chg_en ? rc = __battery_psy_set_charge_current(bcdev, bcdev->restrict_fcc_ua); bcdev->restrict_fcc_ua : bcdev->thermal_fcc_ua); if (rc < 0) if (rc < 0) return rc; return rc; Loading