Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 115764
b: refs/heads/master
c: 3c04e20
h: refs/heads/master
v: v3
  • Loading branch information
Ming Lei authored and Greg Kroah-Hartman committed Oct 17, 2008
1 parent 8d412af commit cc05698
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 549c41e0ac0a3eb68cfdaeb43c1a314e2a6c289a
refs/heads/master: 3c04e20ea95f9a8555456000e0ff340bdc46dea8
44 changes: 25 additions & 19 deletions trunk/drivers/usb/host/ehci-dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ struct debug_buffer {
struct usb_bus *bus;
struct mutex mutex; /* protect filling of buffer */
size_t count; /* number of characters filled into buffer */
char *page;
char *output_buf;
size_t alloc_size;
};

#define speed_char(info1) ({ char tmp; \
Expand Down Expand Up @@ -488,8 +489,8 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)

hcd = bus_to_hcd(buf->bus);
ehci = hcd_to_ehci (hcd);
next = buf->page;
size = PAGE_SIZE;
next = buf->output_buf;
size = buf->alloc_size;

*next = 0;

Expand All @@ -510,7 +511,7 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)
}
spin_unlock_irqrestore (&ehci->lock, flags);

return strlen(buf->page);
return strlen(buf->output_buf);
}

#define DBG_SCHED_LIMIT 64
Expand All @@ -531,8 +532,8 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)

hcd = bus_to_hcd(buf->bus);
ehci = hcd_to_ehci (hcd);
next = buf->page;
size = PAGE_SIZE;
next = buf->output_buf;
size = buf->alloc_size;

temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size);
size -= temp;
Expand Down Expand Up @@ -649,7 +650,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
spin_unlock_irqrestore (&ehci->lock, flags);
kfree (seen);

return PAGE_SIZE - size;
return buf->alloc_size - size;
}
#undef DBG_SCHED_LIMIT

Expand All @@ -665,8 +666,8 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)

hcd = bus_to_hcd(buf->bus);
ehci = hcd_to_ehci (hcd);
next = buf->page;
size = PAGE_SIZE;
next = buf->output_buf;
size = buf->alloc_size;

spin_lock_irqsave (&ehci->lock, flags);

Expand Down Expand Up @@ -808,7 +809,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
done:
spin_unlock_irqrestore (&ehci->lock, flags);

return PAGE_SIZE - size;
return buf->alloc_size - size;
}

static struct debug_buffer *alloc_buffer(struct usb_bus *bus,
Expand All @@ -822,6 +823,7 @@ static struct debug_buffer *alloc_buffer(struct usb_bus *bus,
buf->bus = bus;
buf->fill_func = fill_func;
mutex_init(&buf->mutex);
buf->alloc_size = PAGE_SIZE;
}

return buf;
Expand All @@ -831,10 +833,10 @@ static int fill_buffer(struct debug_buffer *buf)
{
int ret = 0;

if (!buf->page)
buf->page = (char *)get_zeroed_page(GFP_KERNEL);
if (!buf->output_buf)
buf->output_buf = (char *)vmalloc(buf->alloc_size);

if (!buf->page) {
if (!buf->output_buf) {
ret = -ENOMEM;
goto out;
}
Expand Down Expand Up @@ -867,7 +869,7 @@ static ssize_t debug_output(struct file *file, char __user *user_buf,
mutex_unlock(&buf->mutex);

ret = simple_read_from_buffer(user_buf, len, offset,
buf->page, buf->count);
buf->output_buf, buf->count);

out:
return ret;
Expand All @@ -879,8 +881,8 @@ static int debug_close(struct inode *inode, struct file *file)
struct debug_buffer *buf = file->private_data;

if (buf) {
if (buf->page)
free_page((unsigned long)buf->page);
if (buf->output_buf)
vfree(buf->output_buf);
kfree(buf);
}

Expand All @@ -895,10 +897,14 @@ static int debug_async_open(struct inode *inode, struct file *file)

static int debug_periodic_open(struct inode *inode, struct file *file)
{
file->private_data = alloc_buffer(inode->i_private,
fill_periodic_buffer);
struct debug_buffer *buf;
buf = alloc_buffer(inode->i_private, fill_periodic_buffer);
if (!buf)
return -ENOMEM;

return file->private_data ? 0 : -ENOMEM;
buf->alloc_size = (sizeof(void *) == 4 ? 6 : 8)*PAGE_SIZE;
file->private_data = buf;
return 0;
}

static int debug_registers_open(struct inode *inode, struct file *file)
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/usb/host/ehci-hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/ioport.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/timer.h>
Expand Down

0 comments on commit cc05698

Please sign in to comment.