debug.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. /*
  2. * Copyright (c) 2008-2009 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <asm/unaligned.h>
  17. #include "ath9k.h"
  18. static unsigned int ath9k_debug = DBG_DEFAULT;
  19. module_param_named(debug, ath9k_debug, uint, 0);
  20. static struct dentry *ath9k_debugfs_root;
  21. void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...)
  22. {
  23. if (!sc)
  24. return;
  25. if (sc->debug.debug_mask & dbg_mask) {
  26. va_list args;
  27. va_start(args, fmt);
  28. printk(KERN_DEBUG "ath9k: ");
  29. vprintk(fmt, args);
  30. va_end(args);
  31. }
  32. }
  33. static int ath9k_debugfs_open(struct inode *inode, struct file *file)
  34. {
  35. file->private_data = inode->i_private;
  36. return 0;
  37. }
  38. static ssize_t read_file_debug(struct file *file, char __user *user_buf,
  39. size_t count, loff_t *ppos)
  40. {
  41. struct ath_softc *sc = file->private_data;
  42. char buf[32];
  43. unsigned int len = 0;
  44. len += snprintf(buf, sizeof(buf), "0x%08x\n", sc->debug.debug_mask);
  45. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  46. }
  47. static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
  48. size_t count, loff_t *ppos)
  49. {
  50. struct ath_softc *sc = file->private_data;
  51. unsigned long mask;
  52. char buf[32];
  53. if (copy_from_user(buf, user_buf, (sizeof(buf) - 1) < count ?
  54. (sizeof(buf) - 1) : count))
  55. return 0;
  56. buf[sizeof(buf)-1] = 0;
  57. if (strict_strtoul(buf, 0, &mask) == 0)
  58. sc->debug.debug_mask = mask;
  59. return count;
  60. }
  61. static const struct file_operations fops_debug = {
  62. .read = read_file_debug,
  63. .write = write_file_debug,
  64. .open = ath9k_debugfs_open,
  65. .owner = THIS_MODULE
  66. };
  67. static ssize_t read_file_dma(struct file *file, char __user *user_buf,
  68. size_t count, loff_t *ppos)
  69. {
  70. struct ath_softc *sc = file->private_data;
  71. struct ath_hw *ah = sc->sc_ah;
  72. char buf[1024];
  73. unsigned int len = 0;
  74. u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
  75. int i, qcuOffset = 0, dcuOffset = 0;
  76. u32 *qcuBase = &val[0], *dcuBase = &val[4];
  77. REG_WRITE(ah, AR_MACMISC,
  78. ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
  79. (AR_MACMISC_MISC_OBS_BUS_1 <<
  80. AR_MACMISC_MISC_OBS_BUS_MSB_S)));
  81. len += snprintf(buf + len, sizeof(buf) - len,
  82. "Raw DMA Debug values:\n");
  83. for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
  84. if (i % 4 == 0)
  85. len += snprintf(buf + len, sizeof(buf) - len, "\n");
  86. val[i] = REG_READ(ah, AR_DMADBG_0 + (i * sizeof(u32)));
  87. len += snprintf(buf + len, sizeof(buf) - len, "%d: %08x ",
  88. i, val[i]);
  89. }
  90. len += snprintf(buf + len, sizeof(buf) - len, "\n\n");
  91. len += snprintf(buf + len, sizeof(buf) - len,
  92. "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
  93. for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
  94. if (i == 8) {
  95. qcuOffset = 0;
  96. qcuBase++;
  97. }
  98. if (i == 6) {
  99. dcuOffset = 0;
  100. dcuBase++;
  101. }
  102. len += snprintf(buf + len, sizeof(buf) - len,
  103. "%2d %2x %1x %2x %2x\n",
  104. i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
  105. (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
  106. val[2] & (0x7 << (i * 3)) >> (i * 3),
  107. (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
  108. }
  109. len += snprintf(buf + len, sizeof(buf) - len, "\n");
  110. len += snprintf(buf + len, sizeof(buf) - len,
  111. "qcu_stitch state: %2x qcu_fetch state: %2x\n",
  112. (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
  113. len += snprintf(buf + len, sizeof(buf) - len,
  114. "qcu_complete state: %2x dcu_complete state: %2x\n",
  115. (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
  116. len += snprintf(buf + len, sizeof(buf) - len,
  117. "dcu_arb state: %2x dcu_fp state: %2x\n",
  118. (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
  119. len += snprintf(buf + len, sizeof(buf) - len,
  120. "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
  121. (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
  122. len += snprintf(buf + len, sizeof(buf) - len,
  123. "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
  124. (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
  125. len += snprintf(buf + len, sizeof(buf) - len,
  126. "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
  127. (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
  128. len += snprintf(buf + len, sizeof(buf) - len, "pcu observe: 0x%x \n",
  129. REG_READ(ah, AR_OBS_BUS_1));
  130. len += snprintf(buf + len, sizeof(buf) - len,
  131. "AR_CR: 0x%x \n", REG_READ(ah, AR_CR));
  132. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  133. }
  134. static const struct file_operations fops_dma = {
  135. .read = read_file_dma,
  136. .open = ath9k_debugfs_open,
  137. .owner = THIS_MODULE
  138. };
  139. void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
  140. {
  141. if (status)
  142. sc->debug.stats.istats.total++;
  143. if (status & ATH9K_INT_RX)
  144. sc->debug.stats.istats.rxok++;
  145. if (status & ATH9K_INT_RXEOL)
  146. sc->debug.stats.istats.rxeol++;
  147. if (status & ATH9K_INT_RXORN)
  148. sc->debug.stats.istats.rxorn++;
  149. if (status & ATH9K_INT_TX)
  150. sc->debug.stats.istats.txok++;
  151. if (status & ATH9K_INT_TXURN)
  152. sc->debug.stats.istats.txurn++;
  153. if (status & ATH9K_INT_MIB)
  154. sc->debug.stats.istats.mib++;
  155. if (status & ATH9K_INT_RXPHY)
  156. sc->debug.stats.istats.rxphyerr++;
  157. if (status & ATH9K_INT_RXKCM)
  158. sc->debug.stats.istats.rx_keycache_miss++;
  159. if (status & ATH9K_INT_SWBA)
  160. sc->debug.stats.istats.swba++;
  161. if (status & ATH9K_INT_BMISS)
  162. sc->debug.stats.istats.bmiss++;
  163. if (status & ATH9K_INT_BNR)
  164. sc->debug.stats.istats.bnr++;
  165. if (status & ATH9K_INT_CST)
  166. sc->debug.stats.istats.cst++;
  167. if (status & ATH9K_INT_GTT)
  168. sc->debug.stats.istats.gtt++;
  169. if (status & ATH9K_INT_TIM)
  170. sc->debug.stats.istats.tim++;
  171. if (status & ATH9K_INT_CABEND)
  172. sc->debug.stats.istats.cabend++;
  173. if (status & ATH9K_INT_DTIMSYNC)
  174. sc->debug.stats.istats.dtimsync++;
  175. if (status & ATH9K_INT_DTIM)
  176. sc->debug.stats.istats.dtim++;
  177. }
  178. static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
  179. size_t count, loff_t *ppos)
  180. {
  181. struct ath_softc *sc = file->private_data;
  182. char buf[512];
  183. unsigned int len = 0;
  184. len += snprintf(buf + len, sizeof(buf) - len,
  185. "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok);
  186. len += snprintf(buf + len, sizeof(buf) - len,
  187. "%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol);
  188. len += snprintf(buf + len, sizeof(buf) - len,
  189. "%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn);
  190. len += snprintf(buf + len, sizeof(buf) - len,
  191. "%8s: %10u\n", "TX", sc->debug.stats.istats.txok);
  192. len += snprintf(buf + len, sizeof(buf) - len,
  193. "%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn);
  194. len += snprintf(buf + len, sizeof(buf) - len,
  195. "%8s: %10u\n", "MIB", sc->debug.stats.istats.mib);
  196. len += snprintf(buf + len, sizeof(buf) - len,
  197. "%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr);
  198. len += snprintf(buf + len, sizeof(buf) - len,
  199. "%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss);
  200. len += snprintf(buf + len, sizeof(buf) - len,
  201. "%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba);
  202. len += snprintf(buf + len, sizeof(buf) - len,
  203. "%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss);
  204. len += snprintf(buf + len, sizeof(buf) - len,
  205. "%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr);
  206. len += snprintf(buf + len, sizeof(buf) - len,
  207. "%8s: %10u\n", "CST", sc->debug.stats.istats.cst);
  208. len += snprintf(buf + len, sizeof(buf) - len,
  209. "%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt);
  210. len += snprintf(buf + len, sizeof(buf) - len,
  211. "%8s: %10u\n", "TIM", sc->debug.stats.istats.tim);
  212. len += snprintf(buf + len, sizeof(buf) - len,
  213. "%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend);
  214. len += snprintf(buf + len, sizeof(buf) - len,
  215. "%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync);
  216. len += snprintf(buf + len, sizeof(buf) - len,
  217. "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim);
  218. len += snprintf(buf + len, sizeof(buf) - len,
  219. "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total);
  220. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  221. }
  222. static const struct file_operations fops_interrupt = {
  223. .read = read_file_interrupt,
  224. .open = ath9k_debugfs_open,
  225. .owner = THIS_MODULE
  226. };
  227. void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb)
  228. {
  229. struct ath_tx_info_priv *tx_info_priv = NULL;
  230. struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
  231. struct ieee80211_tx_rate *rates = tx_info->status.rates;
  232. int final_ts_idx, idx;
  233. struct ath_rc_stats *stats;
  234. tx_info_priv = ATH_TX_INFO_PRIV(tx_info);
  235. final_ts_idx = tx_info_priv->tx.ts_rateindex;
  236. idx = rates[final_ts_idx].idx;
  237. stats = &sc->debug.stats.rcstats[idx];
  238. stats->success++;
  239. }
  240. void ath_debug_stat_retries(struct ath_softc *sc, int rix,
  241. int xretries, int retries, u8 per)
  242. {
  243. struct ath_rc_stats *stats = &sc->debug.stats.rcstats[rix];
  244. stats->xretries += xretries;
  245. stats->retries += retries;
  246. stats->per = per;
  247. }
  248. static ssize_t read_file_rcstat(struct file *file, char __user *user_buf,
  249. size_t count, loff_t *ppos)
  250. {
  251. struct ath_softc *sc = file->private_data;
  252. char *buf;
  253. unsigned int len = 0, max;
  254. int i = 0;
  255. ssize_t retval;
  256. if (sc->cur_rate_table == NULL)
  257. return 0;
  258. max = 80 + sc->cur_rate_table->rate_cnt * 64;
  259. buf = kmalloc(max + 1, GFP_KERNEL);
  260. if (buf == NULL)
  261. return 0;
  262. buf[max] = 0;
  263. len += sprintf(buf, "%5s %15s %8s %9s %3s\n\n", "Rate", "Success",
  264. "Retries", "XRetries", "PER");
  265. for (i = 0; i < sc->cur_rate_table->rate_cnt; i++) {
  266. u32 ratekbps = sc->cur_rate_table->info[i].ratekbps;
  267. struct ath_rc_stats *stats = &sc->debug.stats.rcstats[i];
  268. len += snprintf(buf + len, max - len,
  269. "%3u.%d: %8u %8u %8u %8u\n", ratekbps / 1000,
  270. (ratekbps % 1000) / 100, stats->success,
  271. stats->retries, stats->xretries,
  272. stats->per);
  273. }
  274. retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
  275. kfree(buf);
  276. return retval;
  277. }
  278. static const struct file_operations fops_rcstat = {
  279. .read = read_file_rcstat,
  280. .open = ath9k_debugfs_open,
  281. .owner = THIS_MODULE
  282. };
  283. static const char * ath_wiphy_state_str(enum ath_wiphy_state state)
  284. {
  285. switch (state) {
  286. case ATH_WIPHY_INACTIVE:
  287. return "INACTIVE";
  288. case ATH_WIPHY_ACTIVE:
  289. return "ACTIVE";
  290. case ATH_WIPHY_PAUSING:
  291. return "PAUSING";
  292. case ATH_WIPHY_PAUSED:
  293. return "PAUSED";
  294. case ATH_WIPHY_SCAN:
  295. return "SCAN";
  296. }
  297. return "?";
  298. }
  299. static ssize_t read_file_wiphy(struct file *file, char __user *user_buf,
  300. size_t count, loff_t *ppos)
  301. {
  302. struct ath_softc *sc = file->private_data;
  303. char buf[512];
  304. unsigned int len = 0;
  305. int i;
  306. u8 addr[ETH_ALEN];
  307. len += snprintf(buf + len, sizeof(buf) - len,
  308. "primary: %s (%s chan=%d ht=%d)\n",
  309. wiphy_name(sc->pri_wiphy->hw->wiphy),
  310. ath_wiphy_state_str(sc->pri_wiphy->state),
  311. sc->pri_wiphy->chan_idx, sc->pri_wiphy->chan_is_ht);
  312. for (i = 0; i < sc->num_sec_wiphy; i++) {
  313. struct ath_wiphy *aphy = sc->sec_wiphy[i];
  314. if (aphy == NULL)
  315. continue;
  316. len += snprintf(buf + len, sizeof(buf) - len,
  317. "secondary: %s (%s chan=%d ht=%d)\n",
  318. wiphy_name(aphy->hw->wiphy),
  319. ath_wiphy_state_str(aphy->state),
  320. aphy->chan_idx, aphy->chan_is_ht);
  321. }
  322. put_unaligned_le32(REG_READ(sc->sc_ah, AR_STA_ID0), addr);
  323. put_unaligned_le16(REG_READ(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4);
  324. len += snprintf(buf + len, sizeof(buf) - len,
  325. "addr: %pM\n", addr);
  326. put_unaligned_le32(REG_READ(sc->sc_ah, AR_BSSMSKL), addr);
  327. put_unaligned_le16(REG_READ(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4);
  328. len += snprintf(buf + len, sizeof(buf) - len,
  329. "addrmask: %pM\n", addr);
  330. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  331. }
  332. static struct ath_wiphy * get_wiphy(struct ath_softc *sc, const char *name)
  333. {
  334. int i;
  335. if (strcmp(name, wiphy_name(sc->pri_wiphy->hw->wiphy)) == 0)
  336. return sc->pri_wiphy;
  337. for (i = 0; i < sc->num_sec_wiphy; i++) {
  338. struct ath_wiphy *aphy = sc->sec_wiphy[i];
  339. if (aphy && strcmp(name, wiphy_name(aphy->hw->wiphy)) == 0)
  340. return aphy;
  341. }
  342. return NULL;
  343. }
  344. static int del_wiphy(struct ath_softc *sc, const char *name)
  345. {
  346. struct ath_wiphy *aphy = get_wiphy(sc, name);
  347. if (!aphy)
  348. return -ENOENT;
  349. return ath9k_wiphy_del(aphy);
  350. }
  351. static int pause_wiphy(struct ath_softc *sc, const char *name)
  352. {
  353. struct ath_wiphy *aphy = get_wiphy(sc, name);
  354. if (!aphy)
  355. return -ENOENT;
  356. return ath9k_wiphy_pause(aphy);
  357. }
  358. static int unpause_wiphy(struct ath_softc *sc, const char *name)
  359. {
  360. struct ath_wiphy *aphy = get_wiphy(sc, name);
  361. if (!aphy)
  362. return -ENOENT;
  363. return ath9k_wiphy_unpause(aphy);
  364. }
  365. static int select_wiphy(struct ath_softc *sc, const char *name)
  366. {
  367. struct ath_wiphy *aphy = get_wiphy(sc, name);
  368. if (!aphy)
  369. return -ENOENT;
  370. return ath9k_wiphy_select(aphy);
  371. }
  372. static int schedule_wiphy(struct ath_softc *sc, const char *msec)
  373. {
  374. ath9k_wiphy_set_scheduler(sc, simple_strtoul(msec, NULL, 0));
  375. return 0;
  376. }
  377. static ssize_t write_file_wiphy(struct file *file, const char __user *user_buf,
  378. size_t count, loff_t *ppos)
  379. {
  380. struct ath_softc *sc = file->private_data;
  381. char buf[50];
  382. size_t len;
  383. len = min(count, sizeof(buf) - 1);
  384. if (copy_from_user(buf, user_buf, len))
  385. return -EFAULT;
  386. buf[len] = '\0';
  387. if (len > 0 && buf[len - 1] == '\n')
  388. buf[len - 1] = '\0';
  389. if (strncmp(buf, "add", 3) == 0) {
  390. int res = ath9k_wiphy_add(sc);
  391. if (res < 0)
  392. return res;
  393. } else if (strncmp(buf, "del=", 4) == 0) {
  394. int res = del_wiphy(sc, buf + 4);
  395. if (res < 0)
  396. return res;
  397. } else if (strncmp(buf, "pause=", 6) == 0) {
  398. int res = pause_wiphy(sc, buf + 6);
  399. if (res < 0)
  400. return res;
  401. } else if (strncmp(buf, "unpause=", 8) == 0) {
  402. int res = unpause_wiphy(sc, buf + 8);
  403. if (res < 0)
  404. return res;
  405. } else if (strncmp(buf, "select=", 7) == 0) {
  406. int res = select_wiphy(sc, buf + 7);
  407. if (res < 0)
  408. return res;
  409. } else if (strncmp(buf, "schedule=", 9) == 0) {
  410. int res = schedule_wiphy(sc, buf + 9);
  411. if (res < 0)
  412. return res;
  413. } else
  414. return -EOPNOTSUPP;
  415. return count;
  416. }
  417. static const struct file_operations fops_wiphy = {
  418. .read = read_file_wiphy,
  419. .write = write_file_wiphy,
  420. .open = ath9k_debugfs_open,
  421. .owner = THIS_MODULE
  422. };
  423. int ath9k_init_debug(struct ath_softc *sc)
  424. {
  425. sc->debug.debug_mask = ath9k_debug;
  426. if (!ath9k_debugfs_root)
  427. return -ENOENT;
  428. sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
  429. ath9k_debugfs_root);
  430. if (!sc->debug.debugfs_phy)
  431. goto err;
  432. sc->debug.debugfs_debug = debugfs_create_file("debug",
  433. S_IRUGO | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug);
  434. if (!sc->debug.debugfs_debug)
  435. goto err;
  436. sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUGO,
  437. sc->debug.debugfs_phy, sc, &fops_dma);
  438. if (!sc->debug.debugfs_dma)
  439. goto err;
  440. sc->debug.debugfs_interrupt = debugfs_create_file("interrupt",
  441. S_IRUGO,
  442. sc->debug.debugfs_phy,
  443. sc, &fops_interrupt);
  444. if (!sc->debug.debugfs_interrupt)
  445. goto err;
  446. sc->debug.debugfs_rcstat = debugfs_create_file("rcstat",
  447. S_IRUGO,
  448. sc->debug.debugfs_phy,
  449. sc, &fops_rcstat);
  450. if (!sc->debug.debugfs_rcstat)
  451. goto err;
  452. sc->debug.debugfs_wiphy = debugfs_create_file(
  453. "wiphy", S_IRUGO | S_IWUSR, sc->debug.debugfs_phy, sc,
  454. &fops_wiphy);
  455. if (!sc->debug.debugfs_wiphy)
  456. goto err;
  457. return 0;
  458. err:
  459. ath9k_exit_debug(sc);
  460. return -ENOMEM;
  461. }
  462. void ath9k_exit_debug(struct ath_softc *sc)
  463. {
  464. debugfs_remove(sc->debug.debugfs_wiphy);
  465. debugfs_remove(sc->debug.debugfs_rcstat);
  466. debugfs_remove(sc->debug.debugfs_interrupt);
  467. debugfs_remove(sc->debug.debugfs_dma);
  468. debugfs_remove(sc->debug.debugfs_debug);
  469. debugfs_remove(sc->debug.debugfs_phy);
  470. }
  471. int ath9k_debug_create_root(void)
  472. {
  473. ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
  474. if (!ath9k_debugfs_root)
  475. return -ENOENT;
  476. return 0;
  477. }
  478. void ath9k_debug_remove_root(void)
  479. {
  480. debugfs_remove(ath9k_debugfs_root);
  481. ath9k_debugfs_root = NULL;
  482. }