blob: 634d3d8093cf4a1a5e344bc36a818e2456750c2b [file] [log] [blame]
John W. Linvillef2223132006-01-23 16:59:58 -05001/*
2
3 Broadcom BCM43xx wireless driver
4
5 debugfs driver debugging code
6
7 Copyright (c) 2005 Michael Buesch <mbuesch@freenet.de>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; see the file COPYING. If not, write to
21 the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
22 Boston, MA 02110-1301, USA.
23
24*/
25
26
27
28#include <linux/fs.h>
29#include <linux/debugfs.h>
30#include <linux/slab.h>
31#include <linux/netdevice.h>
32#include <linux/pci.h>
33#include <asm/io.h>
34
35#include "bcm43xx.h"
36#include "bcm43xx_main.h"
37#include "bcm43xx_debugfs.h"
38#include "bcm43xx_dma.h"
39#include "bcm43xx_pio.h"
Michael Bueschf398f022006-02-23 21:15:39 +010040#include "bcm43xx_xmit.h"
John W. Linvillef2223132006-01-23 16:59:58 -050041
42#define REALLY_BIG_BUFFER_SIZE (1024*256)
43
44static struct bcm43xx_debugfs fs;
45static char really_big_buffer[REALLY_BIG_BUFFER_SIZE];
46static DECLARE_MUTEX(big_buffer_sem);
47
48
49static ssize_t write_file_dummy(struct file *file, const char __user *buf,
50 size_t count, loff_t *ppos)
51{
52 return count;
53}
54
55static int open_file_generic(struct inode *inode, struct file *file)
56{
57 file->private_data = inode->u.generic_ip;
58 return 0;
59}
60
61#define fappend(fmt, x...) pos += snprintf(buf + pos, len - pos, fmt , ##x)
62
63static ssize_t devinfo_read_file(struct file *file, char __user *userbuf,
64 size_t count, loff_t *ppos)
65{
66 const size_t len = REALLY_BIG_BUFFER_SIZE;
67
68 struct bcm43xx_private *bcm = file->private_data;
69 char *buf = really_big_buffer;
70 size_t pos = 0;
71 ssize_t res;
72 struct net_device *net_dev;
73 struct pci_dev *pci_dev;
74 unsigned long flags;
75 u16 tmp16;
76 int i;
77
78 down(&big_buffer_sem);
79
Michael Bueschefa6a372006-06-27 21:38:40 +020080 mutex_lock(&bcm->mutex);
81 spin_lock_irqsave(&bcm->irq_lock, flags);
Michael Buesch78ff56a2006-06-05 20:24:10 +020082 if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
John W. Linvillef2223132006-01-23 16:59:58 -050083 fappend("Board not initialized.\n");
84 goto out;
85 }
86 net_dev = bcm->net_dev;
87 pci_dev = bcm->pci_dev;
88
89 /* This is where the information is written to the "devinfo" file */
90 fappend("*** %s devinfo ***\n", net_dev->name);
91 fappend("vendor: 0x%04x device: 0x%04x\n",
92 pci_dev->vendor, pci_dev->device);
93 fappend("subsystem_vendor: 0x%04x subsystem_device: 0x%04x\n",
94 pci_dev->subsystem_vendor, pci_dev->subsystem_device);
95 fappend("IRQ: %d\n", bcm->irq);
Michael Bueschcc935712006-04-10 02:08:33 +020096 fappend("mmio_addr: 0x%p\n", bcm->mmio_addr);
John W. Linvillef2223132006-01-23 16:59:58 -050097 fappend("chip_id: 0x%04x chip_rev: 0x%02x\n", bcm->chip_id, bcm->chip_rev);
98 if ((bcm->core_80211[0].rev >= 3) && (bcm43xx_read32(bcm, 0x0158) & (1 << 16)))
99 fappend("Radio disabled by hardware!\n");
100 if ((bcm->core_80211[0].rev < 3) && !(bcm43xx_read16(bcm, 0x049A) & (1 << 4)))
101 fappend("Radio disabled by hardware!\n");
102 fappend("board_vendor: 0x%04x board_type: 0x%04x\n", bcm->board_vendor,
103 bcm->board_type);
104
105 fappend("\nCores:\n");
106#define fappend_core(name, info) fappend("core \"" name "\" %s, %s, id: 0x%04x, " \
107 "rev: 0x%02x, index: 0x%02x\n", \
Michael Buesche9357c02006-03-13 19:27:34 +0100108 (info).available \
John W. Linvillef2223132006-01-23 16:59:58 -0500109 ? "available" : "nonavailable", \
Michael Buesche9357c02006-03-13 19:27:34 +0100110 (info).enabled \
John W. Linvillef2223132006-01-23 16:59:58 -0500111 ? "enabled" : "disabled", \
112 (info).id, (info).rev, (info).index)
113 fappend_core("CHIPCOMMON", bcm->core_chipcommon);
114 fappend_core("PCI", bcm->core_pci);
John W. Linvillef2223132006-01-23 16:59:58 -0500115 fappend_core("first 80211", bcm->core_80211[0]);
116 fappend_core("second 80211", bcm->core_80211[1]);
117#undef fappend_core
118 tmp16 = bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_CONTROL);
119 fappend("LEDs: ");
120 for (i = 0; i < BCM43xx_NR_LEDS; i++)
121 fappend("%d ", !!(tmp16 & (1 << i)));
122 fappend("\n");
123
124out:
Michael Bueschefa6a372006-06-27 21:38:40 +0200125 spin_unlock_irqrestore(&bcm->irq_lock, flags);
126 mutex_unlock(&bcm->mutex);
John W. Linvillef2223132006-01-23 16:59:58 -0500127 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
128 up(&big_buffer_sem);
129 return res;
130}
131
132static ssize_t drvinfo_read_file(struct file *file, char __user *userbuf,
133 size_t count, loff_t *ppos)
134{
135 const size_t len = REALLY_BIG_BUFFER_SIZE;
136
137 char *buf = really_big_buffer;
138 size_t pos = 0;
139 ssize_t res;
140
141 down(&big_buffer_sem);
142
143 /* This is where the information is written to the "driver" file */
Michael Buesch65f3f192006-01-31 20:11:38 +0100144 fappend(KBUILD_MODNAME " driver\n");
John W. Linvillef2223132006-01-23 16:59:58 -0500145 fappend("Compiled at: %s %s\n", __DATE__, __TIME__);
146
147 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
148 up(&big_buffer_sem);
149 return res;
150}
151
152static ssize_t spromdump_read_file(struct file *file, char __user *userbuf,
153 size_t count, loff_t *ppos)
154{
155 const size_t len = REALLY_BIG_BUFFER_SIZE;
156
157 struct bcm43xx_private *bcm = file->private_data;
158 char *buf = really_big_buffer;
159 size_t pos = 0;
160 ssize_t res;
161 unsigned long flags;
162
163 down(&big_buffer_sem);
Michael Bueschefa6a372006-06-27 21:38:40 +0200164 mutex_lock(&bcm->mutex);
165 spin_lock_irqsave(&bcm->irq_lock, flags);
Michael Buesch78ff56a2006-06-05 20:24:10 +0200166 if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
John W. Linvillef2223132006-01-23 16:59:58 -0500167 fappend("Board not initialized.\n");
168 goto out;
169 }
170
171 /* This is where the information is written to the "sprom_dump" file */
172 fappend("boardflags: 0x%04x\n", bcm->sprom.boardflags);
173
174out:
Michael Bueschefa6a372006-06-27 21:38:40 +0200175 spin_unlock_irqrestore(&bcm->irq_lock, flags);
176 mutex_unlock(&bcm->mutex);
John W. Linvillef2223132006-01-23 16:59:58 -0500177 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
178 up(&big_buffer_sem);
179 return res;
180}
181
182static ssize_t tsf_read_file(struct file *file, char __user *userbuf,
183 size_t count, loff_t *ppos)
184{
185 const size_t len = REALLY_BIG_BUFFER_SIZE;
186
187 struct bcm43xx_private *bcm = file->private_data;
188 char *buf = really_big_buffer;
189 size_t pos = 0;
190 ssize_t res;
191 unsigned long flags;
192 u64 tsf;
193
194 down(&big_buffer_sem);
Michael Bueschefa6a372006-06-27 21:38:40 +0200195 mutex_lock(&bcm->mutex);
196 spin_lock_irqsave(&bcm->irq_lock, flags);
Michael Buesch78ff56a2006-06-05 20:24:10 +0200197 if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
John W. Linvillef2223132006-01-23 16:59:58 -0500198 fappend("Board not initialized.\n");
199 goto out;
200 }
201 bcm43xx_tsf_read(bcm, &tsf);
202 fappend("0x%08x%08x\n",
203 (unsigned int)((tsf & 0xFFFFFFFF00000000ULL) >> 32),
204 (unsigned int)(tsf & 0xFFFFFFFFULL));
205
206out:
Michael Bueschefa6a372006-06-27 21:38:40 +0200207 spin_unlock_irqrestore(&bcm->irq_lock, flags);
208 mutex_unlock(&bcm->mutex);
John W. Linvillef2223132006-01-23 16:59:58 -0500209 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
210 up(&big_buffer_sem);
211 return res;
212}
213
214static ssize_t tsf_write_file(struct file *file, const char __user *user_buf,
215 size_t count, loff_t *ppos)
216{
217 struct bcm43xx_private *bcm = file->private_data;
218 char *buf = really_big_buffer;
219 ssize_t buf_size;
220 ssize_t res;
221 unsigned long flags;
222 u64 tsf;
223
224 buf_size = min(count, sizeof (really_big_buffer) - 1);
225 down(&big_buffer_sem);
226 if (copy_from_user(buf, user_buf, buf_size)) {
227 res = -EFAULT;
228 goto out_up;
229 }
Michael Bueschefa6a372006-06-27 21:38:40 +0200230 mutex_lock(&bcm->mutex);
231 spin_lock_irqsave(&bcm->irq_lock, flags);
Michael Buesch78ff56a2006-06-05 20:24:10 +0200232 if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
John W. Linvillef2223132006-01-23 16:59:58 -0500233 printk(KERN_INFO PFX "debugfs: Board not initialized.\n");
234 res = -EFAULT;
235 goto out_unlock;
236 }
237 if (sscanf(buf, "%lli", &tsf) != 1) {
238 printk(KERN_INFO PFX "debugfs: invalid values for \"tsf\"\n");
239 res = -EINVAL;
240 goto out_unlock;
241 }
242 bcm43xx_tsf_write(bcm, tsf);
Michael Buesch78ff56a2006-06-05 20:24:10 +0200243 mmiowb();
John W. Linvillef2223132006-01-23 16:59:58 -0500244 res = buf_size;
245
246out_unlock:
Michael Bueschefa6a372006-06-27 21:38:40 +0200247 spin_unlock_irqrestore(&bcm->irq_lock, flags);
248 mutex_unlock(&bcm->mutex);
John W. Linvillef2223132006-01-23 16:59:58 -0500249out_up:
250 up(&big_buffer_sem);
251 return res;
252}
253
254static ssize_t txstat_read_file(struct file *file, char __user *userbuf,
255 size_t count, loff_t *ppos)
256{
257 const size_t len = REALLY_BIG_BUFFER_SIZE;
258
259 struct bcm43xx_private *bcm = file->private_data;
260 char *buf = really_big_buffer;
261 size_t pos = 0;
262 ssize_t res;
263 unsigned long flags;
264 struct bcm43xx_dfsentry *e;
265 struct bcm43xx_xmitstatus *status;
266 int i, cnt, j = 0;
267
268 down(&big_buffer_sem);
Michael Bueschefa6a372006-06-27 21:38:40 +0200269 mutex_lock(&bcm->mutex);
270 spin_lock_irqsave(&bcm->irq_lock, flags);
John W. Linvillef2223132006-01-23 16:59:58 -0500271
272 fappend("Last %d logged xmitstatus blobs (Latest first):\n\n",
273 BCM43xx_NR_LOGGED_XMITSTATUS);
274 e = bcm->dfsentry;
275 if (e->xmitstatus_printing == 0) {
276 /* At the beginning, make a copy of all data to avoid
277 * concurrency, as this function is called multiple
278 * times for big logs. Without copying, the data might
279 * change between reads. This would result in total trash.
280 */
281 e->xmitstatus_printing = 1;
282 e->saved_xmitstatus_ptr = e->xmitstatus_ptr;
283 e->saved_xmitstatus_cnt = e->xmitstatus_cnt;
284 memcpy(e->xmitstatus_print_buffer, e->xmitstatus_buffer,
285 BCM43xx_NR_LOGGED_XMITSTATUS * sizeof(*(e->xmitstatus_buffer)));
286 }
287 i = e->saved_xmitstatus_ptr - 1;
288 if (i < 0)
289 i = BCM43xx_NR_LOGGED_XMITSTATUS - 1;
290 cnt = e->saved_xmitstatus_cnt;
291 while (cnt) {
292 status = e->xmitstatus_print_buffer + i;
293 fappend("0x%02x: cookie: 0x%04x, flags: 0x%02x, "
294 "cnt1: 0x%02x, cnt2: 0x%02x, seq: 0x%04x, "
295 "unk: 0x%04x\n", j,
296 status->cookie, status->flags,
297 status->cnt1, status->cnt2, status->seq,
298 status->unknown);
299 j++;
300 cnt--;
301 i--;
302 if (i < 0)
303 i = BCM43xx_NR_LOGGED_XMITSTATUS - 1;
304 }
305
Michael Bueschefa6a372006-06-27 21:38:40 +0200306 spin_unlock_irqrestore(&bcm->irq_lock, flags);
John W. Linvillef2223132006-01-23 16:59:58 -0500307 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
Michael Bueschefa6a372006-06-27 21:38:40 +0200308 spin_lock_irqsave(&bcm->irq_lock, flags);
John W. Linvillef2223132006-01-23 16:59:58 -0500309 if (*ppos == pos) {
310 /* Done. Drop the copied data. */
311 e->xmitstatus_printing = 0;
312 }
Michael Bueschefa6a372006-06-27 21:38:40 +0200313 spin_unlock_irqrestore(&bcm->irq_lock, flags);
314 mutex_unlock(&bcm->mutex);
John W. Linvillef2223132006-01-23 16:59:58 -0500315 up(&big_buffer_sem);
316 return res;
317}
318
Michael Buesch58e55282006-07-08 22:02:18 +0200319static ssize_t restart_write_file(struct file *file, const char __user *user_buf,
320 size_t count, loff_t *ppos)
321{
322 struct bcm43xx_private *bcm = file->private_data;
323 char *buf = really_big_buffer;
324 ssize_t buf_size;
325 ssize_t res;
326 unsigned long flags;
327
328 buf_size = min(count, sizeof (really_big_buffer) - 1);
329 down(&big_buffer_sem);
330 if (copy_from_user(buf, user_buf, buf_size)) {
331 res = -EFAULT;
332 goto out_up;
333 }
334 bcm43xx_lock_irqsafe(bcm, flags);
335 if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
336 printk(KERN_INFO PFX "debugfs: Board not initialized.\n");
337 res = -EFAULT;
338 goto out_unlock;
339 }
340 if (count > 0 && buf[0] == '1') {
341 bcm43xx_controller_restart(bcm, "manually restarted");
342 res = count;
343 } else
344 res = -EINVAL;
345
346out_unlock:
347 bcm43xx_unlock_irqsafe(bcm, flags);
348out_up:
349 up(&big_buffer_sem);
350 return res;
351}
352
John W. Linvillef2223132006-01-23 16:59:58 -0500353#undef fappend
354
355
356static struct file_operations devinfo_fops = {
357 .read = devinfo_read_file,
358 .write = write_file_dummy,
359 .open = open_file_generic,
360};
361
362static struct file_operations spromdump_fops = {
363 .read = spromdump_read_file,
364 .write = write_file_dummy,
365 .open = open_file_generic,
366};
367
368static struct file_operations drvinfo_fops = {
369 .read = drvinfo_read_file,
370 .write = write_file_dummy,
371 .open = open_file_generic,
372};
373
374static struct file_operations tsf_fops = {
375 .read = tsf_read_file,
376 .write = tsf_write_file,
377 .open = open_file_generic,
378};
379
380static struct file_operations txstat_fops = {
381 .read = txstat_read_file,
382 .write = write_file_dummy,
383 .open = open_file_generic,
384};
385
Michael Buesch58e55282006-07-08 22:02:18 +0200386static struct file_operations restart_fops = {
387 .write = restart_write_file,
388 .open = open_file_generic,
389};
390
John W. Linvillef2223132006-01-23 16:59:58 -0500391
392void bcm43xx_debugfs_add_device(struct bcm43xx_private *bcm)
393{
394 struct bcm43xx_dfsentry *e;
395 char devdir[IFNAMSIZ];
396
397 assert(bcm);
398 e = kzalloc(sizeof(*e), GFP_KERNEL);
399 if (!e) {
400 printk(KERN_ERR PFX "out of memory\n");
401 return;
402 }
403 e->bcm = bcm;
404 e->xmitstatus_buffer = kzalloc(BCM43xx_NR_LOGGED_XMITSTATUS
405 * sizeof(*(e->xmitstatus_buffer)),
406 GFP_KERNEL);
407 if (!e->xmitstatus_buffer) {
408 printk(KERN_ERR PFX "out of memory\n");
409 kfree(e);
410 return;
411 }
412 e->xmitstatus_print_buffer = kzalloc(BCM43xx_NR_LOGGED_XMITSTATUS
413 * sizeof(*(e->xmitstatus_buffer)),
414 GFP_KERNEL);
415 if (!e->xmitstatus_print_buffer) {
416 printk(KERN_ERR PFX "out of memory\n");
417 kfree(e);
418 return;
419 }
420
421
422 bcm->dfsentry = e;
423
424 strncpy(devdir, bcm->net_dev->name, ARRAY_SIZE(devdir));
425 e->subdir = debugfs_create_dir(devdir, fs.root);
426 e->dentry_devinfo = debugfs_create_file("devinfo", 0444, e->subdir,
427 bcm, &devinfo_fops);
428 if (!e->dentry_devinfo)
429 printk(KERN_ERR PFX "debugfs: creating \"devinfo\" for \"%s\" failed!\n", devdir);
430 e->dentry_spromdump = debugfs_create_file("sprom_dump", 0444, e->subdir,
431 bcm, &spromdump_fops);
432 if (!e->dentry_spromdump)
433 printk(KERN_ERR PFX "debugfs: creating \"sprom_dump\" for \"%s\" failed!\n", devdir);
434 e->dentry_tsf = debugfs_create_file("tsf", 0666, e->subdir,
435 bcm, &tsf_fops);
436 if (!e->dentry_tsf)
437 printk(KERN_ERR PFX "debugfs: creating \"tsf\" for \"%s\" failed!\n", devdir);
438 e->dentry_txstat = debugfs_create_file("tx_status", 0444, e->subdir,
439 bcm, &txstat_fops);
440 if (!e->dentry_txstat)
441 printk(KERN_ERR PFX "debugfs: creating \"tx_status\" for \"%s\" failed!\n", devdir);
Michael Buesch58e55282006-07-08 22:02:18 +0200442 e->dentry_restart = debugfs_create_file("restart", 0222, e->subdir,
443 bcm, &restart_fops);
444 if (!e->dentry_restart)
445 printk(KERN_ERR PFX "debugfs: creating \"restart\" for \"%s\" failed!\n", devdir);
John W. Linvillef2223132006-01-23 16:59:58 -0500446}
447
448void bcm43xx_debugfs_remove_device(struct bcm43xx_private *bcm)
449{
450 struct bcm43xx_dfsentry *e;
451
452 if (!bcm)
453 return;
454
455 e = bcm->dfsentry;
456 assert(e);
457 debugfs_remove(e->dentry_spromdump);
458 debugfs_remove(e->dentry_devinfo);
459 debugfs_remove(e->dentry_tsf);
460 debugfs_remove(e->dentry_txstat);
Michael Buesch58e55282006-07-08 22:02:18 +0200461 debugfs_remove(e->dentry_restart);
John W. Linvillef2223132006-01-23 16:59:58 -0500462 debugfs_remove(e->subdir);
463 kfree(e->xmitstatus_buffer);
464 kfree(e->xmitstatus_print_buffer);
465 kfree(e);
466}
467
468void bcm43xx_debugfs_log_txstat(struct bcm43xx_private *bcm,
469 struct bcm43xx_xmitstatus *status)
470{
471 struct bcm43xx_dfsentry *e;
472 struct bcm43xx_xmitstatus *savedstatus;
473
Michael Bueschefccb642006-03-11 13:39:14 +0100474 /* This is protected by bcm->_lock */
John W. Linvillef2223132006-01-23 16:59:58 -0500475 e = bcm->dfsentry;
476 assert(e);
477 savedstatus = e->xmitstatus_buffer + e->xmitstatus_ptr;
478 memcpy(savedstatus, status, sizeof(*status));
479 e->xmitstatus_ptr++;
480 if (e->xmitstatus_ptr >= BCM43xx_NR_LOGGED_XMITSTATUS)
481 e->xmitstatus_ptr = 0;
482 if (e->xmitstatus_cnt < BCM43xx_NR_LOGGED_XMITSTATUS)
483 e->xmitstatus_cnt++;
484}
485
486void bcm43xx_debugfs_init(void)
487{
488 memset(&fs, 0, sizeof(fs));
Michael Buesch65f3f192006-01-31 20:11:38 +0100489 fs.root = debugfs_create_dir(KBUILD_MODNAME, NULL);
John W. Linvillef2223132006-01-23 16:59:58 -0500490 if (!fs.root)
Michael Buesch65f3f192006-01-31 20:11:38 +0100491 printk(KERN_ERR PFX "debugfs: creating \"" KBUILD_MODNAME "\" subdir failed!\n");
John W. Linvillef2223132006-01-23 16:59:58 -0500492 fs.dentry_driverinfo = debugfs_create_file("driver", 0444, fs.root, NULL, &drvinfo_fops);
493 if (!fs.dentry_driverinfo)
Michael Buesch65f3f192006-01-31 20:11:38 +0100494 printk(KERN_ERR PFX "debugfs: creating \"" KBUILD_MODNAME "/driver\" failed!\n");
John W. Linvillef2223132006-01-23 16:59:58 -0500495}
496
497void bcm43xx_debugfs_exit(void)
498{
499 debugfs_remove(fs.dentry_driverinfo);
500 debugfs_remove(fs.root);
501}
502
503void bcm43xx_printk_dump(const char *data,
504 size_t size,
505 const char *description)
506{
507 size_t i;
508 char c;
509
Randy Dunlap4c6f7492006-04-11 14:31:56 -0700510 printk(KERN_INFO PFX "Data dump (%s, %zd bytes):",
John W. Linvillef2223132006-01-23 16:59:58 -0500511 description, size);
512 for (i = 0; i < size; i++) {
513 c = data[i];
514 if (i % 8 == 0)
Randy Dunlap4c6f7492006-04-11 14:31:56 -0700515 printk("\n" KERN_INFO PFX "0x%08zx: 0x%02x, ", i, c & 0xff);
John W. Linvillef2223132006-01-23 16:59:58 -0500516 else
517 printk("0x%02x, ", c & 0xff);
518 }
519 printk("\n");
520}
521
522void bcm43xx_printk_bitdump(const unsigned char *data,
523 size_t bytes, int msb_to_lsb,
524 const char *description)
525{
526 size_t i;
527 int j;
528 const unsigned char *d;
529
Randy Dunlap4c6f7492006-04-11 14:31:56 -0700530 printk(KERN_INFO PFX "*** Bitdump (%s, %zd bytes, %s) ***",
John W. Linvillef2223132006-01-23 16:59:58 -0500531 description, bytes, msb_to_lsb ? "MSB to LSB" : "LSB to MSB");
532 for (i = 0; i < bytes; i++) {
533 d = data + i;
534 if (i % 8 == 0)
Randy Dunlap4c6f7492006-04-11 14:31:56 -0700535 printk("\n" KERN_INFO PFX "0x%08zx: ", i);
John W. Linvillef2223132006-01-23 16:59:58 -0500536 if (msb_to_lsb) {
537 for (j = 7; j >= 0; j--) {
538 if (*d & (1 << j))
539 printk("1");
540 else
541 printk("0");
542 }
543 } else {
544 for (j = 0; j < 8; j++) {
545 if (*d & (1 << j))
546 printk("1");
547 else
548 printk("0");
549 }
550 }
551 printk(" ");
552 }
553 printk("\n");
554}