Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wifi: rtlwifi: use unsigned long for bt_coexist_8723 timestamp

Since 'bt_inq_page_start_time' of 'struct bt_coexist_8723' is
in jiffies, prefer 'unsigned long' over 'u32' to avoid possible
truncation in 'rtl8723e_dm_bt_inq_page_monitor()' and adjust
related code. Found with clang's -Wshorten-64-to-32, compile
tested only.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231004092418.73337-1-dmantipov@yandex.ru

authored by

Dmitry Antipov and committed by
Kalle Valo
71ffa1bc 14a5b115

+8 -10
+7 -9
drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hal_btc.c
··· 1122 1122 /* Always ignore WlanAct if bHid|bSCOBusy|bSCOeSCO */ 1123 1123 1124 1124 rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_DMESG, 1125 - "[BTCoex], BT btInqPageStartTime = 0x%x, btTxRxCntLvl = %d\n", 1125 + "[BTCoex], BT btInqPageStartTime = 0x%lx, btTxRxCntLvl = %d\n", 1126 1126 hal_coex_8723.bt_inq_page_start_time, bt_tx_rx_cnt_lvl); 1127 1127 if ((hal_coex_8723.bt_inq_page_start_time) || 1128 1128 (BT_TXRX_CNT_LEVEL_3 == bt_tx_rx_cnt_lvl)) { ··· 1335 1335 btdm8723.dec_bt_pwr = true; 1336 1336 1337 1337 rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_DMESG, 1338 - "[BTCoex], BT btInqPageStartTime = 0x%x, btTxRxCntLvl = %d\n", 1338 + "[BTCoex], BT btInqPageStartTime = 0x%lx, btTxRxCntLvl = %d\n", 1339 1339 hal_coex_8723.bt_inq_page_start_time, bt_tx_rx_cnt_lvl); 1340 1340 1341 1341 if ((hal_coex_8723.bt_inq_page_start_time) || ··· 1358 1358 static void rtl8723e_dm_bt_inq_page_monitor(struct ieee80211_hw *hw) 1359 1359 { 1360 1360 struct rtl_priv *rtlpriv = rtl_priv(hw); 1361 - u32 cur_time; 1361 + unsigned long cur_time = jiffies; 1362 1362 1363 - cur_time = jiffies; 1364 1363 if (hal_coex_8723.c2h_bt_inquiry_page) { 1365 1364 /* bt inquiry or page is started. */ 1366 1365 if (hal_coex_8723.bt_inq_page_start_time == 0) { ··· 1367 1368 BT_COEX_STATE_BT_INQ_PAGE; 1368 1369 hal_coex_8723.bt_inq_page_start_time = cur_time; 1369 1370 rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_DMESG, 1370 - "[BTCoex], BT Inquiry/page is started at time : 0x%x\n", 1371 + "[BTCoex], BT Inquiry/page is started at time : 0x%lx\n", 1371 1372 hal_coex_8723.bt_inq_page_start_time); 1372 1373 } 1373 1374 } 1374 1375 rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_DMESG, 1375 - "[BTCoex], BT Inquiry/page started time : 0x%x, cur_time : 0x%x\n", 1376 + "[BTCoex], BT Inquiry/page started time : 0x%lx, cur_time : 0x%lx\n", 1376 1377 hal_coex_8723.bt_inq_page_start_time, cur_time); 1377 1378 1378 1379 if (hal_coex_8723.bt_inq_page_start_time) { 1379 - if ((((long)cur_time - 1380 - (long)hal_coex_8723.bt_inq_page_start_time) / HZ) 1381 - >= 10) { 1380 + if (jiffies_to_msecs(cur_time - 1381 + hal_coex_8723.bt_inq_page_start_time) >= 10000) { 1382 1382 rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_DMESG, 1383 1383 "[BTCoex], BT Inquiry/page >= 10sec!!!\n"); 1384 1384 hal_coex_8723.bt_inq_page_start_time = 0;
+1 -1
drivers/net/wireless/realtek/rtlwifi/wifi.h
··· 1597 1597 u8 c2h_bt_info; 1598 1598 bool c2h_bt_info_req_sent; 1599 1599 bool c2h_bt_inquiry_page; 1600 - u32 bt_inq_page_start_time; 1600 + unsigned long bt_inq_page_start_time; 1601 1601 u8 bt_retry_cnt; 1602 1602 u8 c2h_bt_info_original; 1603 1603 u8 bt_inquiry_page_cnt;