From 8d402e1ae03656c1ad215514f8885ef4793f0948 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Sat, 17 Dec 2005 18:03:37 -0500 Subject: [PATCH] UHCI: improve debugging code This patch (as626) makes some improvements to the debugging code in uhci-hcd. The main change is that now the code won't get compiled if CONFIG_USB_DEBUG isn't set. But there are other changes too, like adding a missing .owner field and printing a debugging dump if the controller dies. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/uhci-debug.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'drivers/usb/host/uhci-debug.c') diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c index f2f5f8ce1715..e1239319655c 100644 --- a/drivers/usb/host/uhci-debug.c +++ b/drivers/usb/host/uhci-debug.c @@ -17,10 +17,13 @@ #include "uhci-hcd.h" -static struct dentry *uhci_debugfs_root = NULL; +#define uhci_debug_operations (* (struct file_operations *) NULL) +static struct dentry *uhci_debugfs_root; + +#ifdef DEBUG /* Handle REALLY large printks so we don't overflow buffers */ -static inline void lprintk(char *buf) +static void lprintk(char *buf) { char *p; @@ -196,7 +199,6 @@ static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space) return out - buf; } -#ifdef CONFIG_PROC_FS static const char * const qh_names[] = { "skel_unlink_qh", "skel_iso_qh", "skel_int128_qh", "skel_int64_qh", @@ -393,12 +395,13 @@ static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len) return out - buf; } +#ifdef CONFIG_DEBUG_FS + #define MAX_OUTPUT (64 * 1024) struct uhci_debug { int size; char *data; - struct uhci_hcd *uhci; }; static int uhci_debug_open(struct inode *inode, struct file *file) @@ -419,8 +422,10 @@ static int uhci_debug_open(struct inode *inode, struct file *file) goto out; } + up->size = 0; spin_lock_irqsave(&uhci->lock, flags); - up->size = uhci_sprint_schedule(uhci, up->data, MAX_OUTPUT); + if (uhci->is_initialized) + up->size = uhci_sprint_schedule(uhci, up->data, MAX_OUTPUT); spin_unlock_irqrestore(&uhci->lock, flags); file->private_data = up; @@ -472,15 +477,32 @@ static int uhci_debug_release(struct inode *inode, struct file *file) return 0; } +#undef uhci_debug_operations static struct file_operations uhci_debug_operations = { + .owner = THIS_MODULE, .open = uhci_debug_open, .llseek = uhci_debug_lseek, .read = uhci_debug_read, .release = uhci_debug_release, }; -#else /* CONFIG_DEBUG_FS */ +#endif /* CONFIG_DEBUG_FS */ -#define uhci_debug_operations (* (struct file_operations *) NULL) +#else /* DEBUG */ + +static inline void lprintk(char *buf) +{} + +static inline int uhci_show_qh(struct uhci_qh *qh, char *buf, + int len, int space) +{ + return 0; +} + +static inline int uhci_sprint_schedule(struct uhci_hcd *uhci, + char *buf, int len) +{ + return 0; +} #endif -- cgit v1.2.3