diff options
Diffstat (limited to 'drivers/usb/gadget/ci13xxx_udc.c')
-rw-r--r-- | drivers/usb/gadget/ci13xxx_udc.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c index 082471650fbc..1265a8502ea0 100644 --- a/drivers/usb/gadget/ci13xxx_udc.c +++ b/drivers/usb/gadget/ci13xxx_udc.c | |||
@@ -1214,12 +1214,13 @@ static DEVICE_ATTR(qheads, S_IRUSR, show_qheads, NULL); | |||
1214 | * | 1214 | * |
1215 | * Check "device.h" for details | 1215 | * Check "device.h" for details |
1216 | */ | 1216 | */ |
1217 | #define DUMP_ENTRIES 512 | ||
1217 | static ssize_t show_registers(struct device *dev, | 1218 | static ssize_t show_registers(struct device *dev, |
1218 | struct device_attribute *attr, char *buf) | 1219 | struct device_attribute *attr, char *buf) |
1219 | { | 1220 | { |
1220 | struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); | 1221 | struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); |
1221 | unsigned long flags; | 1222 | unsigned long flags; |
1222 | u32 dump[512]; | 1223 | u32 *dump; |
1223 | unsigned i, k, n = 0; | 1224 | unsigned i, k, n = 0; |
1224 | 1225 | ||
1225 | dbg_trace("[%s] %p\n", __func__, buf); | 1226 | dbg_trace("[%s] %p\n", __func__, buf); |
@@ -1228,8 +1229,14 @@ static ssize_t show_registers(struct device *dev, | |||
1228 | return 0; | 1229 | return 0; |
1229 | } | 1230 | } |
1230 | 1231 | ||
1232 | dump = kmalloc(sizeof(u32) * DUMP_ENTRIES, GFP_KERNEL); | ||
1233 | if (!dump) { | ||
1234 | dev_err(dev, "%s: out of memory\n", __func__); | ||
1235 | return 0; | ||
1236 | } | ||
1237 | |||
1231 | spin_lock_irqsave(udc->lock, flags); | 1238 | spin_lock_irqsave(udc->lock, flags); |
1232 | k = hw_register_read(dump, sizeof(dump)/sizeof(u32)); | 1239 | k = hw_register_read(dump, DUMP_ENTRIES); |
1233 | spin_unlock_irqrestore(udc->lock, flags); | 1240 | spin_unlock_irqrestore(udc->lock, flags); |
1234 | 1241 | ||
1235 | for (i = 0; i < k; i++) { | 1242 | for (i = 0; i < k; i++) { |
@@ -1237,6 +1244,7 @@ static ssize_t show_registers(struct device *dev, | |||
1237 | "reg[0x%04X] = 0x%08X\n", | 1244 | "reg[0x%04X] = 0x%08X\n", |
1238 | i * (unsigned)sizeof(u32), dump[i]); | 1245 | i * (unsigned)sizeof(u32), dump[i]); |
1239 | } | 1246 | } |
1247 | kfree(dump); | ||
1240 | 1248 | ||
1241 | return n; | 1249 | return n; |
1242 | } | 1250 | } |