From: Pandey Raj Date: Wed, 28 Mar 2012 07:39:37 +0000 (+0530) Subject: Updating UI to show the battery percentage increase every 60s X-Git-Tag: 2.1b_release~1145 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=079e80a691e9db19d4a3544a8469d6d198f19c7e;p=kernel%2Fkernel-mfld-blackbay.git Updating UI to show the battery percentage increase every 60s BZ: 24777 Whenever charger is connected/removed to the platform the UI should update the battery percetange increasing/decreasing. So, the UI update is done using the polling method rightnow. The interrupt based solution is WIP and needs to be verified on few platforms before going into mainline. Change-Id: Id42349b5ceb07b9e7144a1f2adfd8d9b2442d272 Signed-off-by: Pandey Raj Reviewed-on: http://android.intel.com:8080/40679 Reviewed-by: Pallala, Ramakrishna Tested-by: Kallappa Manjanna, MadhukumarX Reviewed-by: buildbot Tested-by: buildbot --- diff --git a/drivers/power/bq24192_charger.c b/drivers/power/bq24192_charger.c index 18c15ff..79260c5 100644 --- a/drivers/power/bq24192_charger.c +++ b/drivers/power/bq24192_charger.c @@ -171,6 +171,8 @@ #define BQ24192_CHRG_CUR_HIGH 900 /* 900mA */ #define BQ24192_CHRG_CUR_NOLIMIT 1500 /* 1500mA */ +#define STATUS_UPDATE_INTERVAL (HZ * 60) /* 60sec */ + struct bq24192_chrg_regs { u8 in_src; u8 pwr_cfg; @@ -184,6 +186,7 @@ struct bq24192_chip { struct power_supply usb; struct power_supply_charger_cap cap; struct delayed_work chrg_evt_wrkr; + struct delayed_work stat_mon_wrkr; struct mutex event_lock; int present; @@ -515,6 +518,14 @@ static void set_up_charging(struct bq24192_chip *chip, reg->chr_volt = chrg_volt_to_reg(BQ24192_DEF_VBATT_MAX); } +static void bq24192_monitor_worker(struct work_struct *work) +{ + struct bq24192_chip *chip = container_of(work, + struct bq24192_chip, stat_mon_wrkr.work); + power_supply_changed(&chip->usb); + schedule_delayed_work(&chip->stat_mon_wrkr, STATUS_UPDATE_INTERVAL); +} + static void bq24192_event_worker(struct work_struct *work) { struct bq24192_chip *chip = container_of(work, @@ -902,6 +913,7 @@ static int __devinit bq24192_probe(struct i2c_client *client, } INIT_DELAYED_WORK(&chip->chrg_evt_wrkr, bq24192_event_worker); + INIT_DELAYED_WORK(&chip->stat_mon_wrkr, bq24192_monitor_worker); mutex_init(&chip->event_lock); chip->chrg_cur_cntl = POWER_SUPPLY_CHARGE_CURRENT_LIMIT_NONE; @@ -943,7 +955,8 @@ static int __devinit bq24192_probe(struct i2c_client *client, kfree(chip); return ret; } - + /* start the status monitor worker */ + schedule_delayed_work(&chip->stat_mon_wrkr, 0); return 0; } @@ -964,6 +977,7 @@ static int bq24192_suspend(struct device *dev) { struct bq24192_chip *chip = dev_get_drvdata(dev); + cancel_delayed_work(&chip->stat_mon_wrkr); dev_dbg(&chip->client->dev, "bq24192 suspend\n"); return 0; } @@ -972,6 +986,7 @@ static int bq24192_resume(struct device *dev) { struct bq24192_chip *chip = dev_get_drvdata(dev); + schedule_delayed_work(&chip->stat_mon_wrkr, 0); dev_dbg(&chip->client->dev, "bq24192 resume\n"); return 0; }