aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/ab8500_fg.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power/ab8500_fg.c')
-rw-r--r--drivers/power/ab8500_fg.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c
index 217da4b2ca86..99a78d365ceb 100644
--- a/drivers/power/ab8500_fg.c
+++ b/drivers/power/ab8500_fg.c
@@ -25,6 +25,7 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/time64.h>
28#include <linux/of.h> 29#include <linux/of.h>
29#include <linux/completion.h> 30#include <linux/completion.h>
30#include <linux/mfd/core.h> 31#include <linux/mfd/core.h>
@@ -108,7 +109,7 @@ enum ab8500_fg_calibration_state {
108struct ab8500_fg_avg_cap { 109struct ab8500_fg_avg_cap {
109 int avg; 110 int avg;
110 int samples[NBR_AVG_SAMPLES]; 111 int samples[NBR_AVG_SAMPLES];
111 __kernel_time_t time_stamps[NBR_AVG_SAMPLES]; 112 time64_t time_stamps[NBR_AVG_SAMPLES];
112 int pos; 113 int pos;
113 int nbr_samples; 114 int nbr_samples;
114 int sum; 115 int sum;
@@ -386,15 +387,15 @@ static int ab8500_fg_is_low_curr(struct ab8500_fg *di, int curr)
386 */ 387 */
387static int ab8500_fg_add_cap_sample(struct ab8500_fg *di, int sample) 388static int ab8500_fg_add_cap_sample(struct ab8500_fg *di, int sample)
388{ 389{
389 struct timespec ts; 390 struct timespec64 ts64;
390 struct ab8500_fg_avg_cap *avg = &di->avg_cap; 391 struct ab8500_fg_avg_cap *avg = &di->avg_cap;
391 392
392 getnstimeofday(&ts); 393 getnstimeofday64(&ts64);
393 394
394 do { 395 do {
395 avg->sum += sample - avg->samples[avg->pos]; 396 avg->sum += sample - avg->samples[avg->pos];
396 avg->samples[avg->pos] = sample; 397 avg->samples[avg->pos] = sample;
397 avg->time_stamps[avg->pos] = ts.tv_sec; 398 avg->time_stamps[avg->pos] = ts64.tv_sec;
398 avg->pos++; 399 avg->pos++;
399 400
400 if (avg->pos == NBR_AVG_SAMPLES) 401 if (avg->pos == NBR_AVG_SAMPLES)
@@ -407,7 +408,7 @@ static int ab8500_fg_add_cap_sample(struct ab8500_fg *di, int sample)
407 * Check the time stamp for each sample. If too old, 408 * Check the time stamp for each sample. If too old,
408 * replace with latest sample 409 * replace with latest sample
409 */ 410 */
410 } while (ts.tv_sec - VALID_CAPACITY_SEC > avg->time_stamps[avg->pos]); 411 } while (ts64.tv_sec - VALID_CAPACITY_SEC > avg->time_stamps[avg->pos]);
411 412
412 avg->avg = avg->sum / avg->nbr_samples; 413 avg->avg = avg->sum / avg->nbr_samples;
413 414
@@ -446,14 +447,14 @@ static void ab8500_fg_clear_cap_samples(struct ab8500_fg *di)
446static void ab8500_fg_fill_cap_sample(struct ab8500_fg *di, int sample) 447static void ab8500_fg_fill_cap_sample(struct ab8500_fg *di, int sample)
447{ 448{
448 int i; 449 int i;
449 struct timespec ts; 450 struct timespec64 ts64;
450 struct ab8500_fg_avg_cap *avg = &di->avg_cap; 451 struct ab8500_fg_avg_cap *avg = &di->avg_cap;
451 452
452 getnstimeofday(&ts); 453 getnstimeofday64(&ts64);
453 454
454 for (i = 0; i < NBR_AVG_SAMPLES; i++) { 455 for (i = 0; i < NBR_AVG_SAMPLES; i++) {
455 avg->samples[i] = sample; 456 avg->samples[i] = sample;
456 avg->time_stamps[i] = ts.tv_sec; 457 avg->time_stamps[i] = ts64.tv_sec;
457 } 458 }
458 459
459 avg->pos = 0; 460 avg->pos = 0;