diff options
Diffstat (limited to 'drivers/usb/mon/mon_text.c')
-rw-r--r-- | drivers/usb/mon/mon_text.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c index ec0cc51e39ac..982b773d71e6 100644 --- a/drivers/usb/mon/mon_text.c +++ b/drivers/usb/mon/mon_text.c | |||
@@ -655,20 +655,24 @@ static const struct file_operations mon_fops_text_u = { | |||
655 | .release = mon_text_release, | 655 | .release = mon_text_release, |
656 | }; | 656 | }; |
657 | 657 | ||
658 | int mon_text_add(struct mon_bus *mbus, int busnum) | 658 | int mon_text_add(struct mon_bus *mbus, const struct usb_bus *ubus) |
659 | { | 659 | { |
660 | struct dentry *d; | 660 | struct dentry *d; |
661 | enum { NAMESZ = 10 }; | 661 | enum { NAMESZ = 10 }; |
662 | char name[NAMESZ]; | 662 | char name[NAMESZ]; |
663 | int busnum = ubus? ubus->busnum: 0; | ||
663 | int rc; | 664 | int rc; |
664 | 665 | ||
665 | rc = snprintf(name, NAMESZ, "%dt", busnum); | 666 | if (ubus != NULL) { |
666 | if (rc <= 0 || rc >= NAMESZ) | 667 | rc = snprintf(name, NAMESZ, "%dt", busnum); |
667 | goto err_print_t; | 668 | if (rc <= 0 || rc >= NAMESZ) |
668 | d = debugfs_create_file(name, 0600, mon_dir, mbus, &mon_fops_text_t); | 669 | goto err_print_t; |
669 | if (d == NULL) | 670 | d = debugfs_create_file(name, 0600, mon_dir, mbus, |
670 | goto err_create_t; | 671 | &mon_fops_text_t); |
671 | mbus->dent_t = d; | 672 | if (d == NULL) |
673 | goto err_create_t; | ||
674 | mbus->dent_t = d; | ||
675 | } | ||
672 | 676 | ||
673 | rc = snprintf(name, NAMESZ, "%du", busnum); | 677 | rc = snprintf(name, NAMESZ, "%du", busnum); |
674 | if (rc <= 0 || rc >= NAMESZ) | 678 | if (rc <= 0 || rc >= NAMESZ) |
@@ -694,8 +698,10 @@ err_print_s: | |||
694 | mbus->dent_u = NULL; | 698 | mbus->dent_u = NULL; |
695 | err_create_u: | 699 | err_create_u: |
696 | err_print_u: | 700 | err_print_u: |
697 | debugfs_remove(mbus->dent_t); | 701 | if (ubus != NULL) { |
698 | mbus->dent_t = NULL; | 702 | debugfs_remove(mbus->dent_t); |
703 | mbus->dent_t = NULL; | ||
704 | } | ||
699 | err_create_t: | 705 | err_create_t: |
700 | err_print_t: | 706 | err_print_t: |
701 | return 0; | 707 | return 0; |
@@ -704,7 +710,8 @@ err_print_t: | |||
704 | void mon_text_del(struct mon_bus *mbus) | 710 | void mon_text_del(struct mon_bus *mbus) |
705 | { | 711 | { |
706 | debugfs_remove(mbus->dent_u); | 712 | debugfs_remove(mbus->dent_u); |
707 | debugfs_remove(mbus->dent_t); | 713 | if (mbus->dent_t != NULL) |
714 | debugfs_remove(mbus->dent_t); | ||
708 | debugfs_remove(mbus->dent_s); | 715 | debugfs_remove(mbus->dent_s); |
709 | } | 716 | } |
710 | 717 | ||