Skip to contentSkip to conversation

ath5k: more consistent info and error logging

PATCH In review Bruno Randolf 2 participants 2 messages Nov 21, 2007 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ath5k: more consistent info and error logging

added new macros ATH5K_INFO, ATH5K_WARN and ATH5K_ERR for more consistent logging inside ath5k. they prepend "ath5k phyX:" to all lines so we can distinguish between different cards in multi-card setups. ATH5K_WARN and ATH5K_ERR use net_ratelimit(), so they can be used anywhere without having to check net_ratelimit() seperately.

the macros get a reference to sc, so we can automatically add additional
information: right now it is used to get the phy name, but having this in one central place gived us the flexibility to switch to dev_info/warn/... or others instead too. i think using "phyX" makes the output most readable and easier to match with the output from mac80211. in cases where we don't have sc available we still use ATH5K_PRINTF.

changed all printk, most dev_info and most AR5K_PRINTF lines to use these macros instead. deleted AR5K_PRINT because it's easy to use ATH5K_PRINTF instead.

for base.c
Changes-licensed-under: 3-clause-BSD

for all others...
Changes-licensed-under: ISC

---
 drivers/net/wireless/ath5k/ath5k.h |   23 ++++++++-
 drivers/net/wireless/ath5k/base.c  |   94 ++++++++++++++++-------------------
 drivers/net/wireless/ath5k/hw.c    |   78 +++++++++++++++++-------------
 drivers/net/wireless/ath5k/phy.c   |   31 +++++++-----
 4 files changed, 126 insertions(+), 100 deletions(-)
drivers/net/wireless/ath5k/ath5k.h +21 -2
index c5e37d2..1b542f9 100644
@@ -69,8 +69,27 @@
   GENERIC DRIVER DEFINITIONS
 \****************************/
 
