summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2014-04-11 17:00:54 +0530
committerGerrit Code Review <gerrit2@nvidia.com>2014-04-11 22:04:36 -0700
commit03c21df04cf7eb339d05da3815541dff5207ca15 (patch)
treee6f8909cbd337829827d2d47c08b4c01b0eb5615 /drivers
parent6bb3e44cb81b0afe7fd4bf2f79ae209d80be11e6 (diff)
power: lc709203f: read FG status before registering power supply
Read the SOC and voltage level from fuel gauge before registering power supply so that framework can get the required information even before workqueue get scheduled. This will avoid incorrect value to be pass to the client if there is any race occur. Change-Id: Id8696607bf5ec7d434aaf2af3f9e662f677759b5 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/power/lc709203f_battery.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/power/lc709203f_battery.c b/drivers/power/lc709203f_battery.c
index 67505caa4ee4..d8955ed09b3c 100644
--- a/drivers/power/lc709203f_battery.c
+++ b/drivers/power/lc709203f_battery.c
@@ -129,13 +129,9 @@ static int lc709203f_write_word(struct i2c_client *client, u8 reg, u16 value)
return ret;
}
-static void lc709203f_work(struct work_struct *work)
+static int lc709203f_update_soc_voltage(struct lc709203f_chip *chip)
{
- struct lc709203f_chip *chip;
int val;
- int temperature;
-
- chip = container_of(work, struct lc709203f_chip, work.work);
val = lc709203f_read_word(chip->client, LC709203F_VOLTAGE);
if (val < 0)
@@ -152,7 +148,7 @@ static void lc709203f_work(struct work_struct *work)
chip->pdata->maximum_soc, val * 100);
if (chip->soc >= LC709203F_BATTERY_FULL && chip->charge_complete != 1)
- chip->soc = LC709203F_BATTERY_FULL-1;
+ chip->soc = LC709203F_BATTERY_FULL - 1;
if (chip->status == POWER_SUPPLY_STATUS_FULL && chip->charge_complete) {
chip->soc = LC709203F_BATTERY_FULL;
@@ -167,6 +163,17 @@ static void lc709203f_work(struct work_struct *work)
chip->health = POWER_SUPPLY_HEALTH_GOOD;
chip->capacity_level = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
}
+ return 0;
+}
+static void lc709203f_work(struct work_struct *work)
+{
+ struct lc709203f_chip *chip;
+ int val;
+ int temperature;
+
+ chip = container_of(work, struct lc709203f_chip, work.work);
+
+ lc709203f_update_soc_voltage(chip);
if (chip->soc != chip->lasttime_soc ||
chip->status != chip->lasttime_status) {
@@ -526,6 +533,8 @@ static int lc709203f_probe(struct i2c_client *client,
}
skip_thermistor_config:
+ lc709203f_update_soc_voltage(chip);
+
chip->battery.name = "battery";
chip->battery.type = POWER_SUPPLY_TYPE_BATTERY;
chip->battery.get_property = lc709203f_get_property;