Skip to content

Commit

Permalink
USB: OHCI: use the ohci structure directly in debugfs files.
Browse files Browse the repository at this point in the history
Right now we jump through some hoops to get to the struct ohci_hcd
struct in the ohci debugfs files.  Remove all of the fun casting around
and just use the pointer directly.

This is needed as the dev pointer in the hcd structure is going away,
and it makes the code simpler and smaller

Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Greg Kroah-Hartman committed Jun 16, 2009
1 parent 74675a5 commit 1098334
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions drivers/usb/host/ohci-dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ static struct dentry *ohci_debug_root;

struct debug_buffer {
ssize_t (*fill_func)(struct debug_buffer *); /* fill method */
struct device *dev;
struct ohci_hcd *ohci;
struct mutex mutex; /* protect filling of buffer */
size_t count; /* number of characters filled into buffer */
char *page;
Expand Down Expand Up @@ -505,15 +505,11 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed)

static ssize_t fill_async_buffer(struct debug_buffer *buf)
{
struct usb_bus *bus;
struct usb_hcd *hcd;
struct ohci_hcd *ohci;
size_t temp;
unsigned long flags;

bus = dev_get_drvdata(buf->dev);
hcd = bus_to_hcd(bus);
ohci = hcd_to_ohci(hcd);
ohci = buf->ohci;

/* display control and bulk lists together, for simplicity */
spin_lock_irqsave (&ohci->lock, flags);
Expand All @@ -529,8 +525,6 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)

static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
{
struct usb_bus *bus;
struct usb_hcd *hcd;
struct ohci_hcd *ohci;
struct ed **seen, *ed;
unsigned long flags;
Expand All @@ -542,9 +536,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
return 0;
seen_count = 0;

bus = (struct usb_bus *)dev_get_drvdata(buf->dev);
hcd = bus_to_hcd(bus);
ohci = hcd_to_ohci(hcd);
ohci = buf->ohci;
next = buf->page;
size = PAGE_SIZE;

Expand Down Expand Up @@ -626,7 +618,6 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)

static ssize_t fill_registers_buffer(struct debug_buffer *buf)
{
struct usb_bus *bus;
struct usb_hcd *hcd;
struct ohci_hcd *ohci;
struct ohci_regs __iomem *regs;
Expand All @@ -635,9 +626,8 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
char *next;
u32 rdata;

bus = (struct usb_bus *)dev_get_drvdata(buf->dev);
hcd = bus_to_hcd(bus);
ohci = hcd_to_ohci(hcd);
ohci = buf->ohci;
hcd = ohci_to_hcd(ohci);
regs = ohci->regs;
next = buf->page;
size = PAGE_SIZE;
Expand Down Expand Up @@ -710,15 +700,15 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
return PAGE_SIZE - size;
}

static struct debug_buffer *alloc_buffer(struct device *dev,
static struct debug_buffer *alloc_buffer(struct ohci_hcd *ohci,
ssize_t (*fill_func)(struct debug_buffer *))
{
struct debug_buffer *buf;

buf = kzalloc(sizeof(struct debug_buffer), GFP_KERNEL);

if (buf) {
buf->dev = dev;
buf->ohci = ohci;
buf->fill_func = fill_func;
mutex_init(&buf->mutex);
}
Expand Down Expand Up @@ -810,26 +800,25 @@ static int debug_registers_open(struct inode *inode, struct file *file)
static inline void create_debug_files (struct ohci_hcd *ohci)
{
struct usb_bus *bus = &ohci_to_hcd(ohci)->self;
struct device *dev = bus->dev;

ohci->debug_dir = debugfs_create_dir(bus->bus_name, ohci_debug_root);
if (!ohci->debug_dir)
goto dir_error;

ohci->debug_async = debugfs_create_file("async", S_IRUGO,
ohci->debug_dir, dev,
ohci->debug_dir, ohci,
&debug_async_fops);
if (!ohci->debug_async)
goto async_error;

ohci->debug_periodic = debugfs_create_file("periodic", S_IRUGO,
ohci->debug_dir, dev,
ohci->debug_dir, ohci,
&debug_periodic_fops);
if (!ohci->debug_periodic)
goto periodic_error;

ohci->debug_registers = debugfs_create_file("registers", S_IRUGO,
ohci->debug_dir, dev,
ohci->debug_dir, ohci,
&debug_registers_fops);
if (!ohci->debug_registers)
goto registers_error;
Expand Down

0 comments on commit 1098334

Please sign in to comment.