-#define AR5K_PRINTF(fmt, ...)   printk("%s: " fmt, __func__, ##__VA_ARGS__)
-#define AR5K_PRINT(fmt)         printk("%s: " fmt, __func__)
+#define ATH5K_PRINTF(fmt, ...)   printk("%s: " fmt, __func__, ##__VA_ARGS__)
+
+#define ATH5K_PRINTK(_sc, _level, _fmt, ...) \
+	printk(_level "ath5k %s: " _fmt, \
+		((_sc) && (_sc)->hw) ? wiphy_name((_sc)->hw->wiphy) : "", \
+		##__VA_ARGS__)
+
+#define ATH5K_PRINTK_LIMIT(_sc, _level, _fmt, ...) do { \
+	if (net_ratelimit()) \
+		ATH5K_PRINTK(_sc, _level, _fmt, ##__VA_ARGS__); \
+	} while (0)
+
+#define ATH5K_INFO(_sc, _fmt, ...) \
+	ATH5K_PRINTK(_sc, KERN_INFO, _fmt, ##__VA_ARGS__)
+
+#define ATH5K_WARN(_sc, _fmt, ...) \
+	ATH5K_PRINTK_LIMIT(_sc, KERN_WARNING, _fmt, ##__VA_ARGS__)
+
+#define ATH5K_ERR(_sc, _fmt, ...) \
+	ATH5K_PRINTK_LIMIT(_sc, KERN_ERR, _fmt, ##__VA_ARGS__)
+
 #ifdef AR5K_DEBUG
 #define AR5K_TRACE              printk(KERN_DEBUG "%s:%d\n", __func__, __LINE__)
 #else
drivers/net/wireless/ath5k/base.c +43 -51

312 lines not on this page · raw message

drivers/net/wireless/ath5k/hw.c +45 -33

250 lines not on this page · raw message

drivers/net/wireless/ath5k/phy.c +17 -14
index d5aec18..a4968b6 100644
@@ -23,6 +23,7 @@
 
 #include "ath5k.h"
 #include "reg.h"
+#include "base.h"
 
 /* Struct to hold initial RF register values (RF Banks) */
 struct ath5k_ini_rf {
@@ -719,7 +720,7 @@ static unsigned int ath5k_hw_rfregs_op(u32 *rf, u32 offset, u32 reg, u32 bits,
 		return 0;
 
 	if (!(col <= 3 && bits <= 32 && first + bits <= 319)) {
-		AR5K_PRINTF("invalid values at offset %u\n", offset);
+		ATH5K_PRINTF("invalid values at offset %u\n", offset);
 		return 0;
 	}
 
@@ -880,11 +881,10 @@ static s32 ath5k_hw_rfregs_gain_adjust(struct ath5k_hw *ah)
 
 done:
 #ifdef AR5K_DEBUG
-	AR5K_PRINTF("ret %d, gain step %u, current gain %u, target gain %u\n",
+	ATH5K_PRINTF("ret %d, gain step %u, current gain %u, target gain %u\n",
 		ret, ah->ah_gain.g_step_idx, ah->ah_gain.g_current,
 		ah->ah_gain.g_target);
 #endif
-
 	return ret;
 }
 
@@ -908,7 +908,7 @@ static int ath5k_hw_rf5111_rfregs(struct ath5k_hw *ah,
 	/* Copy values to modify them */
 	for (i = 0; i < rf_size; i++) {
 		if (rfregs_5111[i].rf_bank >= AR5K_RF5111_INI_RF_MAX_BANKS) {
-			AR5K_PRINT("invalid bank\n");
+			ATH5K_ERR(ah->ah_sc, "invalid bank\n");
 			return -EINVAL;
 		}
 
@@ -1017,7 +1017,7 @@ static int ath5k_hw_rf5112_rfregs(struct ath5k_hw *ah,
 	/* Copy values to modify them */
 	for (i = 0; i < rf_size; i++) {
 		if (rf_ini[i].rf_bank >= AR5K_RF5112_INI_RF_MAX_BANKS) {
-			AR5K_PRINT("invalid bank\n");
+			ATH5K_ERR(ah->ah_sc, "invalid bank\n");
 			return -EINVAL;
 		}
 
@@ -1105,7 +1105,7 @@ static int ath5k_hw_rf5413_rfregs(struct ath5k_hw *ah,
 	/* Copy values to modify them */
 	for (i = 0; i < rf_size; i++) {
 		if (rf_ini[i].rf_bank >= AR5K_RF5112_INI_RF_MAX_BANKS) {
-			AR5K_PRINT("invalid bank\n");
+			ATH5K_ERR(ah->ah_sc, "invalid bank\n");
 			return -EINVAL;
 		}
 
@@ -1167,7 +1167,7 @@ int ath5k_hw_rfregs(struct ath5k_hw *ah, struct ieee80211_channel *channel,
 		/* XXX do extra checks? */
 		ah->ah_rf_banks = kmalloc(ah->ah_rf_banks_size, GFP_KERNEL);
 		if (ah->ah_rf_banks == NULL) {
-			AR5K_PRINT("out of memory\n");
+			ATH5K_ERR(ah->ah_sc, "out of memory\n");
 			return -ENOMEM;
 		}
 	}
@@ -1484,7 +1484,8 @@ int ath5k_hw_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel)
 	    channel->freq > ah->ah_capabilities.cap_range.range_2ghz_max) &&
 	    (channel->freq < ah->ah_capabilities.cap_range.range_5ghz_min ||
 	    channel->freq > ah->ah_capabilities.cap_range.range_5ghz_max)) {
-		AR5K_PRINTF("channel out of supported range (%u MHz)\n",
+		ATH5K_ERR(ah->ah_sc,
+			"channel out of supported range (%u MHz)\n",
 			channel->freq);
 		return -EINVAL;
 	}
@@ -1605,7 +1606,8 @@ static int ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah,
 	ath5k_hw_reg_write(ah, phy_sat, AR5K_PHY_ADCSAT);
 
 	if (ret) {
-		AR5K_PRINTF("calibration timeout (%uMHz)\n", channel->freq);
+		ATH5K_ERR(ah->ah_sc, "calibration timeout (%uMHz)\n",
+				channel->freq);
 		return ret;
 	}
 
@@ -1617,8 +1619,9 @@ static int ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah,
 	ret = ath5k_hw_register_timeout(ah, AR5K_PHY_AGCCTL,
 			AR5K_PHY_AGCCTL_NF, 0, false);
 	if (ret) {
-		AR5K_PRINTF("noise floor calibration timeout (%uMHz)\n",
-				channel->freq);
+		ATH5K_ERR(ah->ah_sc,
+			"noise floor calibration timeout (%uMHz)\n",
+			channel->freq);
 		return ret;
 	}
 
@@ -1635,7 +1638,7 @@ static int ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah,
 	}
 
 	if (noise_floor > AR5K_TUNE_NOISE_FLOOR) {
-		AR5K_PRINTF("noise floor calibration failed (%uMHz)\n",
+		ATH5K_ERR(ah->ah_sc, "noise floor calibration failed (%uMHz)\n",
 			channel->freq);
 		return -EIO;
 	}
@@ -1847,7 +1850,7 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
 
 	AR5K_TRACE;
 	if (txpower > AR5K_TUNE_MAX_TXPOWER) {
-		AR5K_PRINTF("invalid tx power: %u\n", txpower);
+		ATH5K_ERR(ah->ah_sc, "invalid tx power: %u\n", txpower);
 		return -EINVAL;
 	}
 
@@ -1901,7 +1904,7 @@ int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, unsigned int power)
 
 	AR5K_TRACE;
 #ifdef AR5K_DEBUG
-	AR5K_PRINTF("changing txpower to %d\n", power);
+	ATH5K_PRINTF("changing txpower to %d\n", power);
 #endif
 	return ath5k_hw_txpower(ah, channel, power);
 }
Signature · 1 line
1.5.3.4
#1 lore raw
Quoted 17 lines · Bruno Randolf

added new macros ATH5K_INFO, ATH5K_WARN and ATH5K_ERR for more consistent logging inside ath5k. they prepend "ath5k phyX:" to all lines so we can distinguish between different cards in multi-card setups. ATH5K_WARN and ATH5K_ERR use net_ratelimit(), so they can be used anywhere without having to check net_ratelimit() seperately.

the macros get a reference to sc, so we can automatically add additional
information: right now it is used to get the phy name, but having this in one central place gived us the flexibility to switch to dev_info/warn/... or others instead too. i think using "phyX" makes the output most readable and easier to match with the output from mac80211. in cases where we don't have sc available we still use ATH5K_PRINTF.

changed all printk, most dev_info and most AR5K_PRINTF lines to use these macros instead. deleted AR5K_PRINT because it's easy to use ATH5K_PRINTF instead.

Quoted 7 lines

for base.c
Changes-licensed-under: 3-clause-BSD

for all others...
Changes-licensed-under: ISC

Thanks for splitting this. I believe you missed some notes I made in the previous e-mail. The boring legal notes are specially important.

Luis