Commit 96c7a22e authored by David Howells's avatar David Howells Committed by Al Viro

goku_udc: Don't use create_proc_read_entry()

Don't use create_proc_read_entry() as that is deprecated, but rather use
proc_create_data() and seq_file instead.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
cc: Felipe Balbi <balbi@ti.com>
cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
cc: linux-usb@vger.kernel.org
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent f1cc0444
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/usb/ch9.h> #include <linux/usb/ch9.h>
#include <linux/usb/gadget.h> #include <linux/usb/gadget.h>
...@@ -1008,7 +1009,7 @@ static const struct usb_gadget_ops goku_ops = { ...@@ -1008,7 +1009,7 @@ static const struct usb_gadget_ops goku_ops = {
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static inline char *dmastr(void) static inline const char *dmastr(void)
{ {
if (use_dma == 0) if (use_dma == 0)
return "(dma disabled)"; return "(dma disabled)";
...@@ -1025,13 +1026,10 @@ static const char proc_node_name [] = "driver/udc"; ...@@ -1025,13 +1026,10 @@ static const char proc_node_name [] = "driver/udc";
#define FOURBITS "%s%s%s%s" #define FOURBITS "%s%s%s%s"
#define EIGHTBITS FOURBITS FOURBITS #define EIGHTBITS FOURBITS FOURBITS
static void static void dump_intmask(struct seq_file *m, const char *label, u32 mask)
dump_intmask(const char *label, u32 mask, char **next, unsigned *size)
{ {
int t;
/* int_status is the same format ... */ /* int_status is the same format ... */
t = scnprintf(*next, *size, seq_printf(m,
"%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n", "%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n",
label, mask, label, mask,
(mask & INT_PWRDETECT) ? " power" : "", (mask & INT_PWRDETECT) ? " power" : "",
...@@ -1058,33 +1056,23 @@ dump_intmask(const char *label, u32 mask, char **next, unsigned *size) ...@@ -1058,33 +1056,23 @@ dump_intmask(const char *label, u32 mask, char **next, unsigned *size)
(mask & INT_ENDPOINT0) ? " ep0" : "", (mask & INT_ENDPOINT0) ? " ep0" : "",
(mask & INT_USBRESET) ? " reset" : "", (mask & INT_USBRESET) ? " reset" : "",
(mask & INT_SUSPEND) ? " suspend" : ""); (mask & INT_SUSPEND) ? " suspend" : "");
*size -= t;
*next += t;
} }
static int static int udc_proc_read(struct seq_file *m, void *v)
udc_proc_read(char *buffer, char **start, off_t off, int count,
int *eof, void *_dev)
{ {
char *buf = buffer; struct goku_udc *dev = m->private;
struct goku_udc *dev = _dev;
struct goku_udc_regs __iomem *regs = dev->regs; struct goku_udc_regs __iomem *regs = dev->regs;
char *next = buf;
unsigned size = count;
unsigned long flags; unsigned long flags;
int i, t, is_usb_connected; int i, is_usb_connected;
u32 tmp; u32 tmp;
if (off != 0)
return 0;
local_irq_save(flags); local_irq_save(flags);
/* basic device status */ /* basic device status */
tmp = readl(&regs->power_detect); tmp = readl(&regs->power_detect);
is_usb_connected = tmp & PW_DETECT; is_usb_connected = tmp & PW_DETECT;
t = scnprintf(next, size, seq_printf(m,
"%s - %s\n" "%s - %s\n"
"%s version: %s %s\n" "%s version: %s %s\n"
"Gadget driver: %s\n" "Gadget driver: %s\n"
...@@ -1096,7 +1084,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, ...@@ -1096,7 +1084,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
is_usb_connected is_usb_connected
? ((tmp & PW_PULLUP) ? "full speed" : "powered") ? ((tmp & PW_PULLUP) ? "full speed" : "powered")
: "disconnected", : "disconnected",
({char *state; ({const char *state;
switch(dev->ep0state){ switch(dev->ep0state){
case EP0_DISCONNECT: state = "ep0_disconnect"; break; case EP0_DISCONNECT: state = "ep0_disconnect"; break;
case EP0_IDLE: state = "ep0_idle"; break; case EP0_IDLE: state = "ep0_idle"; break;
...@@ -1108,27 +1096,24 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, ...@@ -1108,27 +1096,24 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
default: state = "ep0_?"; break; default: state = "ep0_?"; break;
} state; }) } state; })
); );
size -= t;
next += t;
dump_intmask("int_status", readl(&regs->int_status), &next, &size); dump_intmask(m, "int_status", readl(&regs->int_status));
dump_intmask("int_enable", readl(&regs->int_enable), &next, &size); dump_intmask(m, "int_enable", readl(&regs->int_enable));
if (!is_usb_connected || !dev->driver || (tmp & PW_PULLUP) == 0) if (!is_usb_connected || !dev->driver || (tmp & PW_PULLUP) == 0)
goto done; goto done;
/* registers for (active) device and ep0 */ /* 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", "single.bcs %02x.%02x state %x addr %u\n",
dev->irqs, readl(&regs->DataSet), dev->irqs, readl(&regs->DataSet),
readl(&regs->EPxSingle), readl(&regs->EPxBCS), readl(&regs->EPxSingle), readl(&regs->EPxBCS),
readl(&regs->UsbState), readl(&regs->UsbState),
readl(&regs->address)); readl(&regs->address)) < 0)
size -= t; goto done;
next += t;
tmp = readl(&regs->dma_master); tmp = readl(&regs->dma_master);
t = scnprintf(next, size, if (seq_printf(m,
"dma %03X =" EIGHTBITS "%s %s\n", tmp, "dma %03X =" EIGHTBITS "%s %s\n", tmp,
(tmp & MST_EOPB_DIS) ? " eopb-" : "", (tmp & MST_EOPB_DIS) ? " eopb-" : "",
(tmp & MST_EOPB_ENA) ? " eopb+" : "", (tmp & MST_EOPB_ENA) ? " eopb+" : "",
...@@ -1143,9 +1128,8 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, ...@@ -1143,9 +1128,8 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
(tmp & MST_WR_ENA) ? " OUT" : "", (tmp & MST_WR_ENA) ? " OUT" : "",
(tmp & MST_CONNECTION) (tmp & MST_CONNECTION)
? "ep1in/ep2out" ? "ep1in/ep2out"
: "ep1out/ep2in"); : "ep1out/ep2in") < 0)
size -= t; goto done;
next += t;
/* dump endpoint queues */ /* dump endpoint queues */
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
...@@ -1156,7 +1140,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, ...@@ -1156,7 +1140,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
continue; continue;
tmp = readl(ep->reg_status); tmp = readl(ep->reg_status);
t = scnprintf(next, size, if (seq_printf(m,
"%s %s max %u %s, irqs %lu, " "%s %s max %u %s, irqs %lu, "
"status %02x (%s) " FOURBITS "\n", "status %02x (%s) " FOURBITS "\n",
ep->ep.name, ep->ep.name,
...@@ -1189,18 +1173,12 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, ...@@ -1189,18 +1173,12 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
(tmp & EPxSTATUS_SUSPEND) ? " suspend" : "", (tmp & EPxSTATUS_SUSPEND) ? " suspend" : "",
(tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "", (tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "",
(tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : "" (tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : ""
); ) < 0)
if (t <= 0 || t > size)
goto done; goto done;
size -= t;
next += t;
if (list_empty(&ep->queue)) { if (list_empty(&ep->queue)) {
t = scnprintf(next, size, "\t(nothing queued)\n"); if (seq_puts(m, "\t(nothing queued)\n") < 0)
if (t <= 0 || t > size)
goto done; goto done;
size -= t;
next += t;
continue; continue;
} }
list_for_each_entry(req, &ep->queue, queue) { list_for_each_entry(req, &ep->queue, queue) {
...@@ -1214,23 +1192,34 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, ...@@ -1214,23 +1192,34 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
} else } else
tmp = req->req.actual; tmp = req->req.actual;
t = scnprintf(next, size, if (seq_printf(m,
"\treq %p len %u/%u buf %p\n", "\treq %p len %u/%u buf %p\n",
&req->req, tmp, req->req.length, &req->req, tmp, req->req.length,
req->req.buf); req->req.buf) < 0)
if (t <= 0 || t > size)
goto done; goto done;
size -= t;
next += t;
} }
} }
done: done:
local_irq_restore(flags); local_irq_restore(flags);
*eof = 1; return 0;
return count - size; }
/*
* 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 */ #endif /* CONFIG_USB_GADGET_DEBUG_FILES */
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -1807,7 +1796,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1807,7 +1796,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
#ifdef CONFIG_USB_GADGET_DEBUG_FILES #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 #endif
retval = device_register(&dev->gadget.dev); retval = device_register(&dev->gadget.dev);
......
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