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>
#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;
}