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 static const char *rh_state_string(struct ohci_hcd
*ohci
)
132 switch (ohci
->rh_state
) {
135 case OHCI_RH_SUSPENDED
:
137 case OHCI_RH_RUNNING
:
143 // dump control and status registers
145 ohci_dump_status (struct ohci_hcd
*controller
, char **next
, unsigned *size
)
147 struct ohci_regs __iomem
*regs
= controller
->regs
;
150 temp
= ohci_readl (controller
, ®s
->revision
) & 0xff;
151 ohci_dbg_sw (controller
, next
, size
,
152 "OHCI %d.%d, %s legacy support registers, rh state %s\n",
153 0x03 & (temp
>> 4), (temp
& 0x0f),
154 (temp
& 0x0100) ? "with" : "NO",
155 rh_state_string(controller
));
157 temp
= ohci_readl (controller
, ®s
->control
);
158 ohci_dbg_sw (controller
, next
, size
,
159 "control 0x%03x%s%s%s HCFS=%s%s%s%s%s CBSR=%d\n",
161 (temp
& OHCI_CTRL_RWE
) ? " RWE" : "",
162 (temp
& OHCI_CTRL_RWC
) ? " RWC" : "",
163 (temp
& OHCI_CTRL_IR
) ? " IR" : "",
164 hcfs2string (temp
& OHCI_CTRL_HCFS
),
165 (temp
& OHCI_CTRL_BLE
) ? " BLE" : "",
166 (temp
& OHCI_CTRL_CLE
) ? " CLE" : "",
167 (temp
& OHCI_CTRL_IE
) ? " IE" : "",
168 (temp
& OHCI_CTRL_PLE
) ? " PLE" : "",
169 temp
& OHCI_CTRL_CBSR
172 temp
= ohci_readl (controller
, ®s
->cmdstatus
);
173 ohci_dbg_sw (controller
, next
, size
,
174 "cmdstatus 0x%05x SOC=%d%s%s%s%s\n", temp
,
175 (temp
& OHCI_SOC
) >> 16,
176 (temp
& OHCI_OCR
) ? " OCR" : "",
177 (temp
& OHCI_BLF
) ? " BLF" : "",
178 (temp
& OHCI_CLF
) ? " CLF" : "",
179 (temp
& OHCI_HCR
) ? " HCR" : ""
182 ohci_dump_intr_mask (controller
, "intrstatus",
183 ohci_readl (controller
, ®s
->intrstatus
),
185 ohci_dump_intr_mask (controller
, "intrenable",
186 ohci_readl (controller
, ®s
->intrenable
),
188 // intrdisable always same as intrenable
190 maybe_print_eds (controller
, "ed_periodcurrent",
191 ohci_readl (controller
, ®s
->ed_periodcurrent
),
194 maybe_print_eds (controller
, "ed_controlhead",
195 ohci_readl (controller
, ®s
->ed_controlhead
),
197 maybe_print_eds (controller
, "ed_controlcurrent",
198 ohci_readl (controller
, ®s
->ed_controlcurrent
),
201 maybe_print_eds (controller
, "ed_bulkhead",
202 ohci_readl (controller
, ®s
->ed_bulkhead
),
204 maybe_print_eds (controller
, "ed_bulkcurrent",
205 ohci_readl (controller
, ®s
->ed_bulkcurrent
),
208 maybe_print_eds (controller
, "donehead",
209 ohci_readl (controller
, ®s
->donehead
), next
, size
);
212 #define dbg_port_sw(hc,num,value,next,size) \
213 ohci_dbg_sw (hc, next, size, \
214 "roothub.portstatus [%d] " \
215 "0x%08x%s%s%s%s%s%s%s%s%s%s%s%s\n", \
217 (temp & RH_PS_PRSC) ? " PRSC" : "", \
218 (temp & RH_PS_OCIC) ? " OCIC" : "", \
219 (temp & RH_PS_PSSC) ? " PSSC" : "", \
220 (temp & RH_PS_PESC) ? " PESC" : "", \
221 (temp & RH_PS_CSC) ? " CSC" : "", \
223 (temp & RH_PS_LSDA) ? " LSDA" : "", \
224 (temp & RH_PS_PPS) ? " PPS" : "", \
225 (temp & RH_PS_PRS) ? " PRS" : "", \
226 (temp & RH_PS_POCI) ? " POCI" : "", \
227 (temp & RH_PS_PSS) ? " PSS" : "", \
229 (temp & RH_PS_PES) ? " PES" : "", \
230 (temp & RH_PS_CCS) ? " CCS" : "" \
236 struct ohci_hcd
*controller
,
243 temp
= roothub_a (controller
);
248 ohci_dbg_sw (controller
, next
, size
,
249 "roothub.a %08x POTPGT=%d%s%s%s%s%s NDP=%d(%d)\n", temp
,
250 ((temp
& RH_A_POTPGT
) >> 24) & 0xff,
251 (temp
& RH_A_NOCP
) ? " NOCP" : "",
252 (temp
& RH_A_OCPM
) ? " OCPM" : "",
253 (temp
& RH_A_DT
) ? " DT" : "",
254 (temp
& RH_A_NPS
) ? " NPS" : "",
255 (temp
& RH_A_PSM
) ? " PSM" : "",
256 (temp
& RH_A_NDP
), controller
->num_ports
258 temp
= roothub_b (controller
);
259 ohci_dbg_sw (controller
, next
, size
,
260 "roothub.b %08x PPCM=%04x DR=%04x\n",
262 (temp
& RH_B_PPCM
) >> 16,
265 temp
= roothub_status (controller
);
266 ohci_dbg_sw (controller
, next
, size
,
267 "roothub.status %08x%s%s%s%s%s%s\n",
269 (temp
& RH_HS_CRWE
) ? " CRWE" : "",
270 (temp
& RH_HS_OCIC
) ? " OCIC" : "",
271 (temp
& RH_HS_LPSC
) ? " LPSC" : "",
272 (temp
& RH_HS_DRWE
) ? " DRWE" : "",
273 (temp
& RH_HS_OCI
) ? " OCI" : "",
274 (temp
& RH_HS_LPS
) ? " LPS" : ""
278 for (i
= 0; i
< controller
->num_ports
; i
++) {
279 temp
= roothub_portstatus (controller
, i
);
280 dbg_port_sw (controller
, i
, temp
, next
, size
);
284 static void ohci_dump (struct ohci_hcd
*controller
, int verbose
)
286 ohci_dbg (controller
, "OHCI controller state\n");
288 // dumps some of the state we know about
289 ohci_dump_status (controller
, NULL
, NULL
);
290 if (controller
->hcca
)
291 ohci_dbg (controller
,
292 "hcca frame #%04x\n", ohci_frame_no(controller
));
293 ohci_dump_roothub (controller
, 1, NULL
, NULL
);
296 static const char data0
[] = "DATA0";
297 static const char data1
[] = "DATA1";
299 static void ohci_dump_td (const struct ohci_hcd
*ohci
, const char *label
,
302 u32 tmp
= hc32_to_cpup (ohci
, &td
->hwINFO
);
304 ohci_dbg (ohci
, "%s td %p%s; urb %p index %d; hw next td %08x\n",
306 (tmp
& TD_DONE
) ? " (DONE)" : "",
308 hc32_to_cpup (ohci
, &td
->hwNextTD
));
309 if ((tmp
& TD_ISO
) == 0) {
310 const char *toggle
, *pid
;
313 switch (tmp
& TD_T
) {
314 case TD_T_DATA0
: toggle
= data0
; break;
315 case TD_T_DATA1
: toggle
= data1
; break;
316 case TD_T_TOGGLE
: toggle
= "(CARRY)"; break;
317 default: toggle
= "(?)"; break;
319 switch (tmp
& TD_DP
) {
320 case TD_DP_SETUP
: pid
= "SETUP"; break;
321 case TD_DP_IN
: pid
= "IN"; break;
322 case TD_DP_OUT
: pid
= "OUT"; break;
323 default: pid
= "(bad pid)"; break;
325 ohci_dbg (ohci
, " info %08x CC=%x %s DI=%d %s %s\n", tmp
,
326 TD_CC_GET(tmp
), /* EC, */ toggle
,
327 (tmp
& TD_DI
) >> 21, pid
,
328 (tmp
& TD_R
) ? "R" : "");
329 cbp
= hc32_to_cpup (ohci
, &td
->hwCBP
);
330 be
= hc32_to_cpup (ohci
, &td
->hwBE
);
331 ohci_dbg (ohci
, " cbp %08x be %08x (len %d)\n", cbp
, be
,
332 cbp
? (be
+ 1 - cbp
) : 0);
335 ohci_dbg (ohci
, " info %08x CC=%x FC=%d DI=%d SF=%04x\n", tmp
,
340 ohci_dbg (ohci
, " bp0 %08x be %08x\n",
341 hc32_to_cpup (ohci
, &td
->hwCBP
) & ~0x0fff,
342 hc32_to_cpup (ohci
, &td
->hwBE
));
343 for (i
= 0; i
< MAXPSW
; i
++) {
344 u16 psw
= ohci_hwPSW (ohci
, td
, i
);
345 int cc
= (psw
>> 12) & 0x0f;
346 ohci_dbg (ohci
, " psw [%d] = %2x, CC=%x %s=%d\n", i
,
348 (cc
>= 0x0e) ? "OFFSET" : "SIZE",
354 /* caller MUST own hcd spinlock if verbose is set! */
355 static void __maybe_unused
356 ohci_dump_ed (const struct ohci_hcd
*ohci
, const char *label
,
357 const struct ed
*ed
, int verbose
)
359 u32 tmp
= hc32_to_cpu (ohci
, ed
->hwINFO
);
362 ohci_dbg (ohci
, "%s, ed %p state 0x%x type %s; next ed %08x\n",
364 ed
, ed
->state
, edstring (ed
->type
),
365 hc32_to_cpup (ohci
, &ed
->hwNextED
));
366 switch (tmp
& (ED_IN
|ED_OUT
)) {
367 case ED_OUT
: type
= "-OUT"; break;
368 case ED_IN
: type
= "-IN"; break;
369 /* else from TDs ... control */
372 " info %08x MAX=%d%s%s%s%s EP=%d%s DEV=%d\n", tmp
,
373 0x03ff & (tmp
>> 16),
374 (tmp
& ED_DEQUEUE
) ? " DQ" : "",
375 (tmp
& ED_ISO
) ? " ISO" : "",
376 (tmp
& ED_SKIP
) ? " SKIP" : "",
377 (tmp
& ED_LOWSPEED
) ? " LOW" : "",
381 tmp
= hc32_to_cpup (ohci
, &ed
->hwHeadP
);
382 ohci_dbg (ohci
, " tds: head %08x %s%s tail %08x%s\n",
384 (tmp
& ED_C
) ? data1
: data0
,
385 (tmp
& ED_H
) ? " HALT" : "",
386 hc32_to_cpup (ohci
, &ed
->hwTailP
),
387 verbose
? "" : " (not listing)");
389 struct list_head
*tmp
;
391 /* use ed->td_list because HC concurrently modifies
392 * hwNextTD as it accumulates ed_donelist.
394 list_for_each (tmp
, &ed
->td_list
) {
396 td
= list_entry (tmp
, struct td
, td_list
);
397 ohci_dump_td (ohci
, " ->", td
);
403 static inline void ohci_dump (struct ohci_hcd
*controller
, int verbose
) {}
405 #undef OHCI_VERBOSE_DEBUG
409 /*-------------------------------------------------------------------------*/
411 #ifdef STUB_DEBUG_FILES
413 static inline void create_debug_files (struct ohci_hcd
*bus
) { }
414 static inline void remove_debug_files (struct ohci_hcd
*bus
) { }
418 static int debug_async_open(struct inode
*, struct file
*);
419 static int debug_periodic_open(struct inode
*, struct file
*);
420 static int debug_registers_open(struct inode
*, struct file
*);
421 static int debug_async_open(struct inode
*, struct file
*);
422 static ssize_t
debug_output(struct file
*, char __user
*, size_t, loff_t
*);
423 static int debug_close(struct inode
*, struct file
*);
425 static const struct file_operations debug_async_fops
= {
426 .owner
= THIS_MODULE
,
427 .open
= debug_async_open
,
428 .read
= debug_output
,
429 .release
= debug_close
,
430 .llseek
= default_llseek
,
432 static const struct file_operations debug_periodic_fops
= {
433 .owner
= THIS_MODULE
,
434 .open
= debug_periodic_open
,
435 .read
= debug_output
,
436 .release
= debug_close
,
437 .llseek
= default_llseek
,
439 static const struct file_operations debug_registers_fops
= {
440 .owner
= THIS_MODULE
,
441 .open
= debug_registers_open
,
442 .read
= debug_output
,
443 .release
= debug_close
,
444 .llseek
= default_llseek
,
447 static struct dentry
*ohci_debug_root
;
449 struct debug_buffer
{
450 ssize_t (*fill_func
)(struct debug_buffer
*); /* fill method */
451 struct ohci_hcd
*ohci
;
452 struct mutex mutex
; /* protect filling of buffer */
453 size_t count
; /* number of characters filled into buffer */
458 show_list (struct ohci_hcd
*ohci
, char *buf
, size_t count
, struct ed
*ed
)
460 unsigned temp
, size
= count
;
465 /* print first --> last */
469 /* dump a snapshot of the bulk or control schedule */
471 u32 info
= hc32_to_cpu (ohci
, ed
->hwINFO
);
472 u32 headp
= hc32_to_cpu (ohci
, ed
->hwHeadP
);
473 struct list_head
*entry
;
476 temp
= scnprintf (buf
, size
,
477 "ed/%p %cs dev%d ep%d%s max %d %08x%s%s %s",
479 (info
& ED_LOWSPEED
) ? 'l' : 'f',
482 (info
& ED_IN
) ? "in" : "out",
483 0x03ff & (info
>> 16),
485 (info
& ED_SKIP
) ? " s" : "",
486 (headp
& ED_H
) ? " H" : "",
487 (headp
& ED_C
) ? data1
: data0
);
491 list_for_each (entry
, &ed
->td_list
) {
494 td
= list_entry (entry
, struct td
, td_list
);
495 info
= hc32_to_cpup (ohci
, &td
->hwINFO
);
496 cbp
= hc32_to_cpup (ohci
, &td
->hwCBP
);
497 be
= hc32_to_cpup (ohci
, &td
->hwBE
);
498 temp
= scnprintf (buf
, size
,
499 "\n\ttd %p %s %d cc=%x urb %p (%08x)",
502 switch (info
& TD_DP
) {
503 case TD_DP_SETUP
: pid
= "setup"; break;
504 case TD_DP_IN
: pid
= "in"; break;
505 case TD_DP_OUT
: pid
= "out"; break;
506 default: pid
= "(?)"; break;
508 cbp
? (be
+ 1 - cbp
) : 0,
509 TD_CC_GET (info
), td
->urb
, info
);
514 temp
= scnprintf (buf
, size
, "\n");
523 static ssize_t
fill_async_buffer(struct debug_buffer
*buf
)
525 struct ohci_hcd
*ohci
;
531 /* display control and bulk lists together, for simplicity */
532 spin_lock_irqsave (&ohci
->lock
, flags
);
533 temp
= show_list(ohci
, buf
->page
, buf
->count
, ohci
->ed_controltail
);
534 temp
+= show_list(ohci
, buf
->page
+ temp
, buf
->count
- temp
,
536 spin_unlock_irqrestore (&ohci
->lock
, flags
);
541 #define DBG_SCHED_LIMIT 64
543 static ssize_t
fill_periodic_buffer(struct debug_buffer
*buf
)
545 struct ohci_hcd
*ohci
;
546 struct ed
**seen
, *ed
;
548 unsigned temp
, size
, seen_count
;
552 if (!(seen
= kmalloc (DBG_SCHED_LIMIT
* sizeof *seen
, GFP_ATOMIC
)))
560 temp
= scnprintf (next
, size
, "size = %d\n", NUM_INTS
);
564 /* dump a snapshot of the periodic schedule (and load) */
565 spin_lock_irqsave (&ohci
->lock
, flags
);
566 for (i
= 0; i
< NUM_INTS
; i
++) {
567 if (!(ed
= ohci
->periodic
[i
]))
570 temp
= scnprintf (next
, size
, "%2d [%3d]:", i
, ohci
->load
[i
]);
575 temp
= scnprintf (next
, size
, " ed%d/%p",
579 for (temp
= 0; temp
< seen_count
; temp
++) {
580 if (seen
[temp
] == ed
)
584 /* show more info the first time around */
585 if (temp
== seen_count
) {
586 u32 info
= hc32_to_cpu (ohci
, ed
->hwINFO
);
587 struct list_head
*entry
;
590 /* qlen measured here in TDs, not urbs */
591 list_for_each (entry
, &ed
->td_list
)
594 temp
= scnprintf (next
, size
,
595 " (%cs dev%d ep%d%s-%s qlen %u"
597 (info
& ED_LOWSPEED
) ? 'l' : 'f',
600 (info
& ED_IN
) ? "in" : "out",
601 (info
& ED_ISO
) ? "iso" : "int",
603 0x03ff & (info
>> 16),
605 (info
& ED_SKIP
) ? " K" : "",
607 cpu_to_hc32(ohci
, ED_H
)) ?
612 if (seen_count
< DBG_SCHED_LIMIT
)
613 seen
[seen_count
++] = ed
;
618 /* we've seen it and what's after */
625 temp
= scnprintf (next
, size
, "\n");
629 spin_unlock_irqrestore (&ohci
->lock
, flags
);
632 return PAGE_SIZE
- size
;
634 #undef DBG_SCHED_LIMIT
636 static ssize_t
fill_registers_buffer(struct debug_buffer
*buf
)
639 struct ohci_hcd
*ohci
;
640 struct ohci_regs __iomem
*regs
;
647 hcd
= ohci_to_hcd(ohci
);
652 spin_lock_irqsave (&ohci
->lock
, flags
);
654 /* dump driver info, then registers in spec order */
656 ohci_dbg_sw (ohci
, &next
, &size
,
657 "bus %s, device %s\n"
660 hcd
->self
.controller
->bus
->name
,
661 dev_name(hcd
->self
.controller
),
665 if (!HCD_HW_ACCESSIBLE(hcd
)) {
666 size
-= scnprintf (next
, size
,
667 "SUSPENDED (no register access)\n");
671 ohci_dump_status(ohci
, &next
, &size
);
675 ohci_dbg_sw (ohci
, &next
, &size
,
676 "hcca frame 0x%04x\n", ohci_frame_no(ohci
));
678 /* other registers mostly affect frame timings */
679 rdata
= ohci_readl (ohci
, ®s
->fminterval
);
680 temp
= scnprintf (next
, size
,
681 "fmintvl 0x%08x %sFSMPS=0x%04x FI=0x%04x\n",
682 rdata
, (rdata
>> 31) ? "FIT " : "",
683 (rdata
>> 16) & 0xefff, rdata
& 0xffff);
687 rdata
= ohci_readl (ohci
, ®s
->fmremaining
);
688 temp
= scnprintf (next
, size
, "fmremaining 0x%08x %sFR=0x%04x\n",
689 rdata
, (rdata
>> 31) ? "FRT " : "",
694 rdata
= ohci_readl (ohci
, ®s
->periodicstart
);
695 temp
= scnprintf (next
, size
, "periodicstart 0x%04x\n",
700 rdata
= ohci_readl (ohci
, ®s
->lsthresh
);
701 temp
= scnprintf (next
, size
, "lsthresh 0x%04x\n",
706 temp
= scnprintf (next
, size
, "hub poll timer %s\n",
707 HCD_POLL_RH(ohci_to_hcd(ohci
)) ? "ON" : "off");
712 ohci_dump_roothub (ohci
, 1, &next
, &size
);
715 spin_unlock_irqrestore (&ohci
->lock
, flags
);
717 return PAGE_SIZE
- size
;
720 static struct debug_buffer
*alloc_buffer(struct ohci_hcd
*ohci
,
721 ssize_t (*fill_func
)(struct debug_buffer
*))
723 struct debug_buffer
*buf
;
725 buf
= kzalloc(sizeof(struct debug_buffer
), GFP_KERNEL
);
729 buf
->fill_func
= fill_func
;
730 mutex_init(&buf
->mutex
);
736 static int fill_buffer(struct debug_buffer
*buf
)
741 buf
->page
= (char *)get_zeroed_page(GFP_KERNEL
);
748 ret
= buf
->fill_func(buf
);
759 static ssize_t
debug_output(struct file
*file
, char __user
*user_buf
,
760 size_t len
, loff_t
*offset
)
762 struct debug_buffer
*buf
= file
->private_data
;
765 mutex_lock(&buf
->mutex
);
766 if (buf
->count
== 0) {
767 ret
= fill_buffer(buf
);
769 mutex_unlock(&buf
->mutex
);
773 mutex_unlock(&buf
->mutex
);
775 ret
= simple_read_from_buffer(user_buf
, len
, offset
,
776 buf
->page
, buf
->count
);
783 static int debug_close(struct inode
*inode
, struct file
*file
)
785 struct debug_buffer
*buf
= file
->private_data
;
789 free_page((unsigned long)buf
->page
);
795 static int debug_async_open(struct inode
*inode
, struct file
*file
)
797 file
->private_data
= alloc_buffer(inode
->i_private
, fill_async_buffer
);
799 return file
->private_data
? 0 : -ENOMEM
;
802 static int debug_periodic_open(struct inode
*inode
, struct file
*file
)
804 file
->private_data
= alloc_buffer(inode
->i_private
,
805 fill_periodic_buffer
);
807 return file
->private_data
? 0 : -ENOMEM
;
810 static int debug_registers_open(struct inode
*inode
, struct file
*file
)
812 file
->private_data
= alloc_buffer(inode
->i_private
,
813 fill_registers_buffer
);
815 return file
->private_data
? 0 : -ENOMEM
;
817 static inline void create_debug_files (struct ohci_hcd
*ohci
)
819 struct usb_bus
*bus
= &ohci_to_hcd(ohci
)->self
;
821 ohci
->debug_dir
= debugfs_create_dir(bus
->bus_name
, ohci_debug_root
);
822 if (!ohci
->debug_dir
)
825 ohci
->debug_async
= debugfs_create_file("async", S_IRUGO
,
826 ohci
->debug_dir
, ohci
,
828 if (!ohci
->debug_async
)
831 ohci
->debug_periodic
= debugfs_create_file("periodic", S_IRUGO
,
832 ohci
->debug_dir
, ohci
,
833 &debug_periodic_fops
);
834 if (!ohci
->debug_periodic
)
837 ohci
->debug_registers
= debugfs_create_file("registers", S_IRUGO
,
838 ohci
->debug_dir
, ohci
,
839 &debug_registers_fops
);
840 if (!ohci
->debug_registers
)
841 goto registers_error
;
843 ohci_dbg (ohci
, "created debug files\n");
847 debugfs_remove(ohci
->debug_periodic
);
849 debugfs_remove(ohci
->debug_async
);
851 debugfs_remove(ohci
->debug_dir
);
853 ohci
->debug_periodic
= NULL
;
854 ohci
->debug_async
= NULL
;
855 ohci
->debug_dir
= NULL
;
858 static inline void remove_debug_files (struct ohci_hcd
*ohci
)
860 debugfs_remove(ohci
->debug_registers
);
861 debugfs_remove(ohci
->debug_periodic
);
862 debugfs_remove(ohci
->debug_async
);
863 debugfs_remove(ohci
->debug_dir
);
868 /*-------------------------------------------------------------------------*/