aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/mon/mon_text.c
diff options
context:
space:
mode:
authorPete Zaitcev <zaitcev@redhat.com>2007-05-03 19:51:16 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-12 19:29:47 -0400
commitce7cd137fced114d49178b73d468b82096a107fb (patch)
treedfc1f49df82d6ec3b301d786e79ae9481dcc83dd /drivers/usb/mon/mon_text.c
parent49cdee0ed0fce9e1bda81f5dcad8d5cce6aec983 (diff)
usbmon: Add class for binary interface
Add a class which allows for an easier integration with udev. This code was originally written by Paolo Abeni, and arrived to my tree as a part of big patch to add binary API on December 18. As I understand, Paolo always meant the class to be a part of the whole thing. This is his udev rule to go along with the patch: KERNEL=="usbmon[0-9]*", NAME="usbmon%n", MODE="0440",OWNER="root",GROUP="bin" Signed-off-by: Pete Zaitcev <zaitcev@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/mon/mon_text.c')
-rw-r--r--drivers/usb/mon/mon_text.c29
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
658int mon_text_add(struct mon_bus *mbus, int busnum) 658int 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;
695err_create_u: 699err_create_u:
696err_print_u: 700err_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 }
699err_create_t: 705err_create_t:
700err_print_t: 706err_print_t:
701 return 0; 707 return 0;
@@ -704,7 +710,8 @@ err_print_t:
704void mon_text_del(struct mon_bus *mbus) 710void 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