Linux 3.9-rc4
[linux-2.6/cjktty.git] / drivers / usb / chipidea / debug.c
bloba62c4a47d52c6685787ff01e174f67040241502f
1 #include <linux/delay.h>
2 #include <linux/device.h>
3 #include <linux/dmapool.h>
4 #include <linux/dma-mapping.h>
5 #include <linux/init.h>
6 #include <linux/platform_device.h>
7 #include <linux/module.h>
8 #include <linux/interrupt.h>
9 #include <linux/io.h>
10 #include <linux/irq.h>
11 #include <linux/kernel.h>
12 #include <linux/slab.h>
13 #include <linux/pm_runtime.h>
14 #include <linux/usb/ch9.h>
15 #include <linux/usb/gadget.h>
16 #include <linux/usb/otg.h>
17 #include <linux/usb/chipidea.h>
19 #include "ci.h"
20 #include "udc.h"
21 #include "bits.h"
22 #include "debug.h"
24 /* Interrupt statistics */
25 #define ISR_MASK 0x1F
26 static struct isr_statistics {
27 u32 test;
28 u32 ui;
29 u32 uei;
30 u32 pci;
31 u32 uri;
32 u32 sli;
33 u32 none;
34 struct {
35 u32 cnt;
36 u32 buf[ISR_MASK+1];
37 u32 idx;
38 } hndl;
39 } isr_statistics;
41 void dbg_interrupt(u32 intmask)
43 if (!intmask) {
44 isr_statistics.none++;
45 return;
48 isr_statistics.hndl.buf[isr_statistics.hndl.idx++] = intmask;
49 isr_statistics.hndl.idx &= ISR_MASK;
50 isr_statistics.hndl.cnt++;
52 if (USBi_URI & intmask)
53 isr_statistics.uri++;
54 if (USBi_PCI & intmask)
55 isr_statistics.pci++;
56 if (USBi_UEI & intmask)
57 isr_statistics.uei++;
58 if (USBi_UI & intmask)
59 isr_statistics.ui++;
60 if (USBi_SLI & intmask)
61 isr_statistics.sli++;
64 /**
65 * hw_register_read: reads all device registers (execute without interruption)
66 * @buf: destination buffer
67 * @size: buffer size
69 * This function returns number of registers read
71 static size_t hw_register_read(struct ci13xxx *ci, u32 *buf, size_t size)
73 unsigned i;
75 if (size > ci->hw_bank.size)
76 size = ci->hw_bank.size;
78 for (i = 0; i < size; i++)
79 buf[i] = hw_read(ci, i * sizeof(u32), ~0);
81 return size;
84 /**
85 * hw_register_write: writes to register
86 * @addr: register address
87 * @data: register value
89 * This function returns an error code
91 static int hw_register_write(struct ci13xxx *ci, u16 addr, u32 data)
93 /* align */
94 addr /= sizeof(u32);
96 if (addr >= ci->hw_bank.size)
97 return -EINVAL;
99 /* align */
100 addr *= sizeof(u32);
102 hw_write(ci, addr, ~0, data);
103 return 0;
107 * hw_intr_clear: disables interrupt & clears interrupt status (execute without
108 * interruption)
109 * @n: interrupt bit
111 * This function returns an error code
113 static int hw_intr_clear(struct ci13xxx *ci, int n)
115 if (n >= REG_BITS)
116 return -EINVAL;
118 hw_write(ci, OP_USBINTR, BIT(n), 0);
119 hw_write(ci, OP_USBSTS, BIT(n), BIT(n));
120 return 0;
124 * hw_intr_force: enables interrupt & forces interrupt status (execute without
125 * interruption)
126 * @n: interrupt bit
128 * This function returns an error code
130 static int hw_intr_force(struct ci13xxx *ci, int n)
132 if (n >= REG_BITS)
133 return -EINVAL;
135 hw_write(ci, CAP_TESTMODE, TESTMODE_FORCE, TESTMODE_FORCE);
136 hw_write(ci, OP_USBINTR, BIT(n), BIT(n));
137 hw_write(ci, OP_USBSTS, BIT(n), BIT(n));
138 hw_write(ci, CAP_TESTMODE, TESTMODE_FORCE, 0);
139 return 0;
143 * show_device: prints information about device capabilities and status
145 * Check "device.h" for details
147 static ssize_t show_device(struct device *dev, struct device_attribute *attr,
148 char *buf)
150 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
151 struct usb_gadget *gadget = &ci->gadget;
152 int n = 0;
154 if (attr == NULL || buf == NULL) {
155 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
156 return 0;
159 n += scnprintf(buf + n, PAGE_SIZE - n, "speed = %d\n",
160 gadget->speed);
161 n += scnprintf(buf + n, PAGE_SIZE - n, "max_speed = %d\n",
162 gadget->max_speed);
163 n += scnprintf(buf + n, PAGE_SIZE - n, "is_otg = %d\n",
164 gadget->is_otg);
165 n += scnprintf(buf + n, PAGE_SIZE - n, "is_a_peripheral = %d\n",
166 gadget->is_a_peripheral);
167 n += scnprintf(buf + n, PAGE_SIZE - n, "b_hnp_enable = %d\n",
168 gadget->b_hnp_enable);
169 n += scnprintf(buf + n, PAGE_SIZE - n, "a_hnp_support = %d\n",
170 gadget->a_hnp_support);
171 n += scnprintf(buf + n, PAGE_SIZE - n, "a_alt_hnp_support = %d\n",
172 gadget->a_alt_hnp_support);
173 n += scnprintf(buf + n, PAGE_SIZE - n, "name = %s\n",
174 (gadget->name ? gadget->name : ""));
176 return n;
178 static DEVICE_ATTR(device, S_IRUSR, show_device, NULL);
181 * show_driver: prints information about attached gadget (if any)
183 * Check "device.h" for details
185 static ssize_t show_driver(struct device *dev, struct device_attribute *attr,
186 char *buf)
188 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
189 struct usb_gadget_driver *driver = ci->driver;
190 int n = 0;
192 if (attr == NULL || buf == NULL) {
193 dev_err(dev, "[%s] EINVAL\n", __func__);
194 return 0;
197 if (driver == NULL)
198 return scnprintf(buf, PAGE_SIZE,
199 "There is no gadget attached!\n");
201 n += scnprintf(buf + n, PAGE_SIZE - n, "function = %s\n",
202 (driver->function ? driver->function : ""));
203 n += scnprintf(buf + n, PAGE_SIZE - n, "max speed = %d\n",
204 driver->max_speed);
206 return n;
208 static DEVICE_ATTR(driver, S_IRUSR, show_driver, NULL);
210 /* Maximum event message length */
211 #define DBG_DATA_MSG 64UL
213 /* Maximum event messages */
214 #define DBG_DATA_MAX 128UL
216 /* Event buffer descriptor */
217 static struct {
218 char (buf[DBG_DATA_MAX])[DBG_DATA_MSG]; /* buffer */
219 unsigned idx; /* index */
220 unsigned tty; /* print to console? */
221 rwlock_t lck; /* lock */
222 } dbg_data = {
223 .idx = 0,
224 .tty = 0,
225 .lck = __RW_LOCK_UNLOCKED(dbg_data.lck)
229 * dbg_dec: decrements debug event index
230 * @idx: buffer index
232 static void dbg_dec(unsigned *idx)
234 *idx = (*idx - 1) & (DBG_DATA_MAX-1);
238 * dbg_inc: increments debug event index
239 * @idx: buffer index
241 static void dbg_inc(unsigned *idx)
243 *idx = (*idx + 1) & (DBG_DATA_MAX-1);
247 * dbg_print: prints the common part of the event
248 * @addr: endpoint address
249 * @name: event name
250 * @status: status
251 * @extra: extra information
253 static void dbg_print(u8 addr, const char *name, int status, const char *extra)
255 struct timeval tval;
256 unsigned int stamp;
257 unsigned long flags;
259 write_lock_irqsave(&dbg_data.lck, flags);
261 do_gettimeofday(&tval);
262 stamp = tval.tv_sec & 0xFFFF; /* 2^32 = 4294967296. Limit to 4096s */
263 stamp = stamp * 1000000 + tval.tv_usec;
265 scnprintf(dbg_data.buf[dbg_data.idx], DBG_DATA_MSG,
266 "%04X\t? %02X %-7.7s %4i ?\t%s\n",
267 stamp, addr, name, status, extra);
269 dbg_inc(&dbg_data.idx);
271 write_unlock_irqrestore(&dbg_data.lck, flags);
273 if (dbg_data.tty != 0)
274 pr_notice("%04X\t? %02X %-7.7s %4i ?\t%s\n",
275 stamp, addr, name, status, extra);
279 * dbg_done: prints a DONE event
280 * @addr: endpoint address
281 * @td: transfer descriptor
282 * @status: status
284 void dbg_done(u8 addr, const u32 token, int status)
286 char msg[DBG_DATA_MSG];
288 scnprintf(msg, sizeof(msg), "%d %02X",
289 (int)(token & TD_TOTAL_BYTES) >> ffs_nr(TD_TOTAL_BYTES),
290 (int)(token & TD_STATUS) >> ffs_nr(TD_STATUS));
291 dbg_print(addr, "DONE", status, msg);
295 * dbg_event: prints a generic event
296 * @addr: endpoint address
297 * @name: event name
298 * @status: status
300 void dbg_event(u8 addr, const char *name, int status)
302 if (name != NULL)
303 dbg_print(addr, name, status, "");
307 * dbg_queue: prints a QUEUE event
308 * @addr: endpoint address
309 * @req: USB request
310 * @status: status
312 void dbg_queue(u8 addr, const struct usb_request *req, int status)
314 char msg[DBG_DATA_MSG];
316 if (req != NULL) {
317 scnprintf(msg, sizeof(msg),
318 "%d %d", !req->no_interrupt, req->length);
319 dbg_print(addr, "QUEUE", status, msg);
324 * dbg_setup: prints a SETUP event
325 * @addr: endpoint address
326 * @req: setup request
328 void dbg_setup(u8 addr, const struct usb_ctrlrequest *req)
330 char msg[DBG_DATA_MSG];
332 if (req != NULL) {
333 scnprintf(msg, sizeof(msg),
334 "%02X %02X %04X %04X %d", req->bRequestType,
335 req->bRequest, le16_to_cpu(req->wValue),
336 le16_to_cpu(req->wIndex), le16_to_cpu(req->wLength));
337 dbg_print(addr, "SETUP", 0, msg);
342 * show_events: displays the event buffer
344 * Check "device.h" for details
346 static ssize_t show_events(struct device *dev, struct device_attribute *attr,
347 char *buf)
349 unsigned long flags;
350 unsigned i, j, n = 0;
352 if (attr == NULL || buf == NULL) {
353 dev_err(dev->parent, "[%s] EINVAL\n", __func__);
354 return 0;
357 read_lock_irqsave(&dbg_data.lck, flags);
359 i = dbg_data.idx;
360 for (dbg_dec(&i); i != dbg_data.idx; dbg_dec(&i)) {
361 n += strlen(dbg_data.buf[i]);
362 if (n >= PAGE_SIZE) {
363 n -= strlen(dbg_data.buf[i]);
364 break;
367 for (j = 0, dbg_inc(&i); j < n; dbg_inc(&i))
368 j += scnprintf(buf + j, PAGE_SIZE - j,
369 "%s", dbg_data.buf[i]);
371 read_unlock_irqrestore(&dbg_data.lck, flags);
373 return n;
377 * store_events: configure if events are going to be also printed to console
379 * Check "device.h" for details
381 static ssize_t store_events(struct device *dev, struct device_attribute *attr,
382 const char *buf, size_t count)
384 unsigned tty;
386 if (attr == NULL || buf == NULL) {
387 dev_err(dev, "[%s] EINVAL\n", __func__);
388 goto done;
391 if (sscanf(buf, "%u", &tty) != 1 || tty > 1) {
392 dev_err(dev, "<1|0>: enable|disable console log\n");
393 goto done;
396 dbg_data.tty = tty;
397 dev_info(dev, "tty = %u", dbg_data.tty);
399 done:
400 return count;
402 static DEVICE_ATTR(events, S_IRUSR | S_IWUSR, show_events, store_events);
405 * show_inters: interrupt status, enable status and historic
407 * Check "device.h" for details
409 static ssize_t show_inters(struct device *dev, struct device_attribute *attr,
410 char *buf)
412 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
413 unsigned long flags;
414 u32 intr;
415 unsigned i, j, n = 0;
417 if (attr == NULL || buf == NULL) {
418 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
419 return 0;
422 spin_lock_irqsave(&ci->lock, flags);
424 /*n += scnprintf(buf + n, PAGE_SIZE - n,
425 "status = %08x\n", hw_read_intr_status(ci));
426 n += scnprintf(buf + n, PAGE_SIZE - n,
427 "enable = %08x\n", hw_read_intr_enable(ci));*/
429 n += scnprintf(buf + n, PAGE_SIZE - n, "*test = %d\n",
430 isr_statistics.test);
431 n += scnprintf(buf + n, PAGE_SIZE - n, "? ui = %d\n",
432 isr_statistics.ui);
433 n += scnprintf(buf + n, PAGE_SIZE - n, "? uei = %d\n",
434 isr_statistics.uei);
435 n += scnprintf(buf + n, PAGE_SIZE - n, "? pci = %d\n",
436 isr_statistics.pci);
437 n += scnprintf(buf + n, PAGE_SIZE - n, "? uri = %d\n",
438 isr_statistics.uri);
439 n += scnprintf(buf + n, PAGE_SIZE - n, "? sli = %d\n",
440 isr_statistics.sli);
441 n += scnprintf(buf + n, PAGE_SIZE - n, "*none = %d\n",
442 isr_statistics.none);
443 n += scnprintf(buf + n, PAGE_SIZE - n, "*hndl = %d\n",
444 isr_statistics.hndl.cnt);
446 for (i = isr_statistics.hndl.idx, j = 0; j <= ISR_MASK; j++, i++) {
447 i &= ISR_MASK;
448 intr = isr_statistics.hndl.buf[i];
450 if (USBi_UI & intr)
451 n += scnprintf(buf + n, PAGE_SIZE - n, "ui ");
452 intr &= ~USBi_UI;
453 if (USBi_UEI & intr)
454 n += scnprintf(buf + n, PAGE_SIZE - n, "uei ");
455 intr &= ~USBi_UEI;
456 if (USBi_PCI & intr)
457 n += scnprintf(buf + n, PAGE_SIZE - n, "pci ");
458 intr &= ~USBi_PCI;
459 if (USBi_URI & intr)
460 n += scnprintf(buf + n, PAGE_SIZE - n, "uri ");
461 intr &= ~USBi_URI;
462 if (USBi_SLI & intr)
463 n += scnprintf(buf + n, PAGE_SIZE - n, "sli ");
464 intr &= ~USBi_SLI;
465 if (intr)
466 n += scnprintf(buf + n, PAGE_SIZE - n, "??? ");
467 if (isr_statistics.hndl.buf[i])
468 n += scnprintf(buf + n, PAGE_SIZE - n, "\n");
471 spin_unlock_irqrestore(&ci->lock, flags);
473 return n;
477 * store_inters: enable & force or disable an individual interrutps
478 * (to be used for test purposes only)
480 * Check "device.h" for details
482 static ssize_t store_inters(struct device *dev, struct device_attribute *attr,
483 const char *buf, size_t count)
485 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
486 unsigned long flags;
487 unsigned en, bit;
489 if (attr == NULL || buf == NULL) {
490 dev_err(ci->dev, "EINVAL\n");
491 goto done;
494 if (sscanf(buf, "%u %u", &en, &bit) != 2 || en > 1) {
495 dev_err(ci->dev, "<1|0> <bit>: enable|disable interrupt\n");
496 goto done;
499 spin_lock_irqsave(&ci->lock, flags);
500 if (en) {
501 if (hw_intr_force(ci, bit))
502 dev_err(dev, "invalid bit number\n");
503 else
504 isr_statistics.test++;
505 } else {
506 if (hw_intr_clear(ci, bit))
507 dev_err(dev, "invalid bit number\n");
509 spin_unlock_irqrestore(&ci->lock, flags);
511 done:
512 return count;
514 static DEVICE_ATTR(inters, S_IRUSR | S_IWUSR, show_inters, store_inters);
517 * show_port_test: reads port test mode
519 * Check "device.h" for details
521 static ssize_t show_port_test(struct device *dev,
522 struct device_attribute *attr, char *buf)
524 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
525 unsigned long flags;
526 unsigned mode;
528 if (attr == NULL || buf == NULL) {
529 dev_err(ci->dev, "EINVAL\n");
530 return 0;
533 spin_lock_irqsave(&ci->lock, flags);
534 mode = hw_port_test_get(ci);
535 spin_unlock_irqrestore(&ci->lock, flags);
537 return scnprintf(buf, PAGE_SIZE, "mode = %u\n", mode);
541 * store_port_test: writes port test mode
543 * Check "device.h" for details
545 static ssize_t store_port_test(struct device *dev,
546 struct device_attribute *attr,
547 const char *buf, size_t count)
549 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
550 unsigned long flags;
551 unsigned mode;
553 if (attr == NULL || buf == NULL) {
554 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
555 goto done;
558 if (sscanf(buf, "%u", &mode) != 1) {
559 dev_err(ci->dev, "<mode>: set port test mode");
560 goto done;
563 spin_lock_irqsave(&ci->lock, flags);
564 if (hw_port_test_set(ci, mode))
565 dev_err(ci->dev, "invalid mode\n");
566 spin_unlock_irqrestore(&ci->lock, flags);
568 done:
569 return count;
571 static DEVICE_ATTR(port_test, S_IRUSR | S_IWUSR,
572 show_port_test, store_port_test);
575 * show_qheads: DMA contents of all queue heads
577 * Check "device.h" for details
579 static ssize_t show_qheads(struct device *dev, struct device_attribute *attr,
580 char *buf)
582 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
583 unsigned long flags;
584 unsigned i, j, n = 0;
586 if (attr == NULL || buf == NULL) {
587 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
588 return 0;
591 spin_lock_irqsave(&ci->lock, flags);
592 for (i = 0; i < ci->hw_ep_max/2; i++) {
593 struct ci13xxx_ep *mEpRx = &ci->ci13xxx_ep[i];
594 struct ci13xxx_ep *mEpTx =
595 &ci->ci13xxx_ep[i + ci->hw_ep_max/2];
596 n += scnprintf(buf + n, PAGE_SIZE - n,
597 "EP=%02i: RX=%08X TX=%08X\n",
598 i, (u32)mEpRx->qh.dma, (u32)mEpTx->qh.dma);
599 for (j = 0; j < (sizeof(struct ci13xxx_qh)/sizeof(u32)); j++) {
600 n += scnprintf(buf + n, PAGE_SIZE - n,
601 " %04X: %08X %08X\n", j,
602 *((u32 *)mEpRx->qh.ptr + j),
603 *((u32 *)mEpTx->qh.ptr + j));
606 spin_unlock_irqrestore(&ci->lock, flags);
608 return n;
610 static DEVICE_ATTR(qheads, S_IRUSR, show_qheads, NULL);
613 * show_registers: dumps all registers
615 * Check "device.h" for details
617 #define DUMP_ENTRIES 512
618 static ssize_t show_registers(struct device *dev,
619 struct device_attribute *attr, char *buf)
621 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
622 unsigned long flags;
623 u32 *dump;
624 unsigned i, k, n = 0;
626 if (attr == NULL || buf == NULL) {
627 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
628 return 0;
631 dump = kmalloc(sizeof(u32) * DUMP_ENTRIES, GFP_KERNEL);
632 if (!dump) {
633 dev_err(ci->dev, "%s: out of memory\n", __func__);
634 return 0;
637 spin_lock_irqsave(&ci->lock, flags);
638 k = hw_register_read(ci, dump, DUMP_ENTRIES);
639 spin_unlock_irqrestore(&ci->lock, flags);
641 for (i = 0; i < k; i++) {
642 n += scnprintf(buf + n, PAGE_SIZE - n,
643 "reg[0x%04X] = 0x%08X\n",
644 i * (unsigned)sizeof(u32), dump[i]);
646 kfree(dump);
648 return n;
652 * store_registers: writes value to register address
654 * Check "device.h" for details
656 static ssize_t store_registers(struct device *dev,
657 struct device_attribute *attr,
658 const char *buf, size_t count)
660 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
661 unsigned long addr, data, flags;
663 if (attr == NULL || buf == NULL) {
664 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
665 goto done;
668 if (sscanf(buf, "%li %li", &addr, &data) != 2) {
669 dev_err(ci->dev,
670 "<addr> <data>: write data to register address\n");
671 goto done;
674 spin_lock_irqsave(&ci->lock, flags);
675 if (hw_register_write(ci, addr, data))
676 dev_err(ci->dev, "invalid address range\n");
677 spin_unlock_irqrestore(&ci->lock, flags);
679 done:
680 return count;
682 static DEVICE_ATTR(registers, S_IRUSR | S_IWUSR,
683 show_registers, store_registers);
686 * show_requests: DMA contents of all requests currently queued (all endpts)
688 * Check "device.h" for details
690 static ssize_t show_requests(struct device *dev, struct device_attribute *attr,
691 char *buf)
693 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
694 unsigned long flags;
695 struct list_head *ptr = NULL;
696 struct ci13xxx_req *req = NULL;
697 unsigned i, j, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32);
699 if (attr == NULL || buf == NULL) {
700 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
701 return 0;
704 spin_lock_irqsave(&ci->lock, flags);
705 for (i = 0; i < ci->hw_ep_max; i++)
706 list_for_each(ptr, &ci->ci13xxx_ep[i].qh.queue)
708 req = list_entry(ptr, struct ci13xxx_req, queue);
710 n += scnprintf(buf + n, PAGE_SIZE - n,
711 "EP=%02i: TD=%08X %s\n",
712 i % ci->hw_ep_max/2, (u32)req->dma,
713 ((i < ci->hw_ep_max/2) ? "RX" : "TX"));
715 for (j = 0; j < qSize; j++)
716 n += scnprintf(buf + n, PAGE_SIZE - n,
717 " %04X: %08X\n", j,
718 *((u32 *)req->ptr + j));
720 spin_unlock_irqrestore(&ci->lock, flags);
722 return n;
724 static DEVICE_ATTR(requests, S_IRUSR, show_requests, NULL);
727 * dbg_create_files: initializes the attribute interface
728 * @dev: device
730 * This function returns an error code
732 int dbg_create_files(struct device *dev)
734 int retval = 0;
736 if (dev == NULL)
737 return -EINVAL;
738 retval = device_create_file(dev, &dev_attr_device);
739 if (retval)
740 goto done;
741 retval = device_create_file(dev, &dev_attr_driver);
742 if (retval)
743 goto rm_device;
744 retval = device_create_file(dev, &dev_attr_events);
745 if (retval)
746 goto rm_driver;
747 retval = device_create_file(dev, &dev_attr_inters);
748 if (retval)
749 goto rm_events;
750 retval = device_create_file(dev, &dev_attr_port_test);
751 if (retval)
752 goto rm_inters;
753 retval = device_create_file(dev, &dev_attr_qheads);
754 if (retval)
755 goto rm_port_test;
756 retval = device_create_file(dev, &dev_attr_registers);
757 if (retval)
758 goto rm_qheads;
759 retval = device_create_file(dev, &dev_attr_requests);
760 if (retval)
761 goto rm_registers;
762 return 0;
764 rm_registers:
765 device_remove_file(dev, &dev_attr_registers);
766 rm_qheads:
767 device_remove_file(dev, &dev_attr_qheads);
768 rm_port_test:
769 device_remove_file(dev, &dev_attr_port_test);
770 rm_inters:
771 device_remove_file(dev, &dev_attr_inters);
772 rm_events:
773 device_remove_file(dev, &dev_attr_events);
774 rm_driver:
775 device_remove_file(dev, &dev_attr_driver);
776 rm_device:
777 device_remove_file(dev, &dev_attr_device);
778 done:
779 return retval;
783 * dbg_remove_files: destroys the attribute interface
784 * @dev: device
786 * This function returns an error code
788 int dbg_remove_files(struct device *dev)
790 if (dev == NULL)
791 return -EINVAL;
792 device_remove_file(dev, &dev_attr_requests);
793 device_remove_file(dev, &dev_attr_registers);
794 device_remove_file(dev, &dev_attr_qheads);
795 device_remove_file(dev, &dev_attr_port_test);
796 device_remove_file(dev, &dev_attr_inters);
797 device_remove_file(dev, &dev_attr_events);
798 device_remove_file(dev, &dev_attr_driver);
799 device_remove_file(dev, &dev_attr_device);
800 return 0;