Skip to content

Commit

Permalink
ath9k: Use macro to decrease code when priting recv stats.
Browse files Browse the repository at this point in the history
This hides some repetitive code, and will help if the
column widths ever need to change.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Ben Greear authored and John W. Linville committed Apr 16, 2012
1 parent bb3e10f commit 24a0731
Showing 1 changed file with 24 additions and 48 deletions.
72 changes: 24 additions & 48 deletions drivers/net/wireless/ath/ath9k/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,13 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
len += snprintf(buf + len, size - len, "%22s : %10u\n", s, \
sc->debug.stats.rxstats.phy_err_stats[p]);

#define RXS_ERR(s, e) \
do { \
len += snprintf(buf + len, size - len, \
"%22s : %10u\n", s, \
sc->debug.stats.rxstats.e); \
} while (0)

struct ath_softc *sc = file->private_data;
char *buf;
unsigned int len = 0, size = 1600;
Expand All @@ -890,42 +897,18 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
if (buf == NULL)
return -ENOMEM;

len += snprintf(buf + len, size - len,
"%22s : %10u\n", "CRC ERR",
sc->debug.stats.rxstats.crc_err);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "DECRYPT CRC ERR",
sc->debug.stats.rxstats.decrypt_crc_err);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "PHY ERR",
sc->debug.stats.rxstats.phy_err);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "MIC ERR",
sc->debug.stats.rxstats.mic_err);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "PRE-DELIM CRC ERR",
sc->debug.stats.rxstats.pre_delim_crc_err);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "POST-DELIM CRC ERR",
sc->debug.stats.rxstats.post_delim_crc_err);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "DECRYPT BUSY ERR",
sc->debug.stats.rxstats.decrypt_busy_err);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "RX-LENGTH-ERR",
sc->debug.stats.rxstats.rx_len_err);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "RX-OOM-ERR",
sc->debug.stats.rxstats.rx_oom_err);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "RX-RATE-ERR",
sc->debug.stats.rxstats.rx_rate_err);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "RX-DROP-RXFLUSH",
sc->debug.stats.rxstats.rx_drop_rxflush);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "RX-TOO-MANY-FRAGS",
sc->debug.stats.rxstats.rx_too_many_frags_err);
RXS_ERR("CRC ERR", crc_err);
RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err);
RXS_ERR("PHY ERR", phy_err);
RXS_ERR("MIC ERR", mic_err);
RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err);
RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err);
RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err);
RXS_ERR("RX-LENGTH-ERR", rx_len_err);
RXS_ERR("RX-OOM-ERR", rx_oom_err);
RXS_ERR("RX-RATE-ERR", rx_rate_err);
RXS_ERR("RX-DROP-RXFLUSH", rx_drop_rxflush);
RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err);

PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING);
Expand Down Expand Up @@ -954,18 +937,10 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL);

len += snprintf(buf + len, size - len,
"%22s : %10u\n", "RX-Pkts-All",
sc->debug.stats.rxstats.rx_pkts_all);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "RX-Bytes-All",
sc->debug.stats.rxstats.rx_bytes_all);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "RX-Beacons",
sc->debug.stats.rxstats.rx_beacons);
len += snprintf(buf + len, size - len,
"%22s : %10u\n", "RX-Frags",
sc->debug.stats.rxstats.rx_frags);
RXS_ERR("RX-Pkts-All", rx_pkts_all);
RXS_ERR("RX-Bytes-All", rx_bytes_all);
RXS_ERR("RX-Beacons", rx_beacons);
RXS_ERR("RX-Frags", rx_frags);

if (len > size)
len = size;
Expand All @@ -975,6 +950,7 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,

return retval;

#undef RXS_ERR
#undef PHY_ERR
}

Expand Down

0 comments on commit 24a0731

Please sign in to comment.