wifi: rtw88: debug: add to check if debug mask is enabled
authorChin-Yen Lee <timlee@realtek.com>
Mon, 16 Oct 2023 05:35:53 +0000 (13:35 +0800)
committerKalle Valo <kvalo@kernel.org>
Thu, 19 Oct 2023 07:28:02 +0000 (10:28 +0300)
The coming dump function for FW malfunction will add a function to
dump registers to reflect status. However, if we are not debugging
the mechanism, we don't print anything, so avoid reading registers by
checking debug mask to reduce IO.

Signed-off-by: Chin-Yen Lee <timlee@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231016053554.744180-2-pkshih@realtek.com
drivers/net/wireless/realtek/rtw88/debug.h

index a9149c6c2b48c5cd452c5711cfa776ea79464bfd..a03ced11bbe04204aa67dfa7287e6a2aec690ff2 100644 (file)
@@ -48,11 +48,23 @@ void __rtw_dbg(struct rtw_dev *rtwdev, enum rtw_debug_mask mask,
 
 #define rtw_dbg(rtwdev, a...) __rtw_dbg(rtwdev, ##a)
 
+static inline bool rtw_dbg_is_enabled(struct rtw_dev *rtwdev,
+                                     enum rtw_debug_mask mask)
+{
+       return !!(rtw_debug_mask & mask);
+}
+
 #else
 
 static inline void rtw_dbg(struct rtw_dev *rtwdev, enum rtw_debug_mask mask,
                           const char *fmt, ...) {}
 
+static inline bool rtw_dbg_is_enabled(struct rtw_dev *rtwdev,
+                                     enum rtw_debug_mask mask)
+{
+       return false;
+}
+
 #endif /* CONFIG_RTW88_DEBUG */
 
 #define rtw_info(rtwdev, a...) dev_info(rtwdev->dev, ##a)