debugfs.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. /*
  2. Broadcom B43 wireless driver
  3. debugfs driver debugging code
  4. Copyright (c) 2005-2007 Michael Buesch <mb@bu3sch.de>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; see the file COPYING. If not, write to
  15. the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
  16. Boston, MA 02110-1301, USA.
  17. */
  18. #include <linux/fs.h>
  19. #include <linux/debugfs.h>
  20. #include <linux/slab.h>
  21. #include <linux/netdevice.h>
  22. #include <linux/pci.h>
  23. #include <linux/mutex.h>
  24. #include "b43.h"
  25. #include "main.h"
  26. #include "debugfs.h"
  27. #include "dma.h"
  28. #include "pio.h"
  29. #include "xmit.h"
  30. /* The root directory. */
  31. static struct dentry *rootdir;
  32. struct b43_debugfs_fops {
  33. ssize_t (*read)(struct b43_wldev *dev, char *buf, size_t bufsize);
  34. int (*write)(struct b43_wldev *dev, const char *buf, size_t count);
  35. struct file_operations fops;
  36. /* Offset of struct b43_dfs_file in struct b43_dfsentry */
  37. size_t file_struct_offset;
  38. /* Take wl->irq_lock before calling read/write? */
  39. bool take_irqlock;
  40. };
  41. static inline
  42. struct b43_dfs_file * fops_to_dfs_file(struct b43_wldev *dev,
  43. const struct b43_debugfs_fops *dfops)
  44. {
  45. void *p;
  46. p = dev->dfsentry;
  47. p += dfops->file_struct_offset;
  48. return p;
  49. }
  50. #define fappend(fmt, x...) \
  51. do { \
  52. if (bufsize - count) \
  53. count += snprintf(buf + count, \
  54. bufsize - count, \
  55. fmt , ##x); \
  56. else \
  57. printk(KERN_ERR "b43: fappend overflow\n"); \
  58. } while (0)
  59. /* wl->irq_lock is locked */
  60. static ssize_t tsf_read_file(struct b43_wldev *dev,
  61. char *buf, size_t bufsize)
  62. {
  63. ssize_t count = 0;
  64. u64 tsf;
  65. b43_tsf_read(dev, &tsf);
  66. fappend("0x%08x%08x\n",
  67. (unsigned int)((tsf & 0xFFFFFFFF00000000ULL) >> 32),
  68. (unsigned int)(tsf & 0xFFFFFFFFULL));
  69. return count;
  70. }
  71. /* wl->irq_lock is locked */
  72. static int tsf_write_file(struct b43_wldev *dev,
  73. const char *buf, size_t count)
  74. {
  75. u64 tsf;
  76. if (sscanf(buf, "%llu", (unsigned long long *)(&tsf)) != 1)
  77. return -EINVAL;
  78. b43_tsf_write(dev, tsf);
  79. return 0;
  80. }
  81. /* wl->irq_lock is locked */
  82. static ssize_t ucode_regs_read_file(struct b43_wldev *dev,
  83. char *buf, size_t bufsize)
  84. {
  85. ssize_t count = 0;
  86. int i;
  87. for (i = 0; i < 64; i++) {
  88. fappend("r%d = 0x%04x\n", i,
  89. b43_shm_read16(dev, B43_SHM_SCRATCH, i));
  90. }
  91. return count;
  92. }
  93. /* wl->irq_lock is locked */
  94. static ssize_t shm_read_file(struct b43_wldev *dev,
  95. char *buf, size_t bufsize)
  96. {
  97. ssize_t count = 0;
  98. int i;
  99. u16 tmp;
  100. __le16 *le16buf = (__le16 *)buf;
  101. for (i = 0; i < 0x1000; i++) {
  102. if (bufsize < sizeof(tmp))
  103. break;
  104. tmp = b43_shm_read16(dev, B43_SHM_SHARED, 2 * i);
  105. le16buf[i] = cpu_to_le16(tmp);
  106. count += sizeof(tmp);
  107. bufsize -= sizeof(tmp);
  108. }
  109. return count;
  110. }
  111. static ssize_t txstat_read_file(struct b43_wldev *dev,
  112. char *buf, size_t bufsize)
  113. {
  114. struct b43_txstatus_log *log = &dev->dfsentry->txstatlog;
  115. ssize_t count = 0;
  116. unsigned long flags;
  117. int i, idx;
  118. struct b43_txstatus *stat;
  119. spin_lock_irqsave(&log->lock, flags);
  120. if (log->end < 0) {
  121. fappend("Nothing transmitted, yet\n");
  122. goto out_unlock;
  123. }
  124. fappend("b43 TX status reports:\n\n"
  125. "index | cookie | seq | phy_stat | frame_count | "
  126. "rts_count | supp_reason | pm_indicated | "
  127. "intermediate | for_ampdu | acked\n" "---\n");
  128. i = log->end + 1;
  129. idx = 0;
  130. while (1) {
  131. if (i == B43_NR_LOGGED_TXSTATUS)
  132. i = 0;
  133. stat = &(log->log[i]);
  134. if (stat->cookie) {
  135. fappend("%03d | "
  136. "0x%04X | 0x%04X | 0x%02X | "
  137. "0x%X | 0x%X | "
  138. "%u | %u | "
  139. "%u | %u | %u\n",
  140. idx,
  141. stat->cookie, stat->seq, stat->phy_stat,
  142. stat->frame_count, stat->rts_count,
  143. stat->supp_reason, stat->pm_indicated,
  144. stat->intermediate, stat->for_ampdu,
  145. stat->acked);
  146. idx++;
  147. }
  148. if (i == log->end)
  149. break;
  150. i++;
  151. }
  152. out_unlock:
  153. spin_unlock_irqrestore(&log->lock, flags);
  154. return count;
  155. }
  156. static ssize_t txpower_g_read_file(struct b43_wldev *dev,
  157. char *buf, size_t bufsize)
  158. {
  159. ssize_t count = 0;
  160. if (dev->phy.type != B43_PHYTYPE_G) {
  161. fappend("Device is not a G-PHY\n");
  162. goto out;
  163. }
  164. fappend("Control: %s\n", dev->phy.manual_txpower_control ?
  165. "MANUAL" : "AUTOMATIC");
  166. fappend("Baseband attenuation: %u\n", dev->phy.bbatt.att);
  167. fappend("Radio attenuation: %u\n", dev->phy.rfatt.att);
  168. fappend("TX Mixer Gain: %s\n",
  169. (dev->phy.tx_control & B43_TXCTL_TXMIX) ? "ON" : "OFF");
  170. fappend("PA Gain 2dB: %s\n",
  171. (dev->phy.tx_control & B43_TXCTL_PA2DB) ? "ON" : "OFF");
  172. fappend("PA Gain 3dB: %s\n",
  173. (dev->phy.tx_control & B43_TXCTL_PA3DB) ? "ON" : "OFF");
  174. fappend("\n\n");
  175. fappend("You can write to this file:\n");
  176. fappend("Writing \"auto\" enables automatic txpower control.\n");
  177. fappend
  178. ("Writing the attenuation values as \"bbatt rfatt txmix pa2db pa3db\" "
  179. "enables manual txpower control.\n");
  180. fappend("Example: 5 4 0 0 1\n");
  181. fappend("Enables manual control with Baseband attenuation 5, "
  182. "Radio attenuation 4, No TX Mixer Gain, "
  183. "No PA Gain 2dB, With PA Gain 3dB.\n");
  184. out:
  185. return count;
  186. }
  187. static int txpower_g_write_file(struct b43_wldev *dev,
  188. const char *buf, size_t count)
  189. {
  190. unsigned long phy_flags;
  191. if (dev->phy.type != B43_PHYTYPE_G)
  192. return -ENODEV;
  193. if ((count >= 4) && (memcmp(buf, "auto", 4) == 0)) {
  194. /* Automatic control */
  195. dev->phy.manual_txpower_control = 0;
  196. b43_phy_xmitpower(dev);
  197. } else {
  198. int bbatt = 0, rfatt = 0, txmix = 0, pa2db = 0, pa3db = 0;
  199. /* Manual control */
  200. if (sscanf(buf, "%d %d %d %d %d", &bbatt, &rfatt,
  201. &txmix, &pa2db, &pa3db) != 5)
  202. return -EINVAL;
  203. b43_put_attenuation_into_ranges(dev, &bbatt, &rfatt);
  204. dev->phy.manual_txpower_control = 1;
  205. dev->phy.bbatt.att = bbatt;
  206. dev->phy.rfatt.att = rfatt;
  207. dev->phy.tx_control = 0;
  208. if (txmix)
  209. dev->phy.tx_control |= B43_TXCTL_TXMIX;
  210. if (pa2db)
  211. dev->phy.tx_control |= B43_TXCTL_PA2DB;
  212. if (pa3db)
  213. dev->phy.tx_control |= B43_TXCTL_PA3DB;
  214. b43_phy_lock(dev, phy_flags);
  215. b43_radio_lock(dev);
  216. b43_set_txpower_g(dev, &dev->phy.bbatt,
  217. &dev->phy.rfatt, dev->phy.tx_control);
  218. b43_radio_unlock(dev);
  219. b43_phy_unlock(dev, phy_flags);
  220. }
  221. return 0;
  222. }
  223. /* wl->irq_lock is locked */
  224. static int restart_write_file(struct b43_wldev *dev,
  225. const char *buf, size_t count)
  226. {
  227. int err = 0;
  228. if (count > 0 && buf[0] == '1') {
  229. b43_controller_restart(dev, "manually restarted");
  230. } else
  231. err = -EINVAL;
  232. return err;
  233. }
  234. static ssize_t append_lo_table(ssize_t count, char *buf, const size_t bufsize,
  235. struct b43_loctl table[B43_NR_BB][B43_NR_RF])
  236. {
  237. unsigned int i, j;
  238. struct b43_loctl *ctl;
  239. for (i = 0; i < B43_NR_BB; i++) {
  240. for (j = 0; j < B43_NR_RF; j++) {
  241. ctl = &(table[i][j]);
  242. fappend("(bbatt %2u, rfatt %2u) -> "
  243. "(I %+3d, Q %+3d, Used: %d, Calibrated: %d)\n",
  244. i, j, ctl->i, ctl->q,
  245. ctl->used,
  246. b43_loctl_is_calibrated(ctl));
  247. }
  248. }
  249. return count;
  250. }
  251. static ssize_t loctls_read_file(struct b43_wldev *dev,
  252. char *buf, size_t bufsize)
  253. {
  254. ssize_t count = 0;
  255. struct b43_txpower_lo_control *lo;
  256. int i, err = 0;
  257. if (dev->phy.type != B43_PHYTYPE_G) {
  258. fappend("Device is not a G-PHY\n");
  259. err = -ENODEV;
  260. goto out;
  261. }
  262. lo = dev->phy.lo_control;
  263. fappend("-- Local Oscillator calibration data --\n\n");
  264. fappend("Measured: %d, Rebuild: %d, HW-power-control: %d\n",
  265. lo->lo_measured,
  266. lo->rebuild,
  267. dev->phy.hardware_power_control);
  268. fappend("TX Bias: 0x%02X, TX Magn: 0x%02X\n",
  269. lo->tx_bias, lo->tx_magn);
  270. fappend("Power Vector: 0x%08X%08X\n",
  271. (unsigned int)((lo->power_vector & 0xFFFFFFFF00000000ULL) >> 32),
  272. (unsigned int)(lo->power_vector & 0x00000000FFFFFFFFULL));
  273. fappend("\nControl table WITH PADMIX:\n");
  274. count = append_lo_table(count, buf, bufsize, lo->with_padmix);
  275. fappend("\nControl table WITHOUT PADMIX:\n");
  276. count = append_lo_table(count, buf, bufsize, lo->no_padmix);
  277. fappend("\nUsed RF attenuation values: Value(WithPadmix flag)\n");
  278. for (i = 0; i < lo->rfatt_list.len; i++) {
  279. fappend("%u(%d), ",
  280. lo->rfatt_list.list[i].att,
  281. lo->rfatt_list.list[i].with_padmix);
  282. }
  283. fappend("\n");
  284. fappend("\nUsed Baseband attenuation values:\n");
  285. for (i = 0; i < lo->bbatt_list.len; i++) {
  286. fappend("%u, ",
  287. lo->bbatt_list.list[i].att);
  288. }
  289. fappend("\n");
  290. out:
  291. return err ? err : count;
  292. }
  293. #undef fappend
  294. static int b43_debugfs_open(struct inode *inode, struct file *file)
  295. {
  296. file->private_data = inode->i_private;
  297. return 0;
  298. }
  299. static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
  300. size_t count, loff_t *ppos)
  301. {
  302. struct b43_wldev *dev;
  303. struct b43_debugfs_fops *dfops;
  304. struct b43_dfs_file *dfile;
  305. ssize_t ret;
  306. char *buf;
  307. const size_t bufsize = 1024 * 128;
  308. const size_t buforder = get_order(bufsize);
  309. int err = 0;
  310. if (!count)
  311. return 0;
  312. dev = file->private_data;
  313. if (!dev)
  314. return -ENODEV;
  315. mutex_lock(&dev->wl->mutex);
  316. if (b43_status(dev) < B43_STAT_INITIALIZED) {
  317. err = -ENODEV;
  318. goto out_unlock;
  319. }
  320. dfops = container_of(file->f_op, struct b43_debugfs_fops, fops);
  321. if (!dfops->read) {
  322. err = -ENOSYS;
  323. goto out_unlock;
  324. }
  325. dfile = fops_to_dfs_file(dev, dfops);
  326. if (!dfile->buffer) {
  327. buf = (char *)__get_free_pages(GFP_KERNEL, buforder);
  328. if (!buf) {
  329. err = -ENOMEM;
  330. goto out_unlock;
  331. }
  332. /* Sparse warns about the following memset, because it has a big
  333. * size value. That warning is bogus, so I will ignore it. --mb */
  334. memset(buf, 0, bufsize);
  335. if (dfops->take_irqlock) {
  336. spin_lock_irq(&dev->wl->irq_lock);
  337. ret = dfops->read(dev, buf, bufsize);
  338. spin_unlock_irq(&dev->wl->irq_lock);
  339. } else
  340. ret = dfops->read(dev, buf, bufsize);
  341. if (ret <= 0) {
  342. free_pages((unsigned long)buf, buforder);
  343. err = ret;
  344. goto out_unlock;
  345. }
  346. dfile->data_len = ret;
  347. dfile->buffer = buf;
  348. }
  349. ret = simple_read_from_buffer(userbuf, count, ppos,
  350. dfile->buffer,
  351. dfile->data_len);
  352. if (*ppos >= dfile->data_len) {
  353. free_pages((unsigned long)dfile->buffer, buforder);
  354. dfile->buffer = NULL;
  355. dfile->data_len = 0;
  356. }
  357. out_unlock:
  358. mutex_unlock(&dev->wl->mutex);
  359. return err ? err : ret;
  360. }
  361. static ssize_t b43_debugfs_write(struct file *file,
  362. const char __user *userbuf,
  363. size_t count, loff_t *ppos)
  364. {
  365. struct b43_wldev *dev;
  366. struct b43_debugfs_fops *dfops;
  367. char *buf;
  368. int err = 0;
  369. if (!count)
  370. return 0;
  371. if (count > PAGE_SIZE)
  372. return -E2BIG;
  373. dev = file->private_data;
  374. if (!dev)
  375. return -ENODEV;
  376. mutex_lock(&dev->wl->mutex);
  377. if (b43_status(dev) < B43_STAT_INITIALIZED) {
  378. err = -ENODEV;
  379. goto out_unlock;
  380. }
  381. dfops = container_of(file->f_op, struct b43_debugfs_fops, fops);
  382. if (!dfops->write) {
  383. err = -ENOSYS;
  384. goto out_unlock;
  385. }
  386. buf = (char *)get_zeroed_page(GFP_KERNEL);
  387. if (!buf) {
  388. err = -ENOMEM;
  389. goto out_unlock;
  390. }
  391. if (copy_from_user(buf, userbuf, count)) {
  392. err = -EFAULT;
  393. goto out_freepage;
  394. }
  395. if (dfops->take_irqlock) {
  396. spin_lock_irq(&dev->wl->irq_lock);
  397. err = dfops->write(dev, buf, count);
  398. spin_unlock_irq(&dev->wl->irq_lock);
  399. } else
  400. err = dfops->write(dev, buf, count);
  401. if (err)
  402. goto out_freepage;
  403. out_freepage:
  404. free_page((unsigned long)buf);
  405. out_unlock:
  406. mutex_unlock(&dev->wl->mutex);
  407. return err ? err : count;
  408. }
  409. #define B43_DEBUGFS_FOPS(name, _read, _write, _take_irqlock) \
  410. static struct b43_debugfs_fops fops_##name = { \
  411. .read = _read, \
  412. .write = _write, \
  413. .fops = { \
  414. .open = b43_debugfs_open, \
  415. .read = b43_debugfs_read, \
  416. .write = b43_debugfs_write, \
  417. }, \
  418. .file_struct_offset = offsetof(struct b43_dfsentry, \
  419. file_##name), \
  420. .take_irqlock = _take_irqlock, \
  421. }
  422. B43_DEBUGFS_FOPS(tsf, tsf_read_file, tsf_write_file, 1);
  423. B43_DEBUGFS_FOPS(ucode_regs, ucode_regs_read_file, NULL, 1);
  424. B43_DEBUGFS_FOPS(shm, shm_read_file, NULL, 1);
  425. B43_DEBUGFS_FOPS(txstat, txstat_read_file, NULL, 0);
  426. B43_DEBUGFS_FOPS(txpower_g, txpower_g_read_file, txpower_g_write_file, 0);
  427. B43_DEBUGFS_FOPS(restart, NULL, restart_write_file, 1);
  428. B43_DEBUGFS_FOPS(loctls, loctls_read_file, NULL, 0);
  429. int b43_debug(struct b43_wldev *dev, enum b43_dyndbg feature)
  430. {
  431. return !!(dev->dfsentry && dev->dfsentry->dyn_debug[feature]);
  432. }
  433. static void b43_remove_dynamic_debug(struct b43_wldev *dev)
  434. {
  435. struct b43_dfsentry *e = dev->dfsentry;
  436. int i;
  437. for (i = 0; i < __B43_NR_DYNDBG; i++)
  438. debugfs_remove(e->dyn_debug_dentries[i]);
  439. }
  440. static void b43_add_dynamic_debug(struct b43_wldev *dev)
  441. {
  442. struct b43_dfsentry *e = dev->dfsentry;
  443. struct dentry *d;
  444. #define add_dyn_dbg(name, id, initstate) do { \
  445. e->dyn_debug[id] = (initstate); \
  446. d = debugfs_create_bool(name, 0600, e->subdir, \
  447. &(e->dyn_debug[id])); \
  448. if (!IS_ERR(d)) \
  449. e->dyn_debug_dentries[id] = d; \
  450. } while (0)
  451. add_dyn_dbg("debug_xmitpower", B43_DBG_XMITPOWER, 0);
  452. add_dyn_dbg("debug_dmaoverflow", B43_DBG_DMAOVERFLOW, 0);
  453. add_dyn_dbg("debug_dmaverbose", B43_DBG_DMAVERBOSE, 0);
  454. add_dyn_dbg("debug_pwork_fast", B43_DBG_PWORK_FAST, 0);
  455. add_dyn_dbg("debug_pwork_stop", B43_DBG_PWORK_STOP, 0);
  456. #undef add_dyn_dbg
  457. }
  458. void b43_debugfs_add_device(struct b43_wldev *dev)
  459. {
  460. struct b43_dfsentry *e;
  461. struct b43_txstatus_log *log;
  462. char devdir[16];
  463. B43_WARN_ON(!dev);
  464. e = kzalloc(sizeof(*e), GFP_KERNEL);
  465. if (!e) {
  466. b43err(dev->wl, "debugfs: add device OOM\n");
  467. return;
  468. }
  469. e->dev = dev;
  470. log = &e->txstatlog;
  471. log->log = kcalloc(B43_NR_LOGGED_TXSTATUS,
  472. sizeof(struct b43_txstatus), GFP_KERNEL);
  473. if (!log->log) {
  474. b43err(dev->wl, "debugfs: add device txstatus OOM\n");
  475. kfree(e);
  476. return;
  477. }
  478. log->end = -1;
  479. spin_lock_init(&log->lock);
  480. dev->dfsentry = e;
  481. snprintf(devdir, sizeof(devdir), "%s", wiphy_name(dev->wl->hw->wiphy));
  482. e->subdir = debugfs_create_dir(devdir, rootdir);
  483. if (!e->subdir || IS_ERR(e->subdir)) {
  484. if (e->subdir == ERR_PTR(-ENODEV)) {
  485. b43dbg(dev->wl, "DebugFS (CONFIG_DEBUG_FS) not "
  486. "enabled in kernel config\n");
  487. } else {
  488. b43err(dev->wl, "debugfs: cannot create %s directory\n",
  489. devdir);
  490. }
  491. dev->dfsentry = NULL;
  492. kfree(log->log);
  493. kfree(e);
  494. return;
  495. }
  496. #define ADD_FILE(name, mode) \
  497. do { \
  498. struct dentry *d; \
  499. d = debugfs_create_file(__stringify(name), \
  500. mode, e->subdir, dev, \
  501. &fops_##name.fops); \
  502. e->file_##name.dentry = NULL; \
  503. if (!IS_ERR(d)) \
  504. e->file_##name.dentry = d; \
  505. } while (0)
  506. ADD_FILE(tsf, 0600);
  507. ADD_FILE(ucode_regs, 0400);
  508. ADD_FILE(shm, 0400);
  509. ADD_FILE(txstat, 0400);
  510. ADD_FILE(txpower_g, 0600);
  511. ADD_FILE(restart, 0200);
  512. ADD_FILE(loctls, 0400);
  513. #undef ADD_FILE
  514. b43_add_dynamic_debug(dev);
  515. }
  516. void b43_debugfs_remove_device(struct b43_wldev *dev)
  517. {
  518. struct b43_dfsentry *e;
  519. if (!dev)
  520. return;
  521. e = dev->dfsentry;
  522. if (!e)
  523. return;
  524. b43_remove_dynamic_debug(dev);
  525. debugfs_remove(e->file_tsf.dentry);
  526. debugfs_remove(e->file_ucode_regs.dentry);
  527. debugfs_remove(e->file_shm.dentry);
  528. debugfs_remove(e->file_txstat.dentry);
  529. debugfs_remove(e->file_txpower_g.dentry);
  530. debugfs_remove(e->file_restart.dentry);
  531. debugfs_remove(e->file_loctls.dentry);
  532. debugfs_remove(e->subdir);
  533. kfree(e->txstatlog.log);
  534. kfree(e);
  535. }
  536. void b43_debugfs_log_txstat(struct b43_wldev *dev,
  537. const struct b43_txstatus *status)
  538. {
  539. struct b43_dfsentry *e = dev->dfsentry;
  540. struct b43_txstatus_log *log;
  541. struct b43_txstatus *cur;
  542. int i;
  543. if (!e)
  544. return;
  545. log = &e->txstatlog;
  546. B43_WARN_ON(!irqs_disabled());
  547. spin_lock(&log->lock);
  548. i = log->end + 1;
  549. if (i == B43_NR_LOGGED_TXSTATUS)
  550. i = 0;
  551. log->end = i;
  552. cur = &(log->log[i]);
  553. memcpy(cur, status, sizeof(*cur));
  554. spin_unlock(&log->lock);
  555. }
  556. void b43_debugfs_init(void)
  557. {
  558. rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL);
  559. if (IS_ERR(rootdir))
  560. rootdir = NULL;
  561. }
  562. void b43_debugfs_exit(void)
  563. {
  564. debugfs_remove(rootdir);
  565. }