2 * OHCI HCD (Host Controller Driver) for USB.
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
7 * This file is licenced under the GPL.
10 /*-------------------------------------------------------------------------*/
14 #define edstring(ed_type) ({ char *temp; \
16 case PIPE_CONTROL: temp = "ctrl"; break; \
17 case PIPE_BULK: temp = "bulk"; break; \
18 case PIPE_INTERRUPT: temp = "intr"; break; \
19 default: temp = "isoc"; break; \
21 #define pipestring(pipe) edstring(usb_pipetype(pipe))
23 /* debug| print the main components of an URB
24 * small: 0) header + data packets 1) just header
26 static void __maybe_unused
27 urb_print(struct urb
* urb
, char * str
, int small
, int status
)
29 unsigned int pipe
= urb
->pipe
;
31 if (!urb
->dev
|| !urb
->dev
->bus
) {
32 dbg("%s URB: no dev", str
);
36 #ifndef OHCI_VERBOSE_DEBUG
39 dbg("%s %p dev=%d ep=%d%s-%s flags=%x len=%d/%d stat=%d",
42 usb_pipedevice (pipe
),
43 usb_pipeendpoint (pipe
),
44 usb_pipeout (pipe
)? "out" : "in",
48 urb
->transfer_buffer_length
,
51 #ifdef OHCI_VERBOSE_DEBUG
55 if (usb_pipecontrol (pipe
)) {
56 printk (KERN_DEBUG
"%s: setup(8):", __FILE__
);
57 for (i
= 0; i
< 8 ; i
++)
58 printk (" %02x", ((__u8
*) urb
->setup_packet
) [i
]);
61 if (urb
->transfer_buffer_length
> 0 && urb
->transfer_buffer
) {
62 printk (KERN_DEBUG
"%s: data(%d/%d):", __FILE__
,
64 urb
->transfer_buffer_length
);
65 len
= usb_pipeout (pipe
)?
66 urb
->transfer_buffer_length
: urb
->actual_length
;
67 for (i
= 0; i
< 16 && i
< len
; i
++)
68 printk (" %02x", ((__u8
*) urb
->transfer_buffer
) [i
]);
69 printk ("%s stat:%d\n", i
< len
? "...": "", status
);
75 #define ohci_dbg_sw(ohci, next, size, format, arg...) \
79 s_len = scnprintf (*next, *size, format, ## arg ); \
80 *size -= s_len; *next += s_len; \
82 ohci_dbg(ohci,format, ## arg ); \
86 static void ohci_dump_intr_mask (
87 struct ohci_hcd
*ohci
,
93 ohci_dbg_sw (ohci
, next
, size
, "%s 0x%08x%s%s%s%s%s%s%s%s%s\n",
96 (mask
& OHCI_INTR_MIE
) ? " MIE" : "",
97 (mask
& OHCI_INTR_OC
) ? " OC" : "",
98 (mask
& OHCI_INTR_RHSC
) ? " RHSC" : "",
99 (mask
& OHCI_INTR_FNO
) ? " FNO" : "",
100 (mask
& OHCI_INTR_UE
) ? " UE" : "",
101 (mask
& OHCI_INTR_RD
) ? " RD" : "",
102 (mask
& OHCI_INTR_SF
) ? " SF" : "",
103 (mask
& OHCI_INTR_WDH
) ? " WDH" : "",
104 (mask
& OHCI_INTR_SO
) ? " SO" : ""
108 static void maybe_print_eds (
109 struct ohci_hcd
*ohci
,
116 ohci_dbg_sw (ohci
, next
, size
, "%s %08x\n", label
, value
);
119 static char *hcfs2string (int state
)
122 case OHCI_USB_RESET
: return "reset";
123 case OHCI_USB_RESUME
: return "resume";
124 case OHCI_USB_OPER
: return "operational";
125 case OHCI_USB_SUSPEND
: return "suspend";
130 // dump control and status registers
132 ohci_dump_status (struct ohci_hcd
*controller
, char **next
, unsigned *size
)
134 struct ohci_regs __iomem
*regs
= controller
->regs
;
137 temp
= ohci_readl (controller
, ®s
->revision
) & 0xff;
138 ohci_dbg_sw (controller
, next
, size
,
139 "OHCI %d.%d, %s legacy support registers\n",
140 0x03 & (temp
>> 4), (temp
& 0x0f),
141 (temp
& 0x0100) ? "with" : "NO");
143 temp
= ohci_readl (controller
, ®s
->control
);
144 ohci_dbg_sw (controller
, next
, size
,
145 "control 0x%03x%s%s%s HCFS=%s%s%s%s%s CBSR=%d\n",
147 (temp
& OHCI_CTRL_RWE
) ? " RWE" : "",
148 (temp
& OHCI_CTRL_RWC
) ? " RWC" : "",
149 (temp
& OHCI_CTRL_IR
) ? " IR" : "",
150 hcfs2string (temp
& OHCI_CTRL_HCFS
),
151 (temp
& OHCI_CTRL_BLE
) ? " BLE" : "",
152 (temp
& OHCI_CTRL_CLE
) ? " CLE" : "",
153 (temp
& OHCI_CTRL_IE
) ? " IE" : "",
154 (temp
& OHCI_CTRL_PLE
) ? " PLE" : "",
155 temp
& OHCI_CTRL_CBSR
158 temp
= ohci_readl (controller
, ®s
->cmdstatus
);
159 ohci_dbg_sw (controller
, next
, size
,
160 "cmdstatus 0x%05x SOC=%d%s%s%s%s\n", temp
,
161 (temp
& OHCI_SOC
) >> 16,
162 (temp
& OHCI_OCR
) ? " OCR" : "",
163 (temp
& OHCI_BLF
) ? " BLF" : "",
164 (temp
& OHCI_CLF
) ? " CLF" : "",
165 (temp
& OHCI_HCR
) ? " HCR" : ""
168 ohci_dump_intr_mask (controller
, "intrstatus",
169 ohci_readl (controller
, ®s
->intrstatus
),
171 ohci_dump_intr_mask (controller
, "intrenable",
172 ohci_readl (controller
, ®s
->intrenable
),
174 // intrdisable always same as intrenable
176 maybe_print_eds (controller
, "ed_periodcurrent",
177 ohci_readl (controller
, ®s
->ed_periodcurrent
),
180 maybe_print_eds (controller
, "ed_controlhead",
181 ohci_readl (controller
, ®s
->ed_controlhead
),
183 maybe_print_eds (controller
, "ed_controlcurrent",
184 ohci_readl (controller
, ®s
->ed_controlcurrent
),
187 maybe_print_eds (controller
, "ed_bulkhead",
188 ohci_readl (controller
, ®s
->ed_bulkhead
),
190 maybe_print_eds (controller
, "ed_bulkcurrent",
191 ohci_readl (controller
, ®s
->ed_bulkcurrent
),
194 maybe_print_eds (controller
, "donehead",
195 ohci_readl (controller
, ®s
->donehead
), next
, size
);
198 #define dbg_port_sw(hc,num,value,next,size) \
199 ohci_dbg_sw (hc, next, size, \
200 "roothub.portstatus [%d] " \
201 "0x%08x%s%s%s%s%s%s%s%s%s%s%s%s\n", \
203 (temp & RH_PS_PRSC) ? " PRSC" : "", \
204 (temp & RH_PS_OCIC) ? " OCIC" : "", \
205 (temp & RH_PS_PSSC) ? " PSSC" : "", \
206 (temp & RH_PS_PESC) ? " PESC" : "", \
207 (temp & RH_PS_CSC) ? " CSC" : "", \
209 (temp & RH_PS_LSDA) ? " LSDA" : "", \
210 (temp & RH_PS_PPS) ? " PPS" : "", \
211 (temp & RH_PS_PRS) ? " PRS" : "", \
212 (temp & RH_PS_POCI) ? " POCI" : "", \
213 (temp & RH_PS_PSS) ? " PSS" : "", \
215 (temp & RH_PS_PES) ? " PES" : "", \
216 (temp & RH_PS_CCS) ? " CCS" : "" \
222 struct ohci_hcd
*controller
,
229 temp
= roothub_a (controller
);
234 ohci_dbg_sw (controller
, next
, size
,
235 "roothub.a %08x POTPGT=%d%s%s%s%s%s NDP=%d(%d)\n", temp
,
236 ((temp
& RH_A_POTPGT
) >> 24) & 0xff,
237 (temp
& RH_A_NOCP
) ? " NOCP" : "",
238 (temp
& RH_A_OCPM
) ? " OCPM" : "",
239 (temp
& RH_A_DT
) ? " DT" : "",
240 (temp
& RH_A_NPS
) ? " NPS" : "",
241 (temp
& RH_A_PSM
) ? " PSM" : "",
242 (temp
& RH_A_NDP
), controller
->num_ports
244 temp
= roothub_b (controller
);
245 ohci_dbg_sw (controller
, next
, size
,
246 "roothub.b %08x PPCM=%04x DR=%04x\n",
248 (temp
& RH_B_PPCM
) >> 16,
251 temp
= roothub_status (controller
);
252 ohci_dbg_sw (controller
, next
, size
,
253 "roothub.status %08x%s%s%s%s%s%s\n",
255 (temp
& RH_HS_CRWE
) ? " CRWE" : "",
256 (temp
& RH_HS_OCIC
) ? " OCIC" : "",
257 (temp
& RH_HS_LPSC
) ? " LPSC" : "",
258 (temp
& RH_HS_DRWE
) ? " DRWE" : "",
259 (temp
& RH_HS_OCI
) ? " OCI" : "",
260 (temp
& RH_HS_LPS
) ? " LPS" : ""
264 for (i
= 0; i
< controller
->num_ports
; i
++) {
265 temp
= roothub_portstatus (controller
, i
);
266 dbg_port_sw (controller
, i
, temp
, next
, size
);
270 static void ohci_dump (struct ohci_hcd
*controller
, int verbose
)
272 ohci_dbg (controller
, "OHCI controller state\n");
274 // dumps some of the state we know about
275 ohci_dump_status (controller
, NULL
, NULL
);
276 if (controller
->hcca
)
277 ohci_dbg (controller
,
278 "hcca frame #%04x\n", ohci_frame_no(controller
));
279 ohci_dump_roothub (controller
, 1, NULL
, NULL
);
282 static const char data0
[] = "DATA0";
283 static const char data1
[] = "DATA1";
285 static void ohci_dump_td (const struct ohci_hcd
*ohci
, const char *label
,
288 u32 tmp
= hc32_to_cpup (ohci
, &td
->hwINFO
);
290 ohci_dbg (ohci
, "%s td %p%s; urb %p index %d; hw next td %08x\n",
292 (tmp
& TD_DONE
) ? " (DONE)" : "",
294 hc32_to_cpup (ohci
, &td
->hwNextTD
));
295 if ((tmp
& TD_ISO
) == 0) {
296 const char *toggle
, *pid
;
299 switch (tmp
& TD_T
) {
300 case TD_T_DATA0
: toggle
= data0
; break;
301 case TD_T_DATA1
: toggle
= data1
; break;
302 case TD_T_TOGGLE
: toggle
= "(CARRY)"; break;
303 default: toggle
= "(?)"; break;
305 switch (tmp
& TD_DP
) {
306 case TD_DP_SETUP
: pid
= "SETUP"; break;
307 case TD_DP_IN
: pid
= "IN"; break;
308 case TD_DP_OUT
: pid
= "OUT"; break;
309 default: pid
= "(bad pid)"; break;
311 ohci_dbg (ohci
, " info %08x CC=%x %s DI=%d %s %s\n", tmp
,
312 TD_CC_GET(tmp
), /* EC, */ toggle
,
313 (tmp
& TD_DI
) >> 21, pid
,
314 (tmp
& TD_R
) ? "R" : "");
315 cbp
= hc32_to_cpup (ohci
, &td
->hwCBP
);
316 be
= hc32_to_cpup (ohci
, &td
->hwBE
);
317 ohci_dbg (ohci
, " cbp %08x be %08x (len %d)\n", cbp
, be
,
318 cbp
? (be
+ 1 - cbp
) : 0);
321 ohci_dbg (ohci
, " info %08x CC=%x FC=%d DI=%d SF=%04x\n", tmp
,
326 ohci_dbg (ohci
, " bp0 %08x be %08x\n",
327 hc32_to_cpup (ohci
, &td
->hwCBP
) & ~0x0fff,
328 hc32_to_cpup (ohci
, &td
->hwBE
));
329 for (i
= 0; i
< MAXPSW
; i
++) {
330 u16 psw
= ohci_hwPSW (ohci
, td
, i
);
331 int cc
= (psw
>> 12) & 0x0f;
332 ohci_dbg (ohci
, " psw [%d] = %2x, CC=%x %s=%d\n", i
,
334 (cc
>= 0x0e) ? "OFFSET" : "SIZE",
340 /* caller MUST own hcd spinlock if verbose is set! */
341 static void __maybe_unused
342 ohci_dump_ed (const struct ohci_hcd
*ohci
, const char *label
,
343 const struct ed
*ed
, int verbose
)
345 u32 tmp
= hc32_to_cpu (ohci
, ed
->hwINFO
);
348 ohci_dbg (ohci
, "%s, ed %p state 0x%x type %s; next ed %08x\n",
350 ed
, ed
->state
, edstring (ed
->type
),
351 hc32_to_cpup (ohci
, &ed
->hwNextED
));
352 switch (tmp
& (ED_IN
|ED_OUT
)) {
353 case ED_OUT
: type
= "-OUT"; break;
354 case ED_IN
: type
= "-IN"; break;
355 /* else from TDs ... control */
358 " info %08x MAX=%d%s%s%s%s EP=%d%s DEV=%d\n", tmp
,
359 0x03ff & (tmp
>> 16),
360 (tmp
& ED_DEQUEUE
) ? " DQ" : "",
361 (tmp
& ED_ISO
) ? " ISO" : "",
362 (tmp
& ED_SKIP
) ? " SKIP" : "",
363 (tmp
& ED_LOWSPEED
) ? " LOW" : "",
367 tmp
= hc32_to_cpup (ohci
, &ed
->hwHeadP
);
368 ohci_dbg (ohci
, " tds: head %08x %s%s tail %08x%s\n",
370 (tmp
& ED_C
) ? data1
: data0
,
371 (tmp
& ED_H
) ? " HALT" : "",
372 hc32_to_cpup (ohci
, &ed
->hwTailP
),
373 verbose
? "" : " (not listing)");
375 struct list_head
*tmp
;
377 /* use ed->td_list because HC concurrently modifies
378 * hwNextTD as it accumulates ed_donelist.
380 list_for_each (tmp
, &ed
->td_list
) {
382 td
= list_entry (tmp
, struct td
, td_list
);
383 ohci_dump_td (ohci
, " ->", td
);
389 static inline void ohci_dump (struct ohci_hcd
*controller
, int verbose
) {}
391 #undef OHCI_VERBOSE_DEBUG
395 /*-------------------------------------------------------------------------*/
397 #ifdef STUB_DEBUG_FILES
399 static inline void create_debug_files (struct ohci_hcd
*bus
) { }
400 static inline void remove_debug_files (struct ohci_hcd
*bus
) { }
404 static int debug_async_open(struct inode
*, struct file
*);
405 static int debug_periodic_open(struct inode
*, struct file
*);
406 static int debug_registers_open(struct inode
*, struct file
*);
407 static int debug_async_open(struct inode
*, struct file
*);
408 static ssize_t
debug_output(struct file
*, char __user
*, size_t, loff_t
*);
409 static int debug_close(struct inode
*, struct file
*);
411 static const struct file_operations debug_async_fops
= {
412 .owner
= THIS_MODULE
,
413 .open
= debug_async_open
,
414 .read
= debug_output
,
415 .release
= debug_close
,
416 .llseek
= default_llseek
,
418 static const struct file_operations debug_periodic_fops
= {
419 .owner
= THIS_MODULE
,
420 .open
= debug_periodic_open
,
421 .read
= debug_output
,
422 .release
= debug_close
,
423 .llseek
= default_llseek
,
425 static const struct file_operations debug_registers_fops
= {
426 .owner
= THIS_MODULE
,
427 .open
= debug_registers_open
,
428 .read
= debug_output
,
429 .release
= debug_close
,
430 .llseek
= default_llseek
,
433 static struct dentry
*ohci_debug_root
;
435 struct debug_buffer
{
436 ssize_t (*fill_func
)(struct debug_buffer
*); /* fill method */
437 struct ohci_hcd
*ohci
;
438 struct mutex mutex
; /* protect filling of buffer */
439 size_t count
; /* number of characters filled into buffer */
444 show_list (struct ohci_hcd
*ohci
, char *buf
, size_t count
, struct ed
*ed
)
446 unsigned temp
, size
= count
;
451 /* print first --> last */
455 /* dump a snapshot of the bulk or control schedule */
457 u32 info
= hc32_to_cpu (ohci
, ed
->hwINFO
);
458 u32 headp
= hc32_to_cpu (ohci
, ed
->hwHeadP
);
459 struct list_head
*entry
;
462 temp
= scnprintf (buf
, size
,
463 "ed/%p %cs dev%d ep%d%s max %d %08x%s%s %s",
465 (info
& ED_LOWSPEED
) ? 'l' : 'f',
468 (info
& ED_IN
) ? "in" : "out",
469 0x03ff & (info
>> 16),
471 (info
& ED_SKIP
) ? " s" : "",
472 (headp
& ED_H
) ? " H" : "",
473 (headp
& ED_C
) ? data1
: data0
);
477 list_for_each (entry
, &ed
->td_list
) {
480 td
= list_entry (entry
, struct td
, td_list
);
481 info
= hc32_to_cpup (ohci
, &td
->hwINFO
);
482 cbp
= hc32_to_cpup (ohci
, &td
->hwCBP
);
483 be
= hc32_to_cpup (ohci
, &td
->hwBE
);
484 temp
= scnprintf (buf
, size
,
485 "\n\ttd %p %s %d cc=%x urb %p (%08x)",
488 switch (info
& TD_DP
) {
489 case TD_DP_SETUP
: pid
= "setup"; break;
490 case TD_DP_IN
: pid
= "in"; break;
491 case TD_DP_OUT
: pid
= "out"; break;
492 default: pid
= "(?)"; break;
494 cbp
? (be
+ 1 - cbp
) : 0,
495 TD_CC_GET (info
), td
->urb
, info
);
500 temp
= scnprintf (buf
, size
, "\n");
509 static ssize_t
fill_async_buffer(struct debug_buffer
*buf
)
511 struct ohci_hcd
*ohci
;
517 /* display control and bulk lists together, for simplicity */
518 spin_lock_irqsave (&ohci
->lock
, flags
);
519 temp
= show_list(ohci
, buf
->page
, buf
->count
, ohci
->ed_controltail
);
520 temp
+= show_list(ohci
, buf
->page
+ temp
, buf
->count
- temp
,
522 spin_unlock_irqrestore (&ohci
->lock
, flags
);
527 #define DBG_SCHED_LIMIT 64
529 static ssize_t
fill_periodic_buffer(struct debug_buffer
*buf
)
531 struct ohci_hcd
*ohci
;
532 struct ed
**seen
, *ed
;
534 unsigned temp
, size
, seen_count
;
538 if (!(seen
= kmalloc (DBG_SCHED_LIMIT
* sizeof *seen
, GFP_ATOMIC
)))
546 temp
= scnprintf (next
, size
, "size = %d\n", NUM_INTS
);
550 /* dump a snapshot of the periodic schedule (and load) */
551 spin_lock_irqsave (&ohci
->lock
, flags
);
552 for (i
= 0; i
< NUM_INTS
; i
++) {
553 if (!(ed
= ohci
->periodic
[i
]))
556 temp
= scnprintf (next
, size
, "%2d [%3d]:", i
, ohci
->load
[i
]);
561 temp
= scnprintf (next
, size
, " ed%d/%p",
565 for (temp
= 0; temp
< seen_count
; temp
++) {
566 if (seen
[temp
] == ed
)
570 /* show more info the first time around */
571 if (temp
== seen_count
) {
572 u32 info
= hc32_to_cpu (ohci
, ed
->hwINFO
);
573 struct list_head
*entry
;
576 /* qlen measured here in TDs, not urbs */
577 list_for_each (entry
, &ed
->td_list
)
580 temp
= scnprintf (next
, size
,
581 " (%cs dev%d ep%d%s-%s qlen %u"
583 (info
& ED_LOWSPEED
) ? 'l' : 'f',
586 (info
& ED_IN
) ? "in" : "out",
587 (info
& ED_ISO
) ? "iso" : "int",
589 0x03ff & (info
>> 16),
591 (info
& ED_SKIP
) ? " K" : "",
593 cpu_to_hc32(ohci
, ED_H
)) ?
598 if (seen_count
< DBG_SCHED_LIMIT
)
599 seen
[seen_count
++] = ed
;
604 /* we've seen it and what's after */
611 temp
= scnprintf (next
, size
, "\n");
615 spin_unlock_irqrestore (&ohci
->lock
, flags
);
618 return PAGE_SIZE
- size
;
620 #undef DBG_SCHED_LIMIT
622 static ssize_t
fill_registers_buffer(struct debug_buffer
*buf
)
625 struct ohci_hcd
*ohci
;
626 struct ohci_regs __iomem
*regs
;
633 hcd
= ohci_to_hcd(ohci
);
638 spin_lock_irqsave (&ohci
->lock
, flags
);
640 /* dump driver info, then registers in spec order */
642 ohci_dbg_sw (ohci
, &next
, &size
,
643 "bus %s, device %s\n"
646 hcd
->self
.controller
->bus
->name
,
647 dev_name(hcd
->self
.controller
),
651 if (!HCD_HW_ACCESSIBLE(hcd
)) {
652 size
-= scnprintf (next
, size
,
653 "SUSPENDED (no register access)\n");
657 ohci_dump_status(ohci
, &next
, &size
);
661 ohci_dbg_sw (ohci
, &next
, &size
,
662 "hcca frame 0x%04x\n", ohci_frame_no(ohci
));
664 /* other registers mostly affect frame timings */
665 rdata
= ohci_readl (ohci
, ®s
->fminterval
);
666 temp
= scnprintf (next
, size
,
667 "fmintvl 0x%08x %sFSMPS=0x%04x FI=0x%04x\n",
668 rdata
, (rdata
>> 31) ? "FIT " : "",
669 (rdata
>> 16) & 0xefff, rdata
& 0xffff);
673 rdata
= ohci_readl (ohci
, ®s
->fmremaining
);
674 temp
= scnprintf (next
, size
, "fmremaining 0x%08x %sFR=0x%04x\n",
675 rdata
, (rdata
>> 31) ? "FRT " : "",
680 rdata
= ohci_readl (ohci
, ®s
->periodicstart
);
681 temp
= scnprintf (next
, size
, "periodicstart 0x%04x\n",
686 rdata
= ohci_readl (ohci
, ®s
->lsthresh
);
687 temp
= scnprintf (next
, size
, "lsthresh 0x%04x\n",
692 temp
= scnprintf (next
, size
, "hub poll timer %s\n",
693 HCD_POLL_RH(ohci_to_hcd(ohci
)) ? "ON" : "off");
698 ohci_dump_roothub (ohci
, 1, &next
, &size
);
701 spin_unlock_irqrestore (&ohci
->lock
, flags
);
703 return PAGE_SIZE
- size
;
706 static struct debug_buffer
*alloc_buffer(struct ohci_hcd
*ohci
,
707 ssize_t (*fill_func
)(struct debug_buffer
*))
709 struct debug_buffer
*buf
;
711 buf
= kzalloc(sizeof(struct debug_buffer
), GFP_KERNEL
);
715 buf
->fill_func
= fill_func
;
716 mutex_init(&buf
->mutex
);
722 static int fill_buffer(struct debug_buffer
*buf
)
727 buf
->page
= (char *)get_zeroed_page(GFP_KERNEL
);
734 ret
= buf
->fill_func(buf
);
745 static ssize_t
debug_output(struct file
*file
, char __user
*user_buf
,
746 size_t len
, loff_t
*offset
)
748 struct debug_buffer
*buf
= file
->private_data
;
751 mutex_lock(&buf
->mutex
);
752 if (buf
->count
== 0) {
753 ret
= fill_buffer(buf
);
755 mutex_unlock(&buf
->mutex
);
759 mutex_unlock(&buf
->mutex
);
761 ret
= simple_read_from_buffer(user_buf
, len
, offset
,
762 buf
->page
, buf
->count
);
769 static int debug_close(struct inode
*inode
, struct file
*file
)
771 struct debug_buffer
*buf
= file
->private_data
;
775 free_page((unsigned long)buf
->page
);
781 static int debug_async_open(struct inode
*inode
, struct file
*file
)
783 file
->private_data
= alloc_buffer(inode
->i_private
, fill_async_buffer
);
785 return file
->private_data
? 0 : -ENOMEM
;
788 static int debug_periodic_open(struct inode
*inode
, struct file
*file
)
790 file
->private_data
= alloc_buffer(inode
->i_private
,
791 fill_periodic_buffer
);
793 return file
->private_data
? 0 : -ENOMEM
;
796 static int debug_registers_open(struct inode
*inode
, struct file
*file
)
798 file
->private_data
= alloc_buffer(inode
->i_private
,
799 fill_registers_buffer
);
801 return file
->private_data
? 0 : -ENOMEM
;
803 static inline void create_debug_files (struct ohci_hcd
*ohci
)
805 struct usb_bus
*bus
= &ohci_to_hcd(ohci
)->self
;
807 ohci
->debug_dir
= debugfs_create_dir(bus
->bus_name
, ohci_debug_root
);
808 if (!ohci
->debug_dir
)
811 ohci
->debug_async
= debugfs_create_file("async", S_IRUGO
,
812 ohci
->debug_dir
, ohci
,
814 if (!ohci
->debug_async
)
817 ohci
->debug_periodic
= debugfs_create_file("periodic", S_IRUGO
,
818 ohci
->debug_dir
, ohci
,
819 &debug_periodic_fops
);
820 if (!ohci
->debug_periodic
)
823 ohci
->debug_registers
= debugfs_create_file("registers", S_IRUGO
,
824 ohci
->debug_dir
, ohci
,
825 &debug_registers_fops
);
826 if (!ohci
->debug_registers
)
827 goto registers_error
;
829 ohci_dbg (ohci
, "created debug files\n");
833 debugfs_remove(ohci
->debug_periodic
);
835 debugfs_remove(ohci
->debug_async
);
837 debugfs_remove(ohci
->debug_dir
);
839 ohci
->debug_periodic
= NULL
;
840 ohci
->debug_async
= NULL
;
841 ohci
->debug_dir
= NULL
;
844 static inline void remove_debug_files (struct ohci_hcd
*ohci
)
846 debugfs_remove(ohci
->debug_registers
);
847 debugfs_remove(ohci
->debug_periodic
);
848 debugfs_remove(ohci
->debug_async
);
849 debugfs_remove(ohci
->debug_dir
);
854 /*-------------------------------------------------------------------------*/