aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-04-10 06:51:21 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-04-29 15:41:53 -0400
commit96c7a22ebd2c919ed8fb93bb7c02b60aac099768 (patch)
tree7b8ff0a16bf384dc7be416e6e6cf7482fc397afc
parentf1cc0444ab2f0e1b254490f497363e3b0c9bcd56 (diff)
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: David 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: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/usb/gadget/goku_udc.c89
1 files changed, 39 insertions, 50 deletions
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index 85742d4c67df..57a547049df5 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -35,6 +35,7 @@
35#include <linux/list.h> 35#include <linux/list.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/proc_fs.h> 37#include <linux/proc_fs.h>
38#include <linux/seq_file.h>
38#include <linux/device.h> 39#include <linux/device.h>
39#include <linux/usb/ch9.h> 40#include <linux/usb/ch9.h>
40#include <linux/usb/gadget.h> 41#include <linux/usb/gadget.h>
@@ -1008,7 +1009,7 @@ static const struct usb_gadget_ops goku_ops = {
1008 1009
1009/*-------------------------------------------------------------------------*/ 1010/*-------------------------------------------------------------------------*/
1010 1011
1011static inline char *dmastr(void) 1012static inline const char *dmastr(void)
1012{ 1013{
1013 if (use_dma == 0) 1014 if (use_dma == 0)
1014 return "(dma disabled)"; 1015 return "(dma disabled)";
@@ -1025,13 +1026,10 @@ static const char proc_node_name [] = "driver/udc";
1025#define FOURBITS "%s%s%s%s" 1026#define FOURBITS "%s%s%s%s"
1026#define EIGHTBITS FOURBITS FOURBITS 1027#define EIGHTBITS FOURBITS FOURBITS
1027 1028
1028static void 1029static void dump_intmask(struct seq_file *m, const char *label, u32 mask)
1029dump_intmask(const char *label, u32 mask, char **next, unsigned *size)
1030{ 1030{
1031 int t;
1032
1033 /* int_status is the same format ... */ 1031 /* int_status is the same format ... */
1034 t = scnprintf(*next, *size, 1032 seq_printf(m,
1035 "%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n", 1033 "%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n",
1036 label, mask, 1034 label, mask,
1037 (mask & INT_PWRDETECT) ? " power" : "", 1035 (mask & INT_PWRDETECT) ? " power" : "",
@@ -1058,33 +1056,23 @@ dump_intmask(const char *label, u32 mask, char **next, unsigned *size)
1058 (mask & INT_ENDPOINT0) ? " ep0" : "", 1056 (mask & INT_ENDPOINT0) ? " ep0" : "",
1059 (mask & INT_USBRESET) ? " reset" : "", 1057 (mask & INT_USBRESET) ? " reset" : "",
1060 (mask & INT_SUSPEND) ? " suspend" : ""); 1058 (mask & INT_SUSPEND) ? " suspend" : "");
1061 *size -= t;
1062 *next += t;
1063} 1059}
1064 1060
1065 1061
1066static int 1062static int udc_proc_read(struct seq_file *m, void *v)
1067udc_proc_read(char *buffer, char **start, off_t off, int count,
1068 int *eof, void *_dev)
1069{ 1063{
1070 char *buf = buffer; 1064 struct goku_udc *dev = m->private;
1071 struct goku_udc *dev = _dev;
1072 struct goku_udc_regs __iomem *regs = dev->regs; 1065 struct goku_udc_regs __iomem *regs = dev->regs;
1073 char *next = buf;
1074 unsigned size = count;
1075 unsigned long flags; 1066 unsigned long flags;
1076 int i, t, is_usb_connected; 1067 int i, is_usb_connected;
1077 u32 tmp; 1068 u32 tmp;
1078 1069
1079 if (off != 0)
1080 return 0;
1081
1082 local_irq_save(flags); 1070 local_irq_save(flags);
1083 1071
1084 /* basic device status */ 1072 /* basic device status */
1085 tmp = readl(&regs->power_detect); 1073 tmp = readl(&regs->power_detect);
1086 is_usb_connected = tmp & PW_DETECT; 1074 is_usb_connected = tmp & PW_DETECT;
1087 t = scnprintf(next, size, 1075 seq_printf(m,
1088 "%s - %s\n" 1076 "%s - %s\n"
1089 "%s version: %s %s\n" 1077 "%s version: %s %s\n"
1090 "Gadget driver: %s\n" 1078 "Gadget driver: %s\n"
@@ -1096,7 +1084,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
1096 is_usb_connected 1084 is_usb_connected
1097 ? ((tmp & PW_PULLUP) ? "full speed" : "powered") 1085 ? ((tmp & PW_PULLUP) ? "full speed" : "powered")
1098 : "disconnected", 1086 : "disconnected",
1099 ({char *state; 1087 ({const char *state;
1100 switch(dev->ep0state){ 1088 switch(dev->ep0state){
1101 case EP0_DISCONNECT: state = "ep0_disconnect"; break; 1089 case EP0_DISCONNECT: state = "ep0_disconnect"; break;
1102 case EP0_IDLE: state = "ep0_idle"; break; 1090 case EP0_IDLE: state = "ep0_idle"; break;
@@ -1108,27 +1096,24 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
1108 default: state = "ep0_?"; break; 1096 default: state = "ep0_?"; break;
1109 } state; }) 1097 } state; })
1110 ); 1098 );
1111 size -= t;
1112 next += t;
1113 1099
1114 dump_intmask("int_status", readl(&regs->int_status), &next, &size); 1100 dump_intmask(m, "int_status", readl(&regs->int_status));
1115 dump_intmask("int_enable", readl(&regs->int_enable), &next, &size); 1101 dump_intmask(m, "int_enable", readl(&regs->int_enable));
1116 1102
1117 if (!is_usb_connected || !dev->driver || (tmp & PW_PULLUP) == 0) 1103 if (!is_usb_connected || !dev->driver || (tmp & PW_PULLUP) == 0)
1118 goto done; 1104 goto done;
1119 1105
1120 /* registers for (active) device and ep0 */ 1106 /* registers for (active) device and ep0 */
1121 t = scnprintf(next, size, "\nirqs %lu\ndataset %02x " 1107 if (seq_printf(m, "\nirqs %lu\ndataset %02x "
1122 "single.bcs %02x.%02x state %x addr %u\n", 1108 "single.bcs %02x.%02x state %x addr %u\n",
1123 dev->irqs, readl(&regs->DataSet), 1109 dev->irqs, readl(&regs->DataSet),
1124 readl(&regs->EPxSingle), readl(&regs->EPxBCS), 1110 readl(&regs->EPxSingle), readl(&regs->EPxBCS),
1125 readl(&regs->UsbState), 1111 readl(&regs->UsbState),
1126 readl(&regs->address)); 1112 readl(&regs->address)) < 0)
1127 size -= t; 1113 goto done;
1128 next += t;
1129 1114
1130 tmp = readl(&regs->dma_master); 1115 tmp = readl(&regs->dma_master);
1131 t = scnprintf(next, size, 1116 if (seq_printf(m,
1132 "dma %03X =" EIGHTBITS "%s %s\n", tmp, 1117 "dma %03X =" EIGHTBITS "%s %s\n", tmp,
1133 (tmp & MST_EOPB_DIS) ? " eopb-" : "", 1118 (tmp & MST_EOPB_DIS) ? " eopb-" : "",
1134 (tmp & MST_EOPB_ENA) ? " eopb+" : "", 1119 (tmp & MST_EOPB_ENA) ? " eopb+" : "",
@@ -1143,9 +1128,8 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
1143 (tmp & MST_WR_ENA) ? " OUT" : "", 1128 (tmp & MST_WR_ENA) ? " OUT" : "",
1144 (tmp & MST_CONNECTION) 1129 (tmp & MST_CONNECTION)
1145 ? "ep1in/ep2out" 1130 ? "ep1in/ep2out"
1146 : "ep1out/ep2in"); 1131 : "ep1out/ep2in") < 0)
1147 size -= t; 1132 goto done;
1148 next += t;
1149 1133
1150 /* dump endpoint queues */ 1134 /* dump endpoint queues */
1151 for (i = 0; i < 4; i++) { 1135 for (i = 0; i < 4; i++) {
@@ -1156,7 +1140,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
1156 continue; 1140 continue;
1157 1141
1158 tmp = readl(ep->reg_status); 1142 tmp = readl(ep->reg_status);
1159 t = scnprintf(next, size, 1143 if (seq_printf(m,
1160 "%s %s max %u %s, irqs %lu, " 1144 "%s %s max %u %s, irqs %lu, "
1161 "status %02x (%s) " FOURBITS "\n", 1145 "status %02x (%s) " FOURBITS "\n",
1162 ep->ep.name, 1146 ep->ep.name,
@@ -1189,18 +1173,12 @@ udc_proc_read(char *buffer, char **start, off_t off, int count,
1189 (tmp & EPxSTATUS_SUSPEND) ? " suspend" : "", 1173 (tmp & EPxSTATUS_SUSPEND) ? " suspend" : "",
1190 (tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "", 1174 (tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "",
1191 (tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : "" 1175 (tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : ""
1192 ); 1176 ) < 0)
1193 if (t <= 0 || t > size)
1194 goto done; 1177 goto done;
1195 size -= t;
1196 next += t;
1197 1178
1198 if (list_empty(&ep->queue)) { 1179 if (list_empty(&ep->queue)) {
1199 t = scnprintf(next, size, "\t(nothing queued)\n"); 1180 if (seq_puts(m, "\t(nothing queued)\n") < 0)
1200 if (t <= 0 || t > size)
1201 goto done; 1181 goto done;
1202 size -= t;
1203 next += t;
1204 continue; 1182 continue;
1205 } 1183 }
1206 list_for_each_entry(req, &ep->queue, queue) { 1184 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 } else 1192 } else
1215 tmp = req->req.actual; 1193 tmp = req->req.actual;
1216 1194
1217 t = scnprintf(next, size, 1195 if (seq_printf(m,
1218 "\treq %p len %u/%u buf %p\n", 1196 "\treq %p len %u/%u buf %p\n",
1219 &req->req, tmp, req->req.length, 1197 &req->req, tmp, req->req.length,
1220 req->req.buf); 1198 req->req.buf) < 0)
1221 if (t <= 0 || t > size)
1222 goto done; 1199 goto done;
1223 size -= t;
1224 next += t;
1225 } 1200 }
1226 } 1201 }
1227 1202
1228done: 1203done:
1229 local_irq_restore(flags); 1204 local_irq_restore(flags);
1230 *eof = 1; 1205 return 0;
1231 return count - size; 1206}
1207
1208/*
1209 * seq_file wrappers for procfile show routines.
1210 */
1211static int udc_proc_open(struct inode *inode, struct file *file)
1212{
1213 return single_open(file, udc_proc_read, PDE_DATA(file_inode(file)));
1232} 1214}
1233 1215
1216static const struct file_operations udc_proc_fops = {
1217 .open = udc_proc_open,
1218 .read = seq_read,
1219 .llseek = seq_lseek,
1220 .release = seq_release,
1221};
1222
1234#endif /* CONFIG_USB_GADGET_DEBUG_FILES */ 1223#endif /* CONFIG_USB_GADGET_DEBUG_FILES */
1235 1224
1236/*-------------------------------------------------------------------------*/ 1225/*-------------------------------------------------------------------------*/
@@ -1807,7 +1796,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1807 1796
1808 1797
1809#ifdef CONFIG_USB_GADGET_DEBUG_FILES 1798#ifdef CONFIG_USB_GADGET_DEBUG_FILES
1810 create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev); 1799 proc_create_data(proc_node_name, 0, NULL, &udc_proc_fops, dev);
1811#endif 1800#endif
1812 1801
1813 retval = device_register(&dev->gadget.dev); 1802 retval = device_register(&dev->gadget.dev);