| .. | .. |
|---|
| 460 | 460 | #include <linux/debugfs.h> |
|---|
| 461 | 461 | |
|---|
| 462 | 462 | /* Displays ZIP device statistics */ |
|---|
| 463 | | -static int zip_show_stats(struct seq_file *s, void *unused) |
|---|
| 463 | +static int zip_stats_show(struct seq_file *s, void *unused) |
|---|
| 464 | 464 | { |
|---|
| 465 | 465 | u64 val = 0ull; |
|---|
| 466 | 466 | u64 avg_chunk = 0ull, avg_cr = 0ull; |
|---|
| .. | .. |
|---|
| 523 | 523 | } |
|---|
| 524 | 524 | |
|---|
| 525 | 525 | /* Clears stats data */ |
|---|
| 526 | | -static int zip_clear_stats(struct seq_file *s, void *unused) |
|---|
| 526 | +static int zip_clear_show(struct seq_file *s, void *unused) |
|---|
| 527 | 527 | { |
|---|
| 528 | 528 | int index = 0; |
|---|
| 529 | 529 | |
|---|
| .. | .. |
|---|
| 558 | 558 | }; |
|---|
| 559 | 559 | |
|---|
| 560 | 560 | /* Prints registers' contents */ |
|---|
| 561 | | -static int zip_print_regs(struct seq_file *s, void *unused) |
|---|
| 561 | +static int zip_regs_show(struct seq_file *s, void *unused) |
|---|
| 562 | 562 | { |
|---|
| 563 | 563 | u64 val = 0; |
|---|
| 564 | 564 | int i = 0, index = 0; |
|---|
| .. | .. |
|---|
| 584 | 584 | return 0; |
|---|
| 585 | 585 | } |
|---|
| 586 | 586 | |
|---|
| 587 | | -static int zip_stats_open(struct inode *inode, struct file *file) |
|---|
| 588 | | -{ |
|---|
| 589 | | - return single_open(file, zip_show_stats, NULL); |
|---|
| 590 | | -} |
|---|
| 591 | | - |
|---|
| 592 | | -static const struct file_operations zip_stats_fops = { |
|---|
| 593 | | - .owner = THIS_MODULE, |
|---|
| 594 | | - .open = zip_stats_open, |
|---|
| 595 | | - .read = seq_read, |
|---|
| 596 | | - .release = single_release, |
|---|
| 597 | | -}; |
|---|
| 598 | | - |
|---|
| 599 | | -static int zip_clear_open(struct inode *inode, struct file *file) |
|---|
| 600 | | -{ |
|---|
| 601 | | - return single_open(file, zip_clear_stats, NULL); |
|---|
| 602 | | -} |
|---|
| 603 | | - |
|---|
| 604 | | -static const struct file_operations zip_clear_fops = { |
|---|
| 605 | | - .owner = THIS_MODULE, |
|---|
| 606 | | - .open = zip_clear_open, |
|---|
| 607 | | - .read = seq_read, |
|---|
| 608 | | - .release = single_release, |
|---|
| 609 | | -}; |
|---|
| 610 | | - |
|---|
| 611 | | -static int zip_regs_open(struct inode *inode, struct file *file) |
|---|
| 612 | | -{ |
|---|
| 613 | | - return single_open(file, zip_print_regs, NULL); |
|---|
| 614 | | -} |
|---|
| 615 | | - |
|---|
| 616 | | -static const struct file_operations zip_regs_fops = { |
|---|
| 617 | | - .owner = THIS_MODULE, |
|---|
| 618 | | - .open = zip_regs_open, |
|---|
| 619 | | - .read = seq_read, |
|---|
| 620 | | - .release = single_release, |
|---|
| 621 | | -}; |
|---|
| 587 | +DEFINE_SHOW_ATTRIBUTE(zip_stats); |
|---|
| 588 | +DEFINE_SHOW_ATTRIBUTE(zip_clear); |
|---|
| 589 | +DEFINE_SHOW_ATTRIBUTE(zip_regs); |
|---|
| 622 | 590 | |
|---|
| 623 | 591 | /* Root directory for thunderx_zip debugfs entry */ |
|---|
| 624 | 592 | static struct dentry *zip_debugfs_root; |
|---|
| 625 | 593 | |
|---|
| 626 | | -static int __init zip_debugfs_init(void) |
|---|
| 594 | +static void __init zip_debugfs_init(void) |
|---|
| 627 | 595 | { |
|---|
| 628 | | - struct dentry *zip_stats, *zip_clear, *zip_regs; |
|---|
| 629 | | - |
|---|
| 630 | 596 | if (!debugfs_initialized()) |
|---|
| 631 | | - return -ENODEV; |
|---|
| 597 | + return; |
|---|
| 632 | 598 | |
|---|
| 633 | 599 | zip_debugfs_root = debugfs_create_dir("thunderx_zip", NULL); |
|---|
| 634 | | - if (!zip_debugfs_root) |
|---|
| 635 | | - return -ENOMEM; |
|---|
| 636 | 600 | |
|---|
| 637 | 601 | /* Creating files for entries inside thunderx_zip directory */ |
|---|
| 638 | | - zip_stats = debugfs_create_file("zip_stats", 0444, |
|---|
| 639 | | - zip_debugfs_root, |
|---|
| 640 | | - NULL, &zip_stats_fops); |
|---|
| 641 | | - if (!zip_stats) |
|---|
| 642 | | - goto failed_to_create; |
|---|
| 602 | + debugfs_create_file("zip_stats", 0444, zip_debugfs_root, NULL, |
|---|
| 603 | + &zip_stats_fops); |
|---|
| 643 | 604 | |
|---|
| 644 | | - zip_clear = debugfs_create_file("zip_clear", 0444, |
|---|
| 645 | | - zip_debugfs_root, |
|---|
| 646 | | - NULL, &zip_clear_fops); |
|---|
| 647 | | - if (!zip_clear) |
|---|
| 648 | | - goto failed_to_create; |
|---|
| 605 | + debugfs_create_file("zip_clear", 0444, zip_debugfs_root, NULL, |
|---|
| 606 | + &zip_clear_fops); |
|---|
| 649 | 607 | |
|---|
| 650 | | - zip_regs = debugfs_create_file("zip_regs", 0444, |
|---|
| 651 | | - zip_debugfs_root, |
|---|
| 652 | | - NULL, &zip_regs_fops); |
|---|
| 653 | | - if (!zip_regs) |
|---|
| 654 | | - goto failed_to_create; |
|---|
| 608 | + debugfs_create_file("zip_regs", 0444, zip_debugfs_root, NULL, |
|---|
| 609 | + &zip_regs_fops); |
|---|
| 655 | 610 | |
|---|
| 656 | | - return 0; |
|---|
| 657 | | - |
|---|
| 658 | | -failed_to_create: |
|---|
| 659 | | - debugfs_remove_recursive(zip_debugfs_root); |
|---|
| 660 | | - return -ENOENT; |
|---|
| 661 | 611 | } |
|---|
| 662 | 612 | |
|---|
| 663 | 613 | static void __exit zip_debugfs_exit(void) |
|---|
| .. | .. |
|---|
| 666 | 616 | } |
|---|
| 667 | 617 | |
|---|
| 668 | 618 | #else |
|---|
| 669 | | -static int __init zip_debugfs_init(void) |
|---|
| 670 | | -{ |
|---|
| 671 | | - return 0; |
|---|
| 672 | | -} |
|---|
| 673 | | - |
|---|
| 619 | +static void __init zip_debugfs_init(void) { } |
|---|
| 674 | 620 | static void __exit zip_debugfs_exit(void) { } |
|---|
| 675 | | - |
|---|
| 676 | 621 | #endif |
|---|
| 677 | 622 | /* debugfs - end */ |
|---|
| 678 | 623 | |
|---|
| .. | .. |
|---|
| 696 | 641 | } |
|---|
| 697 | 642 | |
|---|
| 698 | 643 | /* comp-decomp statistics are handled with debugfs interface */ |
|---|
| 699 | | - ret = zip_debugfs_init(); |
|---|
| 700 | | - if (ret < 0) { |
|---|
| 701 | | - zip_err("ZIP: debugfs initialization failed\n"); |
|---|
| 702 | | - goto err_crypto_unregister; |
|---|
| 703 | | - } |
|---|
| 644 | + zip_debugfs_init(); |
|---|
| 704 | 645 | |
|---|
| 705 | 646 | return ret; |
|---|
| 706 | | - |
|---|
| 707 | | -err_crypto_unregister: |
|---|
| 708 | | - zip_unregister_compression_device(); |
|---|
| 709 | 647 | |
|---|
| 710 | 648 | err_pci_unregister: |
|---|
| 711 | 649 | pci_unregister_driver(&zip_driver); |
|---|