hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/crypto/cavium/zip/zip_main.c
....@@ -460,7 +460,7 @@
460460 #include <linux/debugfs.h>
461461
462462 /* 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)
464464 {
465465 u64 val = 0ull;
466466 u64 avg_chunk = 0ull, avg_cr = 0ull;
....@@ -523,7 +523,7 @@
523523 }
524524
525525 /* 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)
527527 {
528528 int index = 0;
529529
....@@ -558,7 +558,7 @@
558558 };
559559
560560 /* 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)
562562 {
563563 u64 val = 0;
564564 int i = 0, index = 0;
....@@ -584,80 +584,30 @@
584584 return 0;
585585 }
586586
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);
622590
623591 /* Root directory for thunderx_zip debugfs entry */
624592 static struct dentry *zip_debugfs_root;
625593
626
-static int __init zip_debugfs_init(void)
594
+static void __init zip_debugfs_init(void)
627595 {
628
- struct dentry *zip_stats, *zip_clear, *zip_regs;
629
-
630596 if (!debugfs_initialized())
631
- return -ENODEV;
597
+ return;
632598
633599 zip_debugfs_root = debugfs_create_dir("thunderx_zip", NULL);
634
- if (!zip_debugfs_root)
635
- return -ENOMEM;
636600
637601 /* 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);
643604
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);
649607
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);
655610
656
- return 0;
657
-
658
-failed_to_create:
659
- debugfs_remove_recursive(zip_debugfs_root);
660
- return -ENOENT;
661611 }
662612
663613 static void __exit zip_debugfs_exit(void)
....@@ -666,13 +616,8 @@
666616 }
667617
668618 #else
669
-static int __init zip_debugfs_init(void)
670
-{
671
- return 0;
672
-}
673
-
619
+static void __init zip_debugfs_init(void) { }
674620 static void __exit zip_debugfs_exit(void) { }
675
-
676621 #endif
677622 /* debugfs - end */
678623
....@@ -696,16 +641,9 @@
696641 }
697642
698643 /* 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();
704645
705646 return ret;
706
-
707
-err_crypto_unregister:
708
- zip_unregister_compression_device();
709647
710648 err_pci_unregister:
711649 pci_unregister_driver(&zip_driver);