Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3988726imm; Mon, 18 Jun 2018 07:25:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLdbrVfRWv2FcCAp6ftmtt9yljwi5HLD2ds0zm9hRg8Nh95+eRM5+FdY8lH0GeGxNTBQ3JH X-Received: by 2002:a62:234a:: with SMTP id j71-v6mr13476721pfj.221.1529331944089; Mon, 18 Jun 2018 07:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529331944; cv=none; d=google.com; s=arc-20160816; b=OcQkCFUPU4EWKnjE17DcxMGTolE993Mk2FCXZrMRES9FPkY2PtTDUatn+fgF+lf9xs Cp7qnASB052zYHcCD0t460x5dFRmigR2CruRQvFDawckNm/51T2fl8taJJh+VQyY7yaA bcoBe3fGCOoDE1Zzo4t/kgDjldLJ7nHt9rgj18wp3qvQCq4ZpEqdtZBPZd0XZunyQ1Lq NaeHpwJR19zFPo4LfRpXiCuj+dmOZdo9eqCS79UOJ336HqTpLThSRv7Z8YWlkBUIgnXs j2MBXI7iYs8Qjz1dmT3GQi0ToVNk4RmVyuNN6b/5+gb6X0p128EBcBwyIm3D0l0lboFp I/7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=0HcPcFED+ROJ47+xm2jZQ7g9T0EdWww7IJ96IvLgitQ=; b=it1CaMuKm/zcbhGjHqzHcIJacIExqvfoU7FLM3Pjx6JFU8BukmMAmrV9fnRptEHfTd 4eaCw4G/5WqIeLC4Id990MFe1bLbhApPDE9tC9RDzDgdWzmIsjJzQpadV6cwgUVVx+Xp f+vjXj0c+9GbHNbwqp3frgRIeS44b4ZECgwdXsKtddki/C48nhFsa4mb6yWR4+wEd/VG 2O1Iv4CGRWpiPYG24jbp3hCZNsQW98znFxRlHxgha0jgS26HX5eIdRzEI33sUQ2X27m7 rJfm73XKKwGM54bmqnG6C0slXbigF8GIzgkYcVlSDuTI/Sc7tsexrAJtlguU2iKnavpw dIsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s14-v6si12256194pgo.314.2018.06.18.07.25.30; Mon, 18 Jun 2018 07:25:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934813AbeFROYB (ORCPT + 99 others); Mon, 18 Jun 2018 10:24:01 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:32857 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934281AbeFROX7 (ORCPT ); Mon, 18 Jun 2018 10:23:59 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MKqyu-1fUv4V12zw-0001kL; Mon, 18 Jun 2018 16:23:55 +0200 From: Arnd Bergmann To: Sebastian Reichel Cc: Arnd Bergmann , Linus Walleij , Lee Jones , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] power: supply: ab8500: stop using getnstimeofday64() Date: Mon, 18 Jun 2018 16:23:29 +0200 Message-Id: <20180618142352.3556062-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:usRvYXqg3weoB0ZzPzIKN316WP1UyIzsZNUcxBIDxp7+csDeW+C yTnfsmoPIglqmOztZDRnbVSuKKngen/iWCb10JQ6n3YG9nAepp1Ase+yd856loIxTy59lVu sW8Yy+zfzJQSK3boDO5jn0NJ6mmq/PxN93qX8LXCzAVr7tzebRsbgk7OM+9kPvK0mhXSpxn vu2D2cFbx3rR8A8w6IctQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:J5ecXc/FrVk=:XYUVjA4jUXNoLP1IkG0SGf wiHkuxMJsYdh1wopTbJpPxM/EYRWRoGLPZOxp3kjrb9XCK3A0ufJLShKvlMUOVrDHG3hQSvcF 5AFYOB5ZCh2Lv+g3bV93+B3tiV/oW+zQPKWHDYeTF4CDzyu6XkTvvSnp60sDPSKuOzX2mNCD2 9czYGVFNSQMhmgZkpMzZdJHdPw0x+ci0zbDFcE9XLEP006j95TMdSx8a57hiuhzAJiS9C6eWs no5druOwOLxsvnPprAtrHQkaSS6fGbjTQopieFu+IABjh90DTmMKALxddWoX/pTfZyGT9cFFE E0iExzDhX7Xi8j0bUpFSApCOhpUMvFbPXfYwl6vM7Vgwd9CWoECff/B7r8Jp7DCfMKlfwY/27 RFOrLhUjeB0tcsj5D5rL7p4yUsnfsPcq+O8sbWHU3ev3BPLidf527n2Ax9IVedS6X1IrNjUmO yN1PcPIJzLS+hbRtXUD3bh/A3TF8Wmcj95PZd6EReRXMMa74gikK4ElI75rou4wMOvOOfLkYa pwvwmG5YT+Yg8hnUHdUlVUvKfffK6/L+WQK02sIVXtC4UlvElXK8HfyG1ywlyczFc5RwaSoi+ gfqEO/wjbSOzv37/P4BvlvefYF9MXLbf4AGHQta6KSaohxXDyouxw+zrabUVYj4PgXp9Uz1vS ZAuL5B635c9n78iLKNGdpuSfoyJ5eaeGs3/AVn6FAkgjcoEmGzouR7Xyxx1Qbo2ykhrk= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org getnstimeofday64() is deprecated in favor of the ktime_get() family. The direct replacement would be ktime_get_real_ts64(), but we only need the seconds value, and it seems better to use boottime than real time to avoid unexpected behavior with a concurrent settimeofday(). ktime_get_seconds() might also work, but it seems better to use boottime than monotonic time since I assume that the charging process continues during suspend. Signed-off-by: Arnd Bergmann --- drivers/power/supply/ab8500_fg.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index d9c6c7bedd85..02356f9b5f22 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -379,15 +379,13 @@ static int ab8500_fg_is_low_curr(struct ab8500_fg *di, int curr) */ static int ab8500_fg_add_cap_sample(struct ab8500_fg *di, int sample) { - struct timespec64 ts64; + time64_t now = ktime_get_boottime_seconds(); struct ab8500_fg_avg_cap *avg = &di->avg_cap; - getnstimeofday64(&ts64); - do { avg->sum += sample - avg->samples[avg->pos]; avg->samples[avg->pos] = sample; - avg->time_stamps[avg->pos] = ts64.tv_sec; + avg->time_stamps[avg->pos] = now; avg->pos++; if (avg->pos == NBR_AVG_SAMPLES) @@ -400,7 +398,7 @@ static int ab8500_fg_add_cap_sample(struct ab8500_fg *di, int sample) * Check the time stamp for each sample. If too old, * replace with latest sample */ - } while (ts64.tv_sec - VALID_CAPACITY_SEC > avg->time_stamps[avg->pos]); + } while (now - VALID_CAPACITY_SEC > avg->time_stamps[avg->pos]); avg->avg = avg->sum / avg->nbr_samples; @@ -439,14 +437,14 @@ static void ab8500_fg_clear_cap_samples(struct ab8500_fg *di) static void ab8500_fg_fill_cap_sample(struct ab8500_fg *di, int sample) { int i; - struct timespec64 ts64; + time64_t now; struct ab8500_fg_avg_cap *avg = &di->avg_cap; - getnstimeofday64(&ts64); + now = ktime_get_boottime_seconds(); for (i = 0; i < NBR_AVG_SAMPLES; i++) { avg->samples[i] = sample; - avg->time_stamps[i] = ts64.tv_sec; + avg->time_stamps[i] = now; } avg->pos = 0; -- 2.9.0