Skip to content

Commit

Permalink
USB: mon: Allow to use usbmon without debugfs
Browse files Browse the repository at this point in the history
Do not bail out with an error in mon_text_init() if debugfs is not
available, instead just return 0 and let mon_init() go ahead with
loading the binary API. Return -ENOMEM in case debugfs_create_dir()
fails for other reasons. Later, it is enough to check for mon_dir
not set.

Signed-off-by: Tobias Klauser <[email protected]>
Signed-off-by: Pete Zaitcev <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
tklauser authored and gregkh committed Jul 8, 2011
1 parent 004c196 commit 8dec92b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/usb/mon/mon_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,9 @@ int mon_text_add(struct mon_bus *mbus, const struct usb_bus *ubus)
int busnum = ubus? ubus->busnum: 0;
int rc;

if (mon_dir == NULL)
return 0;

if (ubus != NULL) {
rc = snprintf(name, NAMESZ, "%dt", busnum);
if (rc <= 0 || rc >= NAMESZ)
Expand Down Expand Up @@ -740,12 +743,12 @@ int __init mon_text_init(void)

mondir = debugfs_create_dir("usbmon", usb_debug_root);
if (IS_ERR(mondir)) {
printk(KERN_NOTICE TAG ": debugfs is not available\n");
return -ENODEV;
/* debugfs not available, but we can use usbmon without it */
return 0;
}
if (mondir == NULL) {
printk(KERN_NOTICE TAG ": unable to create usbmon directory\n");
return -ENODEV;
return -ENOMEM;
}
mon_dir = mondir;
return 0;
Expand Down

0 comments on commit 8dec92b

Please sign in to comment.