* UHCI-specific debugging code. Invaluable when something
* goes wrong, but don't get in my face.
*
- * Kernel visible pointers are surrounded in []'s and bus
- * visible pointers are surrounded in ()'s
+ * Kernel visible pointers are surrounded in []s and bus
+ * visible pointers are surrounded in ()s
*
* (C) Copyright 1999 Linus Torvalds
* (C) Copyright 1999-2001 Johannes Erdfelt
#include <linux/config.h>
#include <linux/kernel.h>
-#include <linux/proc_fs.h>
+#include <linux/debugfs.h>
#include <linux/smp_lock.h>
#include <asm/io.h>
#include "uhci-hcd.h"
-/* Handle REALLY large printk's so we don't overflow buffers */
+static struct dentry *uhci_debugfs_root = NULL;
+
+/* Handle REALLY large printks so we don't overflow buffers */
static inline void lprintk(char *buf)
{
char *p;
struct list_head *head, *tmp;
struct uhci_td *td;
int i = 0, checked = 0, prevactive = 0;
+ __le32 element = qh_element(qh);
/* Try to make sure there's enough memory */
if (len < 80 * 6)
return 0;
out += sprintf(out, "%*s[%p] link (%08x) element (%08x)\n", space, "",
- qh, le32_to_cpu(qh->link), le32_to_cpu(qh->element));
+ qh, le32_to_cpu(qh->link), le32_to_cpu(element));
- if (qh->element & UHCI_PTR_QH)
+ if (element & UHCI_PTR_QH)
out += sprintf(out, "%*s Element points to QH (bug?)\n", space, "");
- if (qh->element & UHCI_PTR_DEPTH)
+ if (element & UHCI_PTR_DEPTH)
out += sprintf(out, "%*s Depth traverse\n", space, "");
- if (qh->element & cpu_to_le32(8))
+ if (element & cpu_to_le32(8))
out += sprintf(out, "%*s Bit 3 set (bug?)\n", space, "");
- if (!(qh->element & ~(UHCI_PTR_QH | UHCI_PTR_DEPTH)))
+ if (!(element & ~(UHCI_PTR_QH | UHCI_PTR_DEPTH)))
out += sprintf(out, "%*s Element is NULL (bug?)\n", space, "");
if (!qh->urbp) {
td = list_entry(tmp, struct uhci_td, list);
- if (cpu_to_le32(td->dma_handle) != (qh->element & ~UHCI_PTR_BITS))
+ if (cpu_to_le32(td->dma_handle) != (element & ~UHCI_PTR_BITS))
out += sprintf(out, "%*s Element != First TD\n", space, "");
while (tmp != head) {
}
if (active && ni > i) {
- out += sprintf(out, "%*s[skipped %d active TD's]\n", space, "", ni - i);
+ out += sprintf(out, "%*s[skipped %d active TDs]\n", space, "", ni - i);
tmp = ntmp;
td = ntd;
i = ni;
if (list_empty(&urbp->queue_list) || urbp->queued)
goto out;
- out += sprintf(out, "%*sQueued QH's:\n", -space, "--");
+ out += sprintf(out, "%*sQueued QHs:\n", -space, "--");
head = &urbp->queue_list;
tmp = head->next;
}
#ifdef CONFIG_PROC_FS
-static const char *qh_names[] = {
+static const char * const qh_names[] = {
"skel_int128_qh", "skel_int64_qh",
"skel_int32_qh", "skel_int16_qh",
"skel_int8_qh", "skel_int4_qh",
return out - buf;
}
+static int uhci_show_root_hub_state(struct uhci_hcd *uhci, char *buf, int len)
+{
+ char *out = buf;
+ char *rh_state;
+
+ /* Try to make sure there's enough memory */
+ if (len < 60)
+ return 0;
+
+ switch (uhci->rh_state) {
+ case UHCI_RH_RESET:
+ rh_state = "reset"; break;
+ case UHCI_RH_SUSPENDED:
+ rh_state = "suspended"; break;
+ case UHCI_RH_AUTO_STOPPED:
+ rh_state = "auto-stopped"; break;
+ case UHCI_RH_RESUMING:
+ rh_state = "resuming"; break;
+ case UHCI_RH_SUSPENDING:
+ rh_state = "suspending"; break;
+ case UHCI_RH_RUNNING:
+ rh_state = "running"; break;
+ case UHCI_RH_RUNNING_NODEVS:
+ rh_state = "running, no devs"; break;
+ default:
+ rh_state = "?"; break;
+ }
+ out += sprintf(out, "Root-hub state: %s\n", rh_state);
+ return out - buf;
+}
+
static int uhci_show_status(struct uhci_hcd *uhci, char *buf, int len)
{
char *out = buf;
if (urbp->urb->status != -EINPROGRESS)
out += sprintf(out, "Status=%d ", urbp->urb->status);
- //out += sprintf(out, "Inserttime=%lx ",urbp->inserttime);
//out += sprintf(out, "FSBRtime=%lx ",urbp->fsbrtime);
count = 0;
struct uhci_td *td;
struct list_head *tmp, *head;
- spin_lock_irqsave(&uhci->schedule_lock, flags);
+ spin_lock_irqsave(&uhci->lock, flags);
+ out += uhci_show_root_hub_state(uhci, out, len - (out - buf));
out += sprintf(out, "HC status\n");
out += uhci_show_status(uhci, out, len - (out - buf));
out += sprintf(out, "Frame List\n");
for (i = 0; i < UHCI_NUMFRAMES; ++i) {
int shown = 0;
- td = uhci->fl->frame_cpu[i];
+ td = uhci->frame_cpu[i];
if (!td)
continue;
- if (td->dma_handle != (dma_addr_t)uhci->fl->frame[i]) {
+ if (td->dma_handle != (dma_addr_t)uhci->frame[i]) {
show_frame_num();
out += sprintf(out, " frame list does not match td->dma_handle!\n");
}
} while (tmp != head);
}
- out += sprintf(out, "Skeleton QH's\n");
+ out += sprintf(out, "Skeleton QHs\n");
for (i = 0; i < UHCI_NUM_SKELQH; ++i) {
int shown = 0;
if (qh->link != UHCI_PTR_TERM)
out += sprintf(out, " bandwidth reclamation on!\n");
- if (qh->element != cpu_to_le32(uhci->term_td->dma_handle))
+ if (qh_element(qh) != cpu_to_le32(uhci->term_td->dma_handle))
out += sprintf(out, " skel_term_qh element is not set to term_td!\n");
continue;
if (debug > 2)
out += uhci_show_lists(uhci, out, len - (out - buf));
- spin_unlock_irqrestore(&uhci->schedule_lock, flags);
+ spin_unlock_irqrestore(&uhci->lock, flags);
return out - buf;
}
#define MAX_OUTPUT (64 * 1024)
-static struct proc_dir_entry *uhci_proc_root = NULL;
-
-struct uhci_proc {
+struct uhci_debug {
int size;
char *data;
struct uhci_hcd *uhci;
};
-static int uhci_proc_open(struct inode *inode, struct file *file)
+static int uhci_debug_open(struct inode *inode, struct file *file)
{
- const struct proc_dir_entry *dp = PDE(inode);
- struct uhci_hcd *uhci = dp->data;
- struct uhci_proc *up;
+ struct uhci_hcd *uhci = inode->u.generic_ip;
+ struct uhci_debug *up;
int ret = -ENOMEM;
lock_kernel();
return ret;
}
-static loff_t uhci_proc_lseek(struct file *file, loff_t off, int whence)
+static loff_t uhci_debug_lseek(struct file *file, loff_t off, int whence)
{
- struct uhci_proc *up;
+ struct uhci_debug *up;
loff_t new = -1;
lock_kernel();
return (file->f_pos = new);
}
-static ssize_t uhci_proc_read(struct file *file, char __user *buf,
+static ssize_t uhci_debug_read(struct file *file, char __user *buf,
size_t nbytes, loff_t *ppos)
{
- struct uhci_proc *up = file->private_data;
+ struct uhci_debug *up = file->private_data;
return simple_read_from_buffer(buf, nbytes, ppos, up->data, up->size);
}
-static int uhci_proc_release(struct inode *inode, struct file *file)
+static int uhci_debug_release(struct inode *inode, struct file *file)
{
- struct uhci_proc *up = file->private_data;
+ struct uhci_debug *up = file->private_data;
kfree(up->data);
kfree(up);
return 0;
}
-static struct file_operations uhci_proc_operations = {
- .open = uhci_proc_open,
- .llseek = uhci_proc_lseek,
- .read = uhci_proc_read,
-// write: uhci_proc_write,
- .release = uhci_proc_release,
+static struct file_operations uhci_debug_operations = {
+ .open = uhci_debug_open,
+ .llseek = uhci_debug_lseek,
+ .read = uhci_debug_read,
+ .release = uhci_debug_release,
};
+
+#else /* CONFIG_DEBUG_FS */
+
+#define uhci_debug_operations (* (struct file_operations *) NULL)
+
#endif