Commit 040fa1b9 authored by Dmitry Baryshkov's avatar Dmitry Baryshkov Committed by Greg Kroah-Hartman

USB: pxa2xx_udc: use debugfs not procfs

Use debugfs instead of /proc/driver/udc
Signed-off-by: default avatarDmitry Baryshkov <dbaryshkov@gmail.com>
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f3db6e82
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* *
*/ */
// #define VERBOSE DBG_VERBOSE /* #define VERBOSE_DEBUG */
#include <linux/device.h> #include <linux/device.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -38,13 +38,14 @@ ...@@ -38,13 +38,14 @@
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/proc_fs.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/seq_file.h>
#include <linux/debugfs.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <asm/dma.h> #include <asm/dma.h>
...@@ -679,7 +680,7 @@ pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) ...@@ -679,7 +680,7 @@ pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
/* kickstart this i/o queue? */ /* kickstart this i/o queue? */
if (list_empty(&ep->queue) && !ep->stopped) { if (list_empty(&ep->queue) && !ep->stopped) {
if (ep->desc == 0 /* ep0 */) { if (ep->desc == NULL/* ep0 */) {
unsigned length = _req->length; unsigned length = _req->length;
switch (dev->ep0state) { switch (dev->ep0state) {
...@@ -733,7 +734,7 @@ pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) ...@@ -733,7 +734,7 @@ pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
} }
/* pio or dma irq handler advances the queue. */ /* pio or dma irq handler advances the queue. */
if (likely (req != 0)) if (likely(req != NULL))
list_add_tail(&req->queue, &ep->queue); list_add_tail(&req->queue, &ep->queue);
local_irq_restore(flags); local_irq_restore(flags);
...@@ -993,45 +994,32 @@ static const struct usb_gadget_ops pxa2xx_udc_ops = { ...@@ -993,45 +994,32 @@ static const struct usb_gadget_ops pxa2xx_udc_ops = {
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
#ifdef CONFIG_USB_GADGET_DEBUG_FILES #ifdef CONFIG_USB_GADGET_DEBUG_FS
static const char proc_node_name [] = "driver/udc";
static int static int
udc_proc_read(char *page, char **start, off_t off, int count, udc_seq_show(struct seq_file *m, void *d)
int *eof, void *_dev)
{ {
char *buf = page; struct pxa2xx_udc *dev = m->private;
struct pxa2xx_udc *dev = _dev;
char *next = buf;
unsigned size = count;
unsigned long flags; unsigned long flags;
int i, t; int i;
u32 tmp; u32 tmp;
if (off != 0)
return 0;
local_irq_save(flags); local_irq_save(flags);
/* basic device status */ /* basic device status */
t = scnprintf(next, size, DRIVER_DESC "\n" seq_printf(m, DRIVER_DESC "\n"
"%s version: %s\nGadget driver: %s\nHost %s\n\n", "%s version: %s\nGadget driver: %s\nHost %s\n\n",
driver_name, DRIVER_VERSION SIZE_STR "(pio)", driver_name, DRIVER_VERSION SIZE_STR "(pio)",
dev->driver ? dev->driver->driver.name : "(none)", dev->driver ? dev->driver->driver.name : "(none)",
is_vbus_present() ? "full speed" : "disconnected"); is_vbus_present() ? "full speed" : "disconnected");
size -= t;
next += t;
/* registers for device and ep0 */ /* registers for device and ep0 */
t = scnprintf(next, size, seq_printf(m,
"uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n", "uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n",
UICR1, UICR0, USIR1, USIR0, UFNRH, UFNRL); UICR1, UICR0, USIR1, USIR0, UFNRH, UFNRL);
size -= t;
next += t;
tmp = UDCCR; tmp = UDCCR;
t = scnprintf(next, size, seq_printf(m,
"udccr %02X =%s%s%s%s%s%s%s%s\n", tmp, "udccr %02X =%s%s%s%s%s%s%s%s\n", tmp,
(tmp & UDCCR_REM) ? " rem" : "", (tmp & UDCCR_REM) ? " rem" : "",
(tmp & UDCCR_RSTIR) ? " rstir" : "", (tmp & UDCCR_RSTIR) ? " rstir" : "",
...@@ -1041,11 +1029,9 @@ udc_proc_read(char *page, char **start, off_t off, int count, ...@@ -1041,11 +1029,9 @@ udc_proc_read(char *page, char **start, off_t off, int count,
(tmp & UDCCR_RSM) ? " rsm" : "", (tmp & UDCCR_RSM) ? " rsm" : "",
(tmp & UDCCR_UDA) ? " uda" : "", (tmp & UDCCR_UDA) ? " uda" : "",
(tmp & UDCCR_UDE) ? " ude" : ""); (tmp & UDCCR_UDE) ? " ude" : "");
size -= t;
next += t;
tmp = UDCCS0; tmp = UDCCS0;
t = scnprintf(next, size, seq_printf(m,
"udccs0 %02X =%s%s%s%s%s%s%s%s\n", tmp, "udccs0 %02X =%s%s%s%s%s%s%s%s\n", tmp,
(tmp & UDCCS0_SA) ? " sa" : "", (tmp & UDCCS0_SA) ? " sa" : "",
(tmp & UDCCS0_RNE) ? " rne" : "", (tmp & UDCCS0_RNE) ? " rne" : "",
...@@ -1055,28 +1041,22 @@ udc_proc_read(char *page, char **start, off_t off, int count, ...@@ -1055,28 +1041,22 @@ udc_proc_read(char *page, char **start, off_t off, int count,
(tmp & UDCCS0_FTF) ? " ftf" : "", (tmp & UDCCS0_FTF) ? " ftf" : "",
(tmp & UDCCS0_IPR) ? " ipr" : "", (tmp & UDCCS0_IPR) ? " ipr" : "",
(tmp & UDCCS0_OPR) ? " opr" : ""); (tmp & UDCCS0_OPR) ? " opr" : "");
size -= t;
next += t;
if (dev->has_cfr) { if (dev->has_cfr) {
tmp = UDCCFR; tmp = UDCCFR;
t = scnprintf(next, size, seq_printf(m,
"udccfr %02X =%s%s\n", tmp, "udccfr %02X =%s%s\n", tmp,
(tmp & UDCCFR_AREN) ? " aren" : "", (tmp & UDCCFR_AREN) ? " aren" : "",
(tmp & UDCCFR_ACM) ? " acm" : ""); (tmp & UDCCFR_ACM) ? " acm" : "");
size -= t;
next += t;
} }
if (!is_vbus_present() || !dev->driver) if (!is_vbus_present() || !dev->driver)
goto done; goto done;
t = scnprintf(next, size, "ep0 IN %lu/%lu, OUT %lu/%lu\nirqs %lu\n\n", seq_printf(m, "ep0 IN %lu/%lu, OUT %lu/%lu\nirqs %lu\n\n",
dev->stats.write.bytes, dev->stats.write.ops, dev->stats.write.bytes, dev->stats.write.ops,
dev->stats.read.bytes, dev->stats.read.ops, dev->stats.read.bytes, dev->stats.read.ops,
dev->stats.irqs); dev->stats.irqs);
size -= t;
next += t;
/* dump endpoint queues */ /* dump endpoint queues */
for (i = 0; i < PXA_UDC_NUM_ENDPOINTS; i++) { for (i = 0; i < PXA_UDC_NUM_ENDPOINTS; i++) {
...@@ -1084,61 +1064,68 @@ udc_proc_read(char *page, char **start, off_t off, int count, ...@@ -1084,61 +1064,68 @@ udc_proc_read(char *page, char **start, off_t off, int count,
struct pxa2xx_request *req; struct pxa2xx_request *req;
if (i != 0) { if (i != 0) {
const struct usb_endpoint_descriptor *d; const struct usb_endpoint_descriptor *desc;
d = ep->desc; desc = ep->desc;
if (!d) if (!desc)
continue; continue;
tmp = *dev->ep [i].reg_udccs; tmp = *dev->ep [i].reg_udccs;
t = scnprintf(next, size, seq_printf(m,
"%s max %d %s udccs %02x irqs %lu\n", "%s max %d %s udccs %02x irqs %lu\n",
ep->ep.name, le16_to_cpu (d->wMaxPacketSize), ep->ep.name, le16_to_cpu(desc->wMaxPacketSize),
"pio", tmp, ep->pio_irqs); "pio", tmp, ep->pio_irqs);
/* TODO translate all five groups of udccs bits! */ /* TODO translate all five groups of udccs bits! */
} else /* ep0 should only have one transfer queued */ } else /* ep0 should only have one transfer queued */
t = scnprintf(next, size, "ep0 max 16 pio irqs %lu\n", seq_printf(m, "ep0 max 16 pio irqs %lu\n",
ep->pio_irqs); ep->pio_irqs);
if (t <= 0 || t > size)
goto done;
size -= t;
next += t;
if (list_empty(&ep->queue)) { if (list_empty(&ep->queue)) {
t = scnprintf(next, size, "\t(nothing queued)\n"); seq_printf(m, "\t(nothing queued)\n");
if (t <= 0 || t > size)
goto done;
size -= t;
next += t;
continue; continue;
} }
list_for_each_entry(req, &ep->queue, queue) { list_for_each_entry(req, &ep->queue, queue) {
t = scnprintf(next, size, seq_printf(m,
"\treq %p len %d/%d buf %p\n", "\treq %p len %d/%d buf %p\n",
&req->req, req->req.actual, &req->req, req->req.actual,
req->req.length, req->req.buf); req->req.length, req->req.buf);
if (t <= 0 || t > size)
goto done;
size -= t;
next += t;
} }
} }
done: done:
local_irq_restore(flags); local_irq_restore(flags);
*eof = 1; return 0;
return count - size;
} }
#define create_proc_files() \ static int
create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev) udc_debugfs_open(struct inode *inode, struct file *file)
#define remove_proc_files() \ {
remove_proc_entry(proc_node_name, NULL) return single_open(file, udc_seq_show, inode->i_private);
}
static const struct file_operations debug_fops = {
.open = udc_debugfs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.owner = THIS_MODULE,
};
#define create_debug_files(dev) \
do { \
dev->debugfs_udc = debugfs_create_file(dev->gadget.name, \
S_IRUGO, NULL, dev, &debug_fops); \
} while (0)
#define remove_debug_files(dev) \
do { \
if (dev->debugfs_udc) \
debugfs_remove(dev->debugfs_udc); \
} while (0)
#else /* !CONFIG_USB_GADGET_DEBUG_FILES */ #else /* !CONFIG_USB_GADGET_DEBUG_FILES */
#define create_proc_files() do {} while (0) #define create_debug_files(dev) do {} while (0)
#define remove_proc_files() do {} while (0) #define remove_debug_files(dev) do {} while (0)
#endif /* CONFIG_USB_GADGET_DEBUG_FILES */ #endif /* CONFIG_USB_GADGET_DEBUG_FILES */
...@@ -2246,7 +2233,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev) ...@@ -2246,7 +2233,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
goto err_vbus_irq; goto err_vbus_irq;
} }
} }
create_proc_files(); create_debug_files(dev);
return 0; return 0;
...@@ -2283,7 +2270,7 @@ static int __exit pxa2xx_udc_remove(struct platform_device *pdev) ...@@ -2283,7 +2270,7 @@ static int __exit pxa2xx_udc_remove(struct platform_device *pdev)
return -EBUSY; return -EBUSY;
udc_disable(dev); udc_disable(dev);
remove_proc_files(); remove_debug_files(dev);
if (dev->got_irq) { if (dev->got_irq) {
free_irq(platform_get_irq(pdev, 0), dev); free_irq(platform_get_irq(pdev, 0), dev);
......
...@@ -129,6 +129,10 @@ struct pxa2xx_udc { ...@@ -129,6 +129,10 @@ struct pxa2xx_udc {
struct pxa2xx_udc_mach_info *mach; struct pxa2xx_udc_mach_info *mach;
u64 dma_mask; u64 dma_mask;
struct pxa2xx_ep ep [PXA_UDC_NUM_ENDPOINTS]; struct pxa2xx_ep ep [PXA_UDC_NUM_ENDPOINTS];
#ifdef CONFIG_USB_GADGET_DEBUG_FS
struct dentry *debugfs_udc;
#endif
}; };
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -155,13 +159,15 @@ static struct pxa2xx_udc *the_controller; ...@@ -155,13 +159,15 @@ static struct pxa2xx_udc *the_controller;
#ifdef DEBUG #ifdef DEBUG
static int is_vbus_present(void);
static const char *state_name[] = { static const char *state_name[] = {
"EP0_IDLE", "EP0_IDLE",
"EP0_IN_DATA_PHASE", "EP0_OUT_DATA_PHASE", "EP0_IN_DATA_PHASE", "EP0_OUT_DATA_PHASE",
"EP0_END_XFER", "EP0_STALL" "EP0_END_XFER", "EP0_STALL"
}; };
#ifdef VERBOSE #ifdef VERBOSE_DEBUG
# define UDC_DEBUG DBG_VERBOSE # define UDC_DEBUG DBG_VERBOSE
#else #else
# define UDC_DEBUG DBG_NORMAL # define UDC_DEBUG DBG_NORMAL
...@@ -207,7 +213,7 @@ dump_state(struct pxa2xx_udc *dev) ...@@ -207,7 +213,7 @@ dump_state(struct pxa2xx_udc *dev)
unsigned i; unsigned i;
DMSG("%s %s, uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n", DMSG("%s %s, uicr %02X.%02X, usir %02X.%02x, ufnr %02X.%02X\n",
is_usb_connected() ? "host " : "disconnected", is_vbus_present() ? "host " : "disconnected",
state_name[dev->ep0state], state_name[dev->ep0state],
UICR1, UICR0, USIR1, USIR0, UFNRH, UFNRL); UICR1, UICR0, USIR1, USIR0, UFNRH, UFNRL);
dump_udccr("udccr"); dump_udccr("udccr");
...@@ -224,7 +230,7 @@ dump_state(struct pxa2xx_udc *dev) ...@@ -224,7 +230,7 @@ dump_state(struct pxa2xx_udc *dev)
} else } else
DMSG("ep0 driver '%s'\n", dev->driver->driver.name); DMSG("ep0 driver '%s'\n", dev->driver->driver.name);
if (!is_usb_connected()) if (!is_vbus_present())
return; return;
dump_udccs0 ("udccs0"); dump_udccs0 ("udccs0");
...@@ -233,7 +239,7 @@ dump_state(struct pxa2xx_udc *dev) ...@@ -233,7 +239,7 @@ dump_state(struct pxa2xx_udc *dev)
dev->stats.read.bytes, dev->stats.read.ops); dev->stats.read.bytes, dev->stats.read.ops);
for (i = 1; i < PXA_UDC_NUM_ENDPOINTS; i++) { for (i = 1; i < PXA_UDC_NUM_ENDPOINTS; i++) {
if (dev->ep [i].desc == 0) if (dev->ep [i].desc == NULL)
continue; continue;
DMSG ("udccs%d = %02x\n", i, *dev->ep->reg_udccs); DMSG ("udccs%d = %02x\n", i, *dev->ep->reg_udccs);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment