Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / usb / usb_port.h
blob935a9df6f12c33d5f79bc72fedc7c8f0039fcf0f
1 /* $NetBSD: usb_port.h,v 1.85 2008/06/28 09:06:20 kent Exp $ */
3 /*
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net) at
9 * Carlstedt Research & Technology.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _USB_PORT_H
34 #define _USB_PORT_H
37 * Macro's to cope with the differences between operating systems.
40 typedef struct proc *usb_proc_ptr;
42 typedef device_t device_ptr_t;
43 #define USBBASEDEVICE device_t
44 #define USBDEV(bdev) (bdev)
45 #define USBDEVNAME(bdev) (device_xname(bdev))
46 #define USBDEVUNIT(bdev) device_unit(bdev)
47 #define USBDEVPTRNAME(bdevptr) (device_xname(bdevptr))
48 #define USBGETSOFTC(d) (device_private(d))
50 #define DECLARE_USB_DMA_T \
51 struct usb_dma_block; \
52 typedef struct { \
53 struct usb_dma_block *block; \
54 u_int offs; \
55 } usb_dma_t
57 typedef struct callout usb_callout_t;
58 #define usb_callout_init(h) callout_init(&(h), 0)
59 #define usb_callout_destroy(h) callout_destroy((&h))
60 #define usb_callout(h, t, f, d) callout_reset(&(h), (t), (f), (d))
61 #define usb_uncallout(h, f, d) callout_stop(&(h))
63 #define usb_kthread_create1 kthread_create
64 #define usb_kthread_create(f, a) ((f)(a))
66 typedef struct malloc_type *usb_malloc_type;
68 #define Ether_ifattach ether_ifattach
69 #define IF_INPUT(ifp, m) (*(ifp)->if_input)((ifp), (m))
71 #define logprintf printf
73 #define USB_DNAME(dname) dname
74 #define USB_DECLARE_DRIVER(dname) \
75 int __CONCAT(dname,_match)(device_t, cfdata_t, void *); \
76 void __CONCAT(dname,_attach)(device_t, device_t, void *); \
77 int __CONCAT(dname,_detach)(device_t, int); \
78 int __CONCAT(dname,_activate)(device_t, enum devact); \
80 extern struct cfdriver __CONCAT(dname,_cd); \
82 CFATTACH_DECL_NEW(USB_DNAME(dname), \
83 sizeof(struct ___CONCAT(dname,_softc)), \
84 ___CONCAT(dname,_match), \
85 ___CONCAT(dname,_attach), \
86 ___CONCAT(dname,_detach), \
87 ___CONCAT(dname,_activate))
89 #define USB_MATCH(dname) \
90 int __CONCAT(dname,_match)(device_t parent, \
91 cfdata_t match, void *aux)
93 #define USB_MATCH_START(dname, uaa) \
94 struct usb_attach_arg *uaa = aux
96 #define USB_IFMATCH_START(dname, uaa) \
97 struct usbif_attach_arg *uaa = aux
99 #define USB_ATTACH(dname) \
100 void __CONCAT(dname,_attach)(device_t parent, \
101 device_t self, void *aux)
103 #define USB_ATTACH_START(dname, sc, uaa) \
104 struct __CONCAT(dname,_softc) *sc = \
105 device_private(self); \
106 struct usb_attach_arg *uaa = aux
108 #define USB_IFATTACH_START(dname, sc, uaa) \
109 struct __CONCAT(dname,_softc) *sc = \
110 device_private(self); \
111 struct usbif_attach_arg *uaa = aux
113 /* Returns from attach */
114 #define USB_ATTACH_ERROR_RETURN return
115 #define USB_ATTACH_SUCCESS_RETURN return
117 #define USB_ATTACH_SETUP \
118 do { \
119 aprint_naive("\n"); \
120 aprint_normal("\n"); \
121 } while (0)
123 #define USB_DETACH(dname) \
124 int __CONCAT(dname,_detach)(device_t self, int flags)
126 #define USB_DETACH_START(dname, sc) \
127 struct __CONCAT(dname,_softc) *sc = \
128 device_private(self)
130 #define USB_GET_SC_OPEN(dname, unit, sc) \
131 sc = device_lookup_private(& __CONCAT(dname,_cd), unit); \
132 if (sc == NULL) \
133 return (ENXIO)
135 #define USB_GET_SC(dname, unit, sc) \
136 sc = device_lookup_private(& __CONCAT(dname,_cd), unit)
138 #endif /* _USB_PORT_H */