OSDN Git Service

rtlwifi: use ktime_get_real_seconds() for suspend time
authorArnd Bergmann <arnd@arndb.de>
Mon, 6 Nov 2017 13:55:36 +0000 (14:55 +0100)
committerKalle Valo <kvalo@codeaurora.org>
Wed, 8 Nov 2017 12:33:05 +0000 (14:33 +0200)
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 <arnd@arndb.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/realtek/rtlwifi/core.c
drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
drivers/net/wireless/realtek/rtlwifi/wifi.h

index 1147327..533e9cc 100644 (file)
@@ -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);
index 52f17bd..5a5ce98 100644 (file)
@@ -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:
index 49f6918..c96abc9 100644 (file)
@@ -1600,7 +1600,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;