Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/usb/hubd/hubd.c
+++ new/usr/src/uts/common/io/usb/hubd/hubd.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26
27 27 /*
28 28 * skeleton hub driver, the actual code is in hubdi.c
29 29 * as it is shared between the root hub and the other hub instances
30 30 */
31 31 #if defined(lint) && !defined(DEBUG)
32 32 #define DEBUG 1
33 33 #endif
34 34
35 35 #include <sys/usb/usba/usbai_version.h>
36 36 #include <sys/usb/usba.h>
37 37 #include <sys/usb/usba/hubdi.h>
38 38 #include <sys/usb/hubd/hub.h>
39 39 #include <sys/usb/hubd/hubdvar.h>
40 40
41 41 static int hubd_open(dev_t *devp, int flags, int otyp, cred_t *credp);
42 42 static int hubd_close(dev_t dev, int flag, int otyp, cred_t *credp);
43 43 static int hubd_ioctl(dev_t dev, int cmd, intptr_t arg, int mode,
44 44 cred_t *credp, int *rvalp);
45 45 static int hubd_info(dev_info_t *dip, ddi_info_cmd_t infocmd,
46 46 void *arg, void **result);
47 47 extern int usba_hubdi_power(dev_info_t *dip, int comp, int level);
48 48
49 49
50 50 static struct cb_ops hubd_cb_ops = {
51 51 hubd_open, /* open */
52 52 hubd_close, /* close */
53 53 nodev, /* strategy */
54 54 nodev, /* print */
55 55 nodev, /* dump */
56 56 nodev, /* read */
57 57 nodev, /* write */
58 58 hubd_ioctl, /* ioctl */
59 59 nodev, /* devmap */
60 60 nodev, /* mmap */
61 61 nodev, /* segmap */
62 62 nochpoll, /* poll */
63 63 ddi_prop_op, /* cb_prop_op */
64 64 NULL, /* streamtab */
65 65 D_MP /* Driver compatibility flag */
66 66 };
67 67
68 68 static struct dev_ops hubd_ops = {
69 69 DEVO_REV, /* devo_rev, */
70 70 0, /* refcnt */
71 71 hubd_info, /* info */
72 72 nulldev, /* identify */
73 73 nulldev, /* probe */
74 74 usba_hubdi_attach, /* attach */
75 75 usba_hubdi_detach, /* detach */
76 76 nodev, /* reset */
77 77 &hubd_cb_ops, /* driver operations */
78 78 &usba_hubdi_busops, /* bus operations */
79 79 usba_hubdi_power, /* power */
↓ open down ↓ |
79 lines elided |
↑ open up ↑ |
80 80 ddi_quiesce_not_needed, /* quiesce */
81 81 };
82 82
83 83 static struct modldrv modldrv = {
84 84 &mod_driverops, /* Type of module. This one is a driver */
85 85 "USB Hub Driver", /* Name of the module. */
86 86 &hubd_ops, /* driver ops */
87 87 };
88 88
89 89 static struct modlinkage modlinkage = {
90 - MODREV_1, (void *)&modldrv, NULL
90 + MODREV_1, { (void *)&modldrv, NULL }
91 91 };
92 92
93 93
94 94 extern void *hubd_statep;
95 95
96 96 int
97 97 _init(void)
98 98 {
99 99 int rval;
100 100
101 101 /* Initialize the soft state structures */
102 102 if ((rval = ddi_soft_state_init(&hubd_statep,
103 103 sizeof (hubd_t), HUBD_INITIAL_SOFT_SPACE)) != 0) {
104 104 return (rval);
105 105 }
106 106
107 107 if ((rval = mod_install(&modlinkage)) != 0) {
108 108 ddi_soft_state_fini(&hubd_statep);
109 109
110 110 return (rval);
111 111 }
112 112
113 113 return (rval);
114 114 }
115 115
116 116
117 117 int
118 118 _fini(void)
119 119 {
120 120 int rval = mod_remove(&modlinkage);
121 121 if (rval == 0) {
122 122 ddi_soft_state_fini(&hubd_statep);
123 123 }
124 124
125 125 return (rval);
126 126 }
127 127
128 128
129 129 int
130 130 _info(struct modinfo *modinfop)
131 131 {
132 132 return (mod_info(&modlinkage, modinfop));
133 133 }
134 134
135 135
136 136 static dev_info_t *
137 137 hubd_get_dip(dev_t dev)
138 138 {
139 139 minor_t minor = getminor(dev);
140 140 int instance = (int)minor & ~HUBD_IS_ROOT_HUB;
141 141 hubd_t *hubd = ddi_get_soft_state(hubd_statep, instance);
142 142
143 143 if (hubd) {
144 144 return (hubd->h_dip);
145 145 } else {
146 146 return (NULL);
147 147 }
148 148 }
149 149
150 150 /*
151 151 * info handler
152 152 */
153 153 /*ARGSUSED*/
154 154 int
155 155 hubd_info(dev_info_t *dip, ddi_info_cmd_t infocmd,
156 156 void *arg, void **result)
157 157 {
158 158 dev_t dev;
159 159 int instance;
160 160 int error = DDI_FAILURE;
161 161
162 162 switch (infocmd) {
163 163 case DDI_INFO_DEVT2DEVINFO:
164 164 *result = (void *)hubd_get_dip((dev_t)arg);
165 165 if (*result != NULL) {
166 166 error = DDI_SUCCESS;
167 167 }
168 168 break;
169 169 case DDI_INFO_DEVT2INSTANCE:
170 170 dev = (dev_t)arg;
171 171 instance = HUBD_UNIT(dev);
172 172 *result = (void *)(intptr_t)instance;
173 173 error = DDI_SUCCESS;
174 174 break;
175 175 default:
176 176 break;
177 177 }
178 178 return (error);
179 179 }
180 180
181 181 static int
182 182 hubd_open(dev_t *devp, int flags, int otyp, cred_t *credp)
183 183 {
184 184 dev_info_t *dip = hubd_get_dip(*devp);
185 185
186 186 return (usba_hubdi_open(dip, devp, flags, otyp, credp));
187 187 }
188 188
189 189
190 190 static int
191 191 hubd_close(dev_t dev, int flag, int otyp, cred_t *credp)
192 192 {
193 193 dev_info_t *dip = hubd_get_dip(dev);
194 194
195 195 return (usba_hubdi_close(dip, dev, flag, otyp, credp));
196 196 }
197 197
198 198
199 199 static int
200 200 hubd_ioctl(dev_t dev, int cmd, intptr_t arg, int mode,
201 201 cred_t *credp, int *rvalp)
202 202 {
203 203 dev_info_t *dip = hubd_get_dip(dev);
204 204
205 205 return (usba_hubdi_ioctl(dip, dev, cmd, arg, mode,
206 206 credp, rvalp));
207 207 }
↓ open down ↓ |
107 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX