diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-02 00:51:54 (GMT) |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-02 00:51:54 (GMT) |
commit | 20b4fb485227404329e41ad15588afad3df23050 (patch) | |
tree | f3e099f0ab3da8a93b447203e294d2bb22f6dc05 /drivers/usb/gadget/goku_udc.c | |
parent | b9394d8a657cd3c064fa432aa0905c1b58b38fe9 (diff) | |
parent | ac3e3c5b1164397656df81b9e9ab4991184d3236 (diff) | |
download | linux-20b4fb485227404329e41ad15588afad3df23050.tar.xz |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull VFS updates from Al Viro,
Misc cleanups all over the place, mainly wrt /proc interfaces (switch
create_proc_entry to proc_create(), get rid of the deprecated
create_proc_read_entry() in favor of using proc_create_data() and
seq_file etc).
7kloc removed.
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (204 commits)
don't bother with deferred freeing of fdtables
proc: Move non-public stuff from linux/proc_fs.h to fs/proc/internal.h
proc: Make the PROC_I() and PDE() macros internal to procfs
proc: Supply a function to remove a proc entry by PDE
take cgroup_open() and cpuset_open() to fs/proc/base.c
ppc: Clean up scanlog
ppc: Clean up rtas_flash driver somewhat
hostap: proc: Use remove_proc_subtree()
drm: proc: Use remove_proc_subtree()
drm: proc: Use minor->index to label things, not PDE->name
drm: Constify drm_proc_list[]
zoran: Don't print proc_dir_entry data in debug
reiserfs: Don't access the proc_dir_entry in r_open(), r_start() r_show()
proc: Supply an accessor for getting the data from a PDE's parent
airo: Use remove_proc_subtree()
rtl8192u: Don't need to save device proc dir PDE
rtl8187se: Use a dir under /proc/net/r8180/
proc: Add proc_mkdir_data()
proc: Move some bits from linux/proc_fs.h to linux/{of.h,signal.h,tty.h}
proc: Move PDE_NET() to fs/proc/proc_net.c
...
Diffstat (limited to 'drivers/usb/gadget/goku_udc.c')
-rw-r--r-- | drivers/usb/gadget/goku_udc.c | 89 |
1 files changed, 39 insertions, 50 deletions
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 991aba3..480eeb7 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c @@ -35,6 +35,7 @@ #include <linux/list.h> #include <linux/interrupt.h> #include <linux/proc_fs.h> +#include <linux/seq_file.h> #include <linux/device.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h> @@ -1005,7 +1006,7 @@ static const struct usb_gadget_ops goku_ops = { /*-------------------------------------------------------------------------*/ -static inline char *dmastr(void) +static inline const char *dmastr(void) { if (use_dma == 0) return "(dma disabled)"; @@ -1022,13 +1023,10 @@ static const char proc_node_name [] = "driver/udc"; #define FOURBITS "%s%s%s%s" #define EIGHTBITS FOURBITS FOURBITS -static void -dump_intmask(const char *label, u32 mask, char **next, unsigned *size) +static void dump_intmask(struct seq_file *m, const char *label, u32 mask) { - int t; - /* int_status is the same format ... */ - t = scnprintf(*next, *size, + seq_printf(m, "%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n", label, mask, (mask & INT_PWRDETECT) ? " power" : "", @@ -1055,33 +1053,23 @@ dump_intmask(const char *label, u32 mask, char **next, unsigned *size) (mask & INT_ENDPOINT0) ? " ep0" : "", (mask & INT_USBRESET) ? " reset" : "", (mask & INT_SUSPEND) ? " suspend" : ""); - *size -= t; - *next += t; } -static int -udc_proc_read(char *buffer, char **start, off_t off, int count, - int *eof, void *_dev) +static int udc_proc_read(struct seq_file *m, void *v) { - char *buf = buffer; - struct goku_udc *dev = _dev; + struct goku_udc *dev = m->private; struct goku_udc_regs __iomem *regs = dev->regs; - char *next = buf; - unsigned size = count; unsigned long flags; - int i, t, is_usb_connected; + int i, is_usb_connected; u32 tmp; - if (off != 0) - return 0; - local_irq_save(flags); /* basic device status */ tmp = readl(®s->power_detect); is_usb_connected = tmp & PW_DETECT; - t = scnprintf(next, size, + seq_printf(m, "%s - %s\n" "%s version: %s %s\n" "Gadget driver: %s\n" @@ -1093,7 +1081,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, is_usb_connected ? ((tmp & PW_PULLUP) ? "full speed" : "powered") : "disconnected", - ({char *state; + ({const char *state; switch(dev->ep0state){ case EP0_DISCONNECT: state = "ep0_disconnect"; break; case EP0_IDLE: state = "ep0_idle"; break; @@ -1105,27 +1093,24 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, default: state = "ep0_?"; break; } state; }) ); - size -= t; - next += t; - dump_intmask("int_status", readl(®s->int_status), &next, &size); - dump_intmask("int_enable", readl(®s->int_enable), &next, &size); + dump_intmask(m, "int_status", readl(®s->int_status)); + dump_intmask(m, "int_enable", readl(®s->int_enable)); if (!is_usb_connected || !dev->driver || (tmp & PW_PULLUP) == 0) goto done; /* registers for (active) device and ep0 */ - t = scnprintf(next, size, "\nirqs %lu\ndataset %02x " + if (seq_printf(m, "\nirqs %lu\ndataset %02x " "single.bcs %02x.%02x state %x addr %u\n", dev->irqs, readl(®s->DataSet), readl(®s->EPxSingle), readl(®s->EPxBCS), readl(®s->UsbState), - readl(®s->address)); - size -= t; - next += t; + readl(®s->address)) < 0) + goto done; tmp = readl(®s->dma_master); - t = scnprintf(next, size, + if (seq_printf(m, "dma %03X =" EIGHTBITS "%s %s\n", tmp, (tmp & MST_EOPB_DIS) ? " eopb-" : "", (tmp & MST_EOPB_ENA) ? " eopb+" : "", @@ -1140,9 +1125,8 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, (tmp & MST_WR_ENA) ? " OUT" : "", (tmp & MST_CONNECTION) ? "ep1in/ep2out" - : "ep1out/ep2in"); - size -= t; - next += t; + : "ep1out/ep2in") < 0) + goto done; /* dump endpoint queues */ for (i = 0; i < 4; i++) { @@ -1153,7 +1137,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, continue; tmp = readl(ep->reg_status); - t = scnprintf(next, size, + if (seq_printf(m, "%s %s max %u %s, irqs %lu, " "status %02x (%s) " FOURBITS "\n", ep->ep.name, @@ -1186,18 +1170,12 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, (tmp & EPxSTATUS_SUSPEND) ? " suspend" : "", (tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "", (tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : "" - ); - if (t <= 0 || t > size) + ) < 0) goto done; - size -= t; - next += t; if (list_empty(&ep->queue)) { - t = scnprintf(next, size, "\t(nothing queued)\n"); - if (t <= 0 || t > size) + if (seq_puts(m, "\t(nothing queued)\n") < 0) goto done; - size -= t; - next += t; continue; } list_for_each_entry(req, &ep->queue, queue) { @@ -1211,23 +1189,34 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, } else tmp = req->req.actual; - t = scnprintf(next, size, + if (seq_printf(m, "\treq %p len %u/%u buf %p\n", &req->req, tmp, req->req.length, - req->req.buf); - if (t <= 0 || t > size) + req->req.buf) < 0) goto done; - size -= t; - next += t; } } done: local_irq_restore(flags); - *eof = 1; - return count - size; + return 0; +} + +/* + * seq_file wrappers for procfile show routines. + */ +static int udc_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, udc_proc_read, PDE_DATA(file_inode(file))); } +static const struct file_operations udc_proc_fops = { + .open = udc_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ /*-------------------------------------------------------------------------*/ @@ -1796,7 +1785,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) #ifdef CONFIG_USB_GADGET_DEBUG_FILES - create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev); + proc_create_data(proc_node_name, 0, NULL, &udc_proc_fops, dev); #endif retval = usb_add_gadget_udc_release(&pdev->dev, &dev->gadget, |