diff options
Diffstat (limited to 'drivers/net/wireless/iwmc3200wifi/debugfs.c')
-rw-r--r-- | drivers/net/wireless/iwmc3200wifi/debugfs.c | 123 |
1 files changed, 19 insertions, 104 deletions
diff --git a/drivers/net/wireless/iwmc3200wifi/debugfs.c b/drivers/net/wireless/iwmc3200wifi/debugfs.c index cbb81befdb55..53b0b7711f02 100644 --- a/drivers/net/wireless/iwmc3200wifi/debugfs.c +++ b/drivers/net/wireless/iwmc3200wifi/debugfs.c | |||
@@ -48,12 +48,11 @@ static struct { | |||
48 | 48 | ||
49 | #define add_dbg_module(dbg, name, id, initlevel) \ | 49 | #define add_dbg_module(dbg, name, id, initlevel) \ |
50 | do { \ | 50 | do { \ |
51 | struct dentry *d; \ | ||
52 | dbg.dbg_module[id] = (initlevel); \ | 51 | dbg.dbg_module[id] = (initlevel); \ |
53 | d = debugfs_create_x8(name, 0600, dbg.dbgdir, \ | 52 | dbg.dbg_module_dentries[id] = \ |
54 | &(dbg.dbg_module[id])); \ | 53 | debugfs_create_x8(name, 0600, \ |
55 | if (!IS_ERR(d)) \ | 54 | dbg.dbgdir, \ |
56 | dbg.dbg_module_dentries[id] = d; \ | 55 | &(dbg.dbg_module[id])); \ |
57 | } while (0) | 56 | } while (0) |
58 | 57 | ||
59 | static int iwm_debugfs_u32_read(void *data, u64 *val) | 58 | static int iwm_debugfs_u32_read(void *data, u64 *val) |
@@ -266,7 +265,7 @@ static ssize_t iwm_debugfs_rx_ticket_read(struct file *filp, | |||
266 | size_t count, loff_t *ppos) | 265 | size_t count, loff_t *ppos) |
267 | { | 266 | { |
268 | struct iwm_priv *iwm = filp->private_data; | 267 | struct iwm_priv *iwm = filp->private_data; |
269 | struct iwm_rx_ticket_node *ticket, *next; | 268 | struct iwm_rx_ticket_node *ticket; |
270 | char *buf; | 269 | char *buf; |
271 | int buf_len = 4096, i; | 270 | int buf_len = 4096, i; |
272 | size_t len = 0; | 271 | size_t len = 0; |
@@ -281,7 +280,8 @@ static ssize_t iwm_debugfs_rx_ticket_read(struct file *filp, | |||
281 | if (!buf) | 280 | if (!buf) |
282 | return -ENOMEM; | 281 | return -ENOMEM; |
283 | 282 | ||
284 | list_for_each_entry_safe(ticket, next, &iwm->rx_tickets, node) { | 283 | spin_lock(&iwm->ticket_lock); |
284 | list_for_each_entry(ticket, &iwm->rx_tickets, node) { | ||
285 | len += snprintf(buf + len, buf_len - len, "Ticket #%d\n", | 285 | len += snprintf(buf + len, buf_len - len, "Ticket #%d\n", |
286 | ticket->ticket->id); | 286 | ticket->ticket->id); |
287 | len += snprintf(buf + len, buf_len - len, "\taction: 0x%x\n", | 287 | len += snprintf(buf + len, buf_len - len, "\taction: 0x%x\n", |
@@ -289,14 +289,17 @@ static ssize_t iwm_debugfs_rx_ticket_read(struct file *filp, | |||
289 | len += snprintf(buf + len, buf_len - len, "\tflags: 0x%x\n", | 289 | len += snprintf(buf + len, buf_len - len, "\tflags: 0x%x\n", |
290 | ticket->ticket->flags); | 290 | ticket->ticket->flags); |
291 | } | 291 | } |
292 | spin_unlock(&iwm->ticket_lock); | ||
292 | 293 | ||
293 | for (i = 0; i < IWM_RX_ID_HASH; i++) { | 294 | for (i = 0; i < IWM_RX_ID_HASH; i++) { |
294 | struct iwm_rx_packet *packet, *nxt; | 295 | struct iwm_rx_packet *packet; |
295 | struct list_head *pkt_list = &iwm->rx_packets[i]; | 296 | struct list_head *pkt_list = &iwm->rx_packets[i]; |
297 | |||
296 | if (!list_empty(pkt_list)) { | 298 | if (!list_empty(pkt_list)) { |
297 | len += snprintf(buf + len, buf_len - len, | 299 | len += snprintf(buf + len, buf_len - len, |
298 | "Packet hash #%d\n", i); | 300 | "Packet hash #%d\n", i); |
299 | list_for_each_entry_safe(packet, nxt, pkt_list, node) { | 301 | spin_lock(&iwm->packet_lock[i]); |
302 | list_for_each_entry(packet, pkt_list, node) { | ||
300 | len += snprintf(buf + len, buf_len - len, | 303 | len += snprintf(buf + len, buf_len - len, |
301 | "\tPacket id: %d\n", | 304 | "\tPacket id: %d\n", |
302 | packet->id); | 305 | packet->id); |
@@ -304,6 +307,7 @@ static ssize_t iwm_debugfs_rx_ticket_read(struct file *filp, | |||
304 | "\tPacket length: %lu\n", | 307 | "\tPacket length: %lu\n", |
305 | packet->pkt_size); | 308 | packet->pkt_size); |
306 | } | 309 | } |
310 | spin_unlock(&iwm->packet_lock[i]); | ||
307 | } | 311 | } |
308 | } | 312 | } |
309 | 313 | ||
@@ -418,89 +422,29 @@ static const struct file_operations iwm_debugfs_fw_err_fops = { | |||
418 | .read = iwm_debugfs_fw_err_read, | 422 | .read = iwm_debugfs_fw_err_read, |
419 | }; | 423 | }; |
420 | 424 | ||
421 | int iwm_debugfs_init(struct iwm_priv *iwm) | 425 | void iwm_debugfs_init(struct iwm_priv *iwm) |
422 | { | 426 | { |
423 | int i, result; | 427 | int i; |
424 | char devdir[16]; | ||
425 | 428 | ||
426 | iwm->dbg.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL); | 429 | iwm->dbg.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL); |
427 | result = PTR_ERR(iwm->dbg.rootdir); | 430 | iwm->dbg.devdir = debugfs_create_dir(wiphy_name(iwm_to_wiphy(iwm)), |
428 | if (!result || IS_ERR(iwm->dbg.rootdir)) { | 431 | iwm->dbg.rootdir); |
429 | if (result == -ENODEV) { | ||
430 | IWM_ERR(iwm, "DebugFS (CONFIG_DEBUG_FS) not " | ||
431 | "enabled in kernel config\n"); | ||
432 | result = 0; /* No debugfs support */ | ||
433 | } | ||
434 | IWM_ERR(iwm, "Couldn't create rootdir: %d\n", result); | ||
435 | goto error; | ||
436 | } | ||
437 | |||
438 | snprintf(devdir, sizeof(devdir), "%s", wiphy_name(iwm_to_wiphy(iwm))); | ||
439 | |||
440 | iwm->dbg.devdir = debugfs_create_dir(devdir, iwm->dbg.rootdir); | ||
441 | result = PTR_ERR(iwm->dbg.devdir); | ||
442 | if (IS_ERR(iwm->dbg.devdir) && (result != -ENODEV)) { | ||
443 | IWM_ERR(iwm, "Couldn't create devdir: %d\n", result); | ||
444 | goto error; | ||
445 | } | ||
446 | |||
447 | iwm->dbg.dbgdir = debugfs_create_dir("debug", iwm->dbg.devdir); | 432 | iwm->dbg.dbgdir = debugfs_create_dir("debug", iwm->dbg.devdir); |
448 | result = PTR_ERR(iwm->dbg.dbgdir); | ||
449 | if (IS_ERR(iwm->dbg.dbgdir) && (result != -ENODEV)) { | ||
450 | IWM_ERR(iwm, "Couldn't create dbgdir: %d\n", result); | ||
451 | goto error; | ||
452 | } | ||
453 | |||
454 | iwm->dbg.rxdir = debugfs_create_dir("rx", iwm->dbg.devdir); | 433 | iwm->dbg.rxdir = debugfs_create_dir("rx", iwm->dbg.devdir); |
455 | result = PTR_ERR(iwm->dbg.rxdir); | ||
456 | if (IS_ERR(iwm->dbg.rxdir) && (result != -ENODEV)) { | ||
457 | IWM_ERR(iwm, "Couldn't create rx dir: %d\n", result); | ||
458 | goto error; | ||
459 | } | ||
460 | |||
461 | iwm->dbg.txdir = debugfs_create_dir("tx", iwm->dbg.devdir); | 434 | iwm->dbg.txdir = debugfs_create_dir("tx", iwm->dbg.devdir); |
462 | result = PTR_ERR(iwm->dbg.txdir); | ||
463 | if (IS_ERR(iwm->dbg.txdir) && (result != -ENODEV)) { | ||
464 | IWM_ERR(iwm, "Couldn't create tx dir: %d\n", result); | ||
465 | goto error; | ||
466 | } | ||
467 | |||
468 | iwm->dbg.busdir = debugfs_create_dir("bus", iwm->dbg.devdir); | 435 | iwm->dbg.busdir = debugfs_create_dir("bus", iwm->dbg.devdir); |
469 | result = PTR_ERR(iwm->dbg.busdir); | 436 | if (iwm->bus_ops->debugfs_init) |
470 | if (IS_ERR(iwm->dbg.busdir) && (result != -ENODEV)) { | 437 | iwm->bus_ops->debugfs_init(iwm, iwm->dbg.busdir); |
471 | IWM_ERR(iwm, "Couldn't create bus dir: %d\n", result); | ||
472 | goto error; | ||
473 | } | ||
474 | |||
475 | if (iwm->bus_ops->debugfs_init) { | ||
476 | result = iwm->bus_ops->debugfs_init(iwm, iwm->dbg.busdir); | ||
477 | if (result < 0) { | ||
478 | IWM_ERR(iwm, "Couldn't create bus entry: %d\n", result); | ||
479 | goto error; | ||
480 | } | ||
481 | } | ||
482 | |||
483 | 438 | ||
484 | iwm->dbg.dbg_level = IWM_DL_NONE; | 439 | iwm->dbg.dbg_level = IWM_DL_NONE; |
485 | iwm->dbg.dbg_level_dentry = | 440 | iwm->dbg.dbg_level_dentry = |
486 | debugfs_create_file("level", 0200, iwm->dbg.dbgdir, iwm, | 441 | debugfs_create_file("level", 0200, iwm->dbg.dbgdir, iwm, |
487 | &fops_iwm_dbg_level); | 442 | &fops_iwm_dbg_level); |
488 | result = PTR_ERR(iwm->dbg.dbg_level_dentry); | ||
489 | if (IS_ERR(iwm->dbg.dbg_level_dentry) && (result != -ENODEV)) { | ||
490 | IWM_ERR(iwm, "Couldn't create dbg_level: %d\n", result); | ||
491 | goto error; | ||
492 | } | ||
493 | |||
494 | 443 | ||
495 | iwm->dbg.dbg_modules = IWM_DM_DEFAULT; | 444 | iwm->dbg.dbg_modules = IWM_DM_DEFAULT; |
496 | iwm->dbg.dbg_modules_dentry = | 445 | iwm->dbg.dbg_modules_dentry = |
497 | debugfs_create_file("modules", 0200, iwm->dbg.dbgdir, iwm, | 446 | debugfs_create_file("modules", 0200, iwm->dbg.dbgdir, iwm, |
498 | &fops_iwm_dbg_modules); | 447 | &fops_iwm_dbg_modules); |
499 | result = PTR_ERR(iwm->dbg.dbg_modules_dentry); | ||
500 | if (IS_ERR(iwm->dbg.dbg_modules_dentry) && (result != -ENODEV)) { | ||
501 | IWM_ERR(iwm, "Couldn't create dbg_modules: %d\n", result); | ||
502 | goto error; | ||
503 | } | ||
504 | 448 | ||
505 | for (i = 0; i < __IWM_DM_NR; i++) | 449 | for (i = 0; i < __IWM_DM_NR; i++) |
506 | add_dbg_module(iwm->dbg, iwm_debug_module[i].name, | 450 | add_dbg_module(iwm->dbg, iwm_debug_module[i].name, |
@@ -509,44 +453,15 @@ int iwm_debugfs_init(struct iwm_priv *iwm) | |||
509 | iwm->dbg.txq_dentry = debugfs_create_file("queues", 0200, | 453 | iwm->dbg.txq_dentry = debugfs_create_file("queues", 0200, |
510 | iwm->dbg.txdir, iwm, | 454 | iwm->dbg.txdir, iwm, |
511 | &iwm_debugfs_txq_fops); | 455 | &iwm_debugfs_txq_fops); |
512 | result = PTR_ERR(iwm->dbg.txq_dentry); | ||
513 | if (IS_ERR(iwm->dbg.txq_dentry) && (result != -ENODEV)) { | ||
514 | IWM_ERR(iwm, "Couldn't create tx queue: %d\n", result); | ||
515 | goto error; | ||
516 | } | ||
517 | |||
518 | iwm->dbg.tx_credit_dentry = debugfs_create_file("credits", 0200, | 456 | iwm->dbg.tx_credit_dentry = debugfs_create_file("credits", 0200, |
519 | iwm->dbg.txdir, iwm, | 457 | iwm->dbg.txdir, iwm, |
520 | &iwm_debugfs_tx_credit_fops); | 458 | &iwm_debugfs_tx_credit_fops); |
521 | result = PTR_ERR(iwm->dbg.tx_credit_dentry); | ||
522 | if (IS_ERR(iwm->dbg.tx_credit_dentry) && (result != -ENODEV)) { | ||
523 | IWM_ERR(iwm, "Couldn't create tx credit: %d\n", result); | ||
524 | goto error; | ||
525 | } | ||
526 | |||
527 | iwm->dbg.rx_ticket_dentry = debugfs_create_file("tickets", 0200, | 459 | iwm->dbg.rx_ticket_dentry = debugfs_create_file("tickets", 0200, |
528 | iwm->dbg.rxdir, iwm, | 460 | iwm->dbg.rxdir, iwm, |
529 | &iwm_debugfs_rx_ticket_fops); | 461 | &iwm_debugfs_rx_ticket_fops); |
530 | result = PTR_ERR(iwm->dbg.rx_ticket_dentry); | ||
531 | if (IS_ERR(iwm->dbg.rx_ticket_dentry) && (result != -ENODEV)) { | ||
532 | IWM_ERR(iwm, "Couldn't create rx ticket: %d\n", result); | ||
533 | goto error; | ||
534 | } | ||
535 | |||
536 | iwm->dbg.fw_err_dentry = debugfs_create_file("last_fw_err", 0200, | 462 | iwm->dbg.fw_err_dentry = debugfs_create_file("last_fw_err", 0200, |
537 | iwm->dbg.dbgdir, iwm, | 463 | iwm->dbg.dbgdir, iwm, |
538 | &iwm_debugfs_fw_err_fops); | 464 | &iwm_debugfs_fw_err_fops); |
539 | result = PTR_ERR(iwm->dbg.fw_err_dentry); | ||
540 | if (IS_ERR(iwm->dbg.fw_err_dentry) && (result != -ENODEV)) { | ||
541 | IWM_ERR(iwm, "Couldn't create last FW err: %d\n", result); | ||
542 | goto error; | ||
543 | } | ||
544 | |||
545 | |||
546 | return 0; | ||
547 | |||
548 | error: | ||
549 | return result; | ||
550 | } | 465 | } |
551 | 466 | ||
552 | void iwm_debugfs_exit(struct iwm_priv *iwm) | 467 | void iwm_debugfs_exit(struct iwm_priv *iwm) |