summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/realtek/rtw89/mac.c
diff options
context:
space:
mode:
authorPing-Ke Shih <pkshih@realtek.com>2023-04-14 11:22:28 +0300
committerKalle Valo <kvalo@kernel.org>2023-04-20 15:32:18 +0300
commiteaddda248483ff78c4d26f1bf420e5f2af436a74 (patch)
tree5ae8f72ad5093c345b98450de02897da9e270325 /drivers/net/wireless/realtek/rtw89/mac.c
parenteb74bfcfa99415f1a65ce021b8ac2256b7ed50bc (diff)
downloadlinux-eaddda248483ff78c4d26f1bf420e5f2af436a74.tar.xz
wifi: rtw89: mac: use regular int as return type of DLE buffer request
The function to request DLE (data link engine) buffer uses 'u16' as return value that mixes error code, so change it to 'int' as regular error code. Also, treat invalid register value (0xfff) as an error. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230414082228.30766-1-pkshih@realtek.com
Diffstat (limited to 'drivers/net/wireless/realtek/rtw89/mac.c')
-rw-r--r--drivers/net/wireless/realtek/rtw89/mac.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/net/wireless/realtek/rtw89/mac.c b/drivers/net/wireless/realtek/rtw89/mac.c
index 9b47d80b900b..b8019cfc11b2 100644
--- a/drivers/net/wireless/realtek/rtw89/mac.c
+++ b/drivers/net/wireless/realtek/rtw89/mac.c
@@ -2813,7 +2813,7 @@ int rtw89_mac_resume_sch_tx_v1(struct rtw89_dev *rtwdev, u8 mac_idx, u32 tx_en)
}
EXPORT_SYMBOL(rtw89_mac_resume_sch_tx_v1);
-u16 rtw89_mac_dle_buf_req(struct rtw89_dev *rtwdev, u16 buf_len, bool wd)
+int rtw89_mac_dle_buf_req(struct rtw89_dev *rtwdev, u16 buf_len, bool wd, u16 *pkt_id)
{
u32 val, reg;
int ret;
@@ -2828,9 +2828,13 @@ u16 rtw89_mac_dle_buf_req(struct rtw89_dev *rtwdev, u16 buf_len, bool wd)
ret = read_poll_timeout(rtw89_read32, val, val & B_AX_WD_BUF_STAT_DONE,
1, 2000, false, rtwdev, reg);
if (ret)
- return 0xffff;
+ return ret;
+
+ *pkt_id = FIELD_GET(B_AX_WD_BUF_STAT_PKTID_MASK, val);
+ if (*pkt_id == S_WD_BUF_STAT_PKTID_INVALID)
+ return -ENOENT;
- return FIELD_GET(B_AX_WD_BUF_STAT_PKTID_MASK, val);
+ return 0;
}
int rtw89_mac_set_cpuio(struct rtw89_dev *rtwdev,
@@ -2907,10 +2911,10 @@ static int dle_quota_change(struct rtw89_dev *rtwdev, enum rtw89_qta_mode mode)
dle_quota_cfg(rtwdev, cfg, INVALID_QT_WCPU);
- pkt_id = rtw89_mac_dle_buf_req(rtwdev, 0x20, true);
- if (pkt_id == 0xffff) {
+ ret = rtw89_mac_dle_buf_req(rtwdev, 0x20, true, &pkt_id);
+ if (ret) {
rtw89_err(rtwdev, "[ERR]WDE DLE buf req\n");
- return -ENOMEM;
+ return ret;
}
ctrl_para.cmd_type = CPUIO_OP_CMD_ENQ_TO_HEAD;
@@ -2925,10 +2929,10 @@ static int dle_quota_change(struct rtw89_dev *rtwdev, enum rtw89_qta_mode mode)
return -EFAULT;
}
- pkt_id = rtw89_mac_dle_buf_req(rtwdev, 0x20, false);
- if (pkt_id == 0xffff) {
+ ret = rtw89_mac_dle_buf_req(rtwdev, 0x20, false, &pkt_id);
+ if (ret) {
rtw89_err(rtwdev, "[ERR]PLE DLE buf req\n");
- return -ENOMEM;
+ return ret;
}
ctrl_para.cmd_type = CPUIO_OP_CMD_ENQ_TO_HEAD;