diff options
author | Karl-Johan Perntz <karl-johan.perntz@stericsson.com> | 2011-12-15 14:51:59 +0100 |
---|---|---|
committer | Philippe Langlais <philippe.langlais@linaro.org> | 2012-03-19 08:51:12 +0100 |
commit | 2225b4c324510be163e2ebf309325e5eea11cdff (patch) | |
tree | fbca38dbc7701a7a437b7d228ea46f46ba7d983d /drivers | |
parent | 39aeddfb29f82d120f12c8e6e36cd91dc1ea7013 (diff) |
ab8500_btemp: limit number of batctrl readings
Read as many batctrl values as possible during 250 ms but do not spend more
time than that. This is done with cc_lock taken (the ab8500_fg_inst_curr_start
call in the ab8500_fg driver) so finishing as quick as possible is good (lock
freed by the ab8500_fg_inst_curr_finalize call).
ST-Ericsson Linux next: -
ST-Ericsson ID: 404432
ST-Ericsson FOSS-OUT ID: Trivial
Change-Id: Ieee4c01a6e1750a747abceaec60e3e4dd62419f0
Signed-off-by: Karl-Johan Perntz <karl-johan.perntz@stericsson.com>
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/43177
Reviewed-by: Johan BJORNSTEDT <johan.bjornstedt@stericsson.com>
Reviewed-by: QABUILD
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/power/ab8500_btemp.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c index c08f0334ca9..271263050b2 100644 --- a/drivers/power/ab8500_btemp.c +++ b/drivers/power/ab8500_btemp.c @@ -22,6 +22,7 @@ #include <linux/mfd/abx500.h> #include <linux/mfd/ab8500/bm.h> #include <linux/mfd/abx500/ab8500-gpadc.h> +#include <linux/jiffies.h> #define VTVOUT_V 1800 @@ -350,6 +351,7 @@ static int ab8500_btemp_get_batctrl_res(struct ab8500_btemp *di) int res; int inst_curr; int i; + unsigned long stop_time; /* * BATCTRL current sources are included on AB8500 cut2.0 @@ -376,16 +378,19 @@ static int ab8500_btemp_get_batctrl_res(struct ab8500_btemp *di) } /* - * Since there is no interrupt when current measurement id one, - * loop for over 250ms, since 250ms is one sample conversion time - * with 32.768 Khz RTC clock. + * Since there is no interrupt when current measurement is done, + * loop for over 250ms (250ms is one sample conversion time + * with 32.768 Khz RTC clock). Note that a stop time must be set + * since the ab8500_btemp_read_batctrl_voltage call can block and + * take an unknown amount of time to complete. */ - - for (i = 0; i < 11; i++) { + stop_time = jiffies + msecs_to_jiffies(250); + i = 0; + do { batctrl += ab8500_btemp_read_batctrl_voltage(di); + i++; msleep(25); - } - + } while (time_after(stop_time, jiffies)); batctrl /= i; ret = ab8500_fg_inst_curr_finalize(di->fg, &inst_curr); |