]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
staging: rtl8723bs: use read_poll_timeout_atomic in _is_fw_read_cmd_down
authorPrithvi Tambewagh <activprithvi@gmail.com>
Thu, 9 Apr 2026 13:50:25 +0000 (19:20 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Apr 2026 11:01:55 +0000 (05:01 -0600)
Replace the existing rtw_read8() and do-while loop mechanism with
read_poll_timeout_atomic() from <linux/iopoll.h>, in _is_fw_read_cmd_down()
which is a standard Linux macro, ensuring polling REG_HMETFR efficiently.

Signed-off-by: Prithvi Tambewagh <activprithvi@gmail.com>
Reviewed-by: Luka Gejak <luka.gejak@linux.dev>
Link: https://patch.msgid.link/20260409135026.137904-5-activprithvi@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c

index 12416e499ac35b9ab20298451636b884d1c6292f..4bdc8e314015b89d4b70758e0602a4f963111ea1 100644 (file)
@@ -8,6 +8,7 @@
 #include <drv_types.h>
 #include <rtl8723b_hal.h>
 #include <linux/etherdevice.h>
+#include <linux/iopoll.h>
 #include "hal_com_h2c.h"
 
 #define MAX_H2C_BOX_NUMS       4
 
 static u8 _is_fw_read_cmd_down(struct adapter *padapter, u8 msgbox_num)
 {
-       u8 read_down = false;
-       int retry_cnts = 100;
-
        u8 valid;
+       int ret;
 
-       do {
-               valid = rtw_read8(padapter, REG_HMETFR) & BIT(msgbox_num);
-               if (0 == valid) {
-                       read_down = true;
-               }
-       } while ((!read_down) && (retry_cnts--));
-
-       return read_down;
+       ret = read_poll_timeout_atomic(rtw_read8,
+                                      valid, !(valid & BIT(msgbox_num)),
+                                      0, 500, false,
+                                      padapter, REG_HMETFR);
 
+       return !ret;
 }