debugfs.c 16 KB

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