rtw88: use read_poll_timeout_atomic() for poll loop
authorBrian Norris <briannorris@chromium.org>
Fri, 21 Aug 2020 23:57:33 +0000 (16:57 -0700)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 27 Aug 2020 10:04:38 +0000 (13:04 +0300)
This gives the added bonus of not wasting an extra udelay() if we're
timing out -- we double-check the register state one last time before
returning.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200821235733.1785009-1-briannorris@chromium.org
drivers/net/wireless/realtek/rtw88/mac.c

index 19b9b7a..59028b1 100644 (file)
@@ -114,18 +114,13 @@ static int rtw_mac_pre_system_cfg(struct rtw_dev *rtwdev)
 
 static bool do_pwr_poll_cmd(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 target)
 {
-       u32 cnt;
+       u32 val;
 
        target &= mask;
 
-       for (cnt = 0; cnt < RTW_PWR_POLLING_CNT; cnt++) {
-               if ((rtw_read8(rtwdev, addr) & mask) == target)
-                       return true;
-
-               udelay(50);
-       }
-
-       return false;
+       return read_poll_timeout_atomic(rtw_read8, val, (val & mask) == target,
+                                       50, 50 * RTW_PWR_POLLING_CNT, false,
+                                       rtwdev, addr) == 0;
 }
 
 static int rtw_pwr_cmd_polling(struct rtw_dev *rtwdev,