From patchwork Mon Jun 18 14:23:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 138965 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4016332lji; Mon, 18 Jun 2018 07:24:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI0sEy8ZAu/nw73a+1ArZkyZAUlSAwQjxqWlD9uOb9pRpAkuUG36ofnKeTsRNYzhTOeHRfz X-Received: by 2002:a17:902:981:: with SMTP id 1-v6mr14464870pln.11.1529331842224; Mon, 18 Jun 2018 07:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529331842; cv=none; d=google.com; s=arc-20160816; b=g7gP3hJ5ngyd9YBVzkD7vcV1BaerZL38K0DCByxWSobJloKT8IG+LSagIbfPcu5F8C ulTgMdmzSkny7Iv2VF6t6J04bVvwXxpNQF8fJvKCtQy8B1CiMjkJkp5vgGhXAjOfcTj5 glvWQuLkAMtFyQejci7EbNx7/DYZ9636mxCla/g3JA30W0gENnmdLq5+tzOaheWphnbK 9mSKkYz/mQGHl2/CfqVrBppB+9SdUvMEQHJewfIHyJm6O5h3tRLznpWzT2eXnJlI7+8c q0XNn+6i01Ng+kzKD6zkTh4/cNG0kS+WvJj5J67G0uMmq1O4XlEPcyFU4A11hvOVt76s kG8g== 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=ejZz5ulJr1Q1XyL746ALKgPRGuOGvf6govsteYIsdDiN/wkGkT66IIOhzUCMqUtthI 4jcDd3nsdbEWGOcK9VgMeuRzk8LhZgM5lM09i0Vv4MhnJ/AMPrXiIH1nW170SJkRv3Lp dHn0r8ExF3iVc/tOQfTM2o3NqG4sXvdash0PraxC36H5v7In91jRliMEyauMGjioOktS T4Bc6WhA8Q+U92h/VzbLy35ZE+sj1dJhR5jxbthcdhZGPcU568CaRU9O4oEZ7GZqQOy8 FaxMHU1762WflZsN96SGzVU3GseNQnb2TFBJLpln2m3bq3QNMUHG34zTiG+dRhv/Pyt6 4PBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 t29-v6si14584458pfg.114.2018.06.18.07.24.01; Mon, 18 Jun 2018 07:24:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934734AbeFROYA (ORCPT + 10 others); Mon, 18 Jun 2018 10:24:00 -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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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(-) -- 2.9.0 Acked-by: Linus Walleij 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;