From patchwork Mon Nov 6 13:55:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10043509 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BF50D60247 for ; Mon, 6 Nov 2017 13:57:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B04E229C82 for ; Mon, 6 Nov 2017 13:57:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A465829C9D; Mon, 6 Nov 2017 13:57:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FBB329C82 for ; Mon, 6 Nov 2017 13:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753354AbdKFN5M (ORCPT ); Mon, 6 Nov 2017 08:57:12 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:52194 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752800AbdKFN5L (ORCPT ); Mon, 6 Nov 2017 08:57:11 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0MUEy2-1ecYAb45cw-00QzOf; Mon, 06 Nov 2017 14:57:00 +0100 From: Arnd Bergmann To: Larry Finger , Chaoming Li , Kalle Valo Cc: Arnd Bergmann , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] rtlwifi: use ktime_get_real_seconds() for suspend time Date: Mon, 6 Nov 2017 14:55:36 +0100 Message-Id: <20171106135619.1248453-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171106135619.1248453-1-arnd@arndb.de> References: <20171106135619.1248453-1-arnd@arndb.de> X-Provags-ID: V03:K0:wxxxLqazar6pcznhhWczkuLS0VII+zs+DMwJ78OnOb/Slq1HBUr kGCXcdSjX43QglNZi3D1WyfoSuUHd3LiIrfU0FuNAhWAFC25M1RDXJ2G8Mh5BcN3kLBv0ez Dv4HVeKbwu5FzXRzbN9JvHUtFuobZ/eEJhQGB8NjFTpNL4h39c6LBVnO/2Q2YbeaaSD9Lwi bmM/ORy0AucjHSYtYDygA== X-UI-Out-Filterresults: notjunk:1; V01:K0:XIdAaSudI/8=:zS6F3iIFpJYzrhUOacMnc6 SvuzAFxNtk8oTmnQgUYOeEbVLFY5l0z6EvMKmJulSISv0MGqt1zZyWgnG/9DF+bkJbaJZ6PJl dmBi0PjG7MSML4gZESKpE/w/hMc7BFuAJ5/fgrCl6PuTg4SgOkq9OtPBkagzeGYIxfoTCGrdw QbXZGEcdPXTtOVH7KbyLYXjgTMMU50/yaUcwZpG25gkaVpl2OyJdSYXKHWSP9OV2y4Swtx7to fnYywD8PAiJmkZQoHa5NQt1xQBZZfJio3hm2FaZvvT3M56cJrKvQ+plNf56qgRO7N8rV5HBVv i/Lvu7RpRbZDBHw92opXh9X3KpJjpHAqiGH/C3kR3RVbYt9Ik1L+pee4eNNE4l0aH2EaE+n7t Lz6ARGcVPiDfTnt2xzIzWjVaqVHUlsu7iNp81IvmEE35oj480CXgs3E+CmySj0LQA6HhJ1Yf3 SfNkuhnt1q8Y7mIL5uUwM8iUdJ4fstnOCyq3Dr7xauxqQOJQvBNt7pUiAW9oWiDGUZPtVB5Yz EOvP6Q2O2FjW8DWL9NCaDl7bNR8Pk8aALOE7l4z9jyoK4peBwlVfeDR1/lTnfNX7DzJ/XZFvT mz86A8Yv/fr/PZ1Qk7XHSClCN3SdCC3fkY8T1DUbpbtF5ZnZCEqAmB4m/dNG6VCQ6R5Icawn7 U7q9IQyK5cIkczPP3QZACsVWw6NhWDmcyk++LDr9G5ZVp12onO4J1s+5mlxLK1EXWOKJTUGLu rk1mwsCK8i6BJPFqdEKmRY41nYpG106Fq30NPw== Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP do_gettimeofday() is deprecated and slower than necessary for the purpose of reading the seconds. This changes rtl_op_suspend/resume to use ktime_get_real_seconds() instead, which is simpler and avoids confusion about whether it is y2038-safe or not. Signed-off-by: Arnd Bergmann --- drivers/net/wireless/realtek/rtlwifi/core.c | 10 ++++------ drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c | 3 +-- drivers/net/wireless/realtek/rtlwifi/wifi.h | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c index 1147327e6f52..533e9cc4c84b 100644 --- a/drivers/net/wireless/realtek/rtlwifi/core.c +++ b/drivers/net/wireless/realtek/rtlwifi/core.c @@ -550,15 +550,13 @@ static int rtl_op_suspend(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_hal *rtlhal = rtl_hal(rtlpriv); struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - struct timeval ts; RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n"); if (WARN_ON(!wow)) return -EINVAL; /* to resolve s4 can not wake up*/ - do_gettimeofday(&ts); - rtlhal->last_suspend_sec = ts.tv_sec; + rtlhal->last_suspend_sec = ktime_get_real_seconds(); if ((ppsc->wo_wlan_mode & WAKE_ON_PATTERN_MATCH) && wow->n_patterns) _rtl_add_wowlan_patterns(hw, wow); @@ -577,7 +575,7 @@ static int rtl_op_resume(struct ieee80211_hw *hw) struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_hal *rtlhal = rtl_hal(rtlpriv); struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - struct timeval ts; + time64_t now; RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n"); rtlhal->driver_is_goingto_unload = false; @@ -585,8 +583,8 @@ static int rtl_op_resume(struct ieee80211_hw *hw) rtlhal->wake_from_pnp_sleep = true; /* to resovle s4 can not wake up*/ - do_gettimeofday(&ts); - if (ts.tv_sec - rtlhal->last_suspend_sec < 5) + now = ktime_get_real_seconds(); + if (now - rtlhal->last_suspend_sec < 5) return -1; rtl_op_start(hw); diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c index 20ffe856180e..ad28e188bd04 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c @@ -1373,8 +1373,7 @@ static void _rtl8821ae_get_wakeup_reason(struct ieee80211_hw *hw) ppsc->wakeup_reason = 0; - do_gettimeofday(&ts); - rtlhal->last_suspend_sec = ts.tv_sec; + rtlhal->last_suspend_sec = ktime_get_real_seconds(); switch (fw_reason) { case FW_WOW_V2_PTK_UPDATE_EVENT: diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h index 22afc14c3da6..6f1b0f4667d9 100644 --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h @@ -1599,7 +1599,7 @@ struct rtl_hal { bool enter_pnp_sleep; bool wake_from_pnp_sleep; bool wow_enabled; - __kernel_time_t last_suspend_sec; + time64_t last_suspend_sec; u32 wowlan_fwsize; u8 *wowlan_firmware;