Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 887a2486 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: step-chg-jeita: use power_supply notifier for time hysteresis"

parents 5cfa92a3 1270712c
Loading
Loading
Loading
Loading
+5 −26
Original line number Diff line number Diff line
@@ -541,8 +541,9 @@ static int handle_step_chg_config(struct step_chg_info *chip)
	u64 elapsed_us;

	elapsed_us = ktime_us_delta(ktime_get(), chip->step_last_update_time);
	/* skip processing, event too early */
	if (elapsed_us < STEP_CHG_HYSTERISIS_DELAY_US)
		goto reschedule;
		return 0;

	rc = power_supply_get_property(chip->batt_psy,
		POWER_SUPPLY_PROP_STEP_CHARGING_ENABLED, &pval);
@@ -612,10 +613,6 @@ static int handle_step_chg_config(struct step_chg_info *chip)
update_time:
	chip->step_last_update_time = ktime_get();
	return 0;

reschedule:
	/* reschedule 1000uS after the remaining time */
	return (STEP_CHG_HYSTERISIS_DELAY_US - elapsed_us + 1000);
}

#define JEITA_SUSPEND_HYST_UV		50000
@@ -643,8 +640,9 @@ static int handle_jeita(struct step_chg_info *chip)
	}

	elapsed_us = ktime_us_delta(ktime_get(), chip->jeita_last_update_time);
	/* skip processing, event too early */
	if (elapsed_us < STEP_CHG_HYSTERISIS_DELAY_US)
		goto reschedule;
		return 0;

	if (chip->jeita_fcc_config->param.use_bms)
		rc = power_supply_get_property(chip->bms_psy,
@@ -731,10 +729,6 @@ static int handle_jeita(struct step_chg_info *chip)
		power_supply_changed(chip->main_psy);

	return 0;

reschedule:
	/* reschedule 1000uS after the remaining time */
	return (STEP_CHG_HYSTERISIS_DELAY_US - elapsed_us + 1000);
}

static int handle_battery_insertion(struct step_chg_info *chip)
@@ -775,9 +769,6 @@ static void status_change_work(struct work_struct *work)
	struct step_chg_info *chip = container_of(work,
			struct step_chg_info, status_change_work.work);
	int rc = 0;
	int reschedule_us;
	int reschedule_jeita_work_us = 0;
	int reschedule_step_work_us = 0;
	union power_supply_propval prop = {0, };

	if (!is_batt_available(chip) || !is_bms_available(chip))
@@ -787,14 +778,10 @@ static void status_change_work(struct work_struct *work)

	/* skip elapsed_us debounce for handling battery temperature */
	rc = handle_jeita(chip);
	if (rc > 0)
		reschedule_jeita_work_us = rc;
	else if (rc < 0)
	if (rc < 0)
		pr_err("Couldn't handle sw jeita rc = %d\n", rc);

	rc = handle_step_chg_config(chip);
	if (rc > 0)
		reschedule_step_work_us = rc;
	if (rc < 0)
		pr_err("Couldn't handle step rc = %d\n", rc);

@@ -810,14 +797,6 @@ static void status_change_work(struct work_struct *work)
		}
	}

	reschedule_us = min(reschedule_jeita_work_us, reschedule_step_work_us);
	if (reschedule_us == 0)
		goto exit_work;
	else
		schedule_delayed_work(&chip->status_change_work,
				usecs_to_jiffies(reschedule_us));
	return;

exit_work:
	__pm_relax(chip->step_chg_ws);
}