示例#1
0
static void max17048_work(struct work_struct *work)
{
	struct max17048_chip *chip =
		container_of(work, struct max17048_chip, monitor_work.work);
	int ret = 0;
	int rechg_now;

	wake_lock(&chip->alert_lock);

	pr_debug("%s.\n", __func__);

	max17048_get_prop_temp(chip);
	max17048_get_prop_current(chip);

	ret = max17048_set_rcomp(chip);
	if (ret)
		pr_err("%s : failed to set rcomp\n", __func__);

	max17048_get_vcell(chip);
	max17048_get_soc(chip);
	complete_all(&monitor_work_done);

	if (chip->capacity_level != chip->lasttime_capacity_level ||
			chip->capacity_level == 0) {
		rechg_now = max17048_check_recharge(chip);
		chip->lasttime_capacity_level = chip->capacity_level;
		if (!rechg_now)
			power_supply_changed(&chip->batt_psy);
	}

	ret = max17048_clear_interrupt(chip);
	if (ret < 0)
		pr_err("%s : error clear alert irq register.\n", __func__);

	pr_info("%s: raw soc = 0x%04X raw vcell = 0x%04X\n",
			__func__, chip->soc, chip->vcell);
	pr_info("%s: SOC = %d vbatt_mv = %d\n",
			__func__, chip->capacity_level, chip->voltage);
	pr_info("%s: ibatt_ua = %d batt_temp = %d\n",
			__func__, chip->batt_current, chip->batt_temp);

	wake_unlock(&chip->alert_lock);
}
static int max17048_get_prop_vbatt_uv(struct max17048_chip *chip)
{
	max17048_get_vcell(chip);
	return chip->voltage * 1000;
}