Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/tclient.c
+++ new/usr/src/uts/common/io/tclient.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 * generic mpxio leaf driver
29 29 */
30 30 #include <sys/types.h>
31 31 #include <sys/param.h>
32 32 #include <sys/errno.h>
33 33 #include <sys/uio.h>
34 34 #include <sys/buf.h>
35 35 #include <sys/modctl.h>
36 36 #include <sys/open.h>
37 37 #include <sys/kmem.h>
38 38 #include <sys/conf.h>
39 39 #include <sys/cmn_err.h>
40 40 #include <sys/stat.h>
41 41 #include <sys/ddi.h>
42 42 #include <sys/sunddi.h>
43 43 #include <sys/sunndi.h>
44 44
45 45
46 46 static int tcli_open(dev_t *, int, int, cred_t *);
47 47 static int tcli_close(dev_t, int, int, cred_t *);
48 48 static int tcli_read(dev_t, struct uio *, cred_t *);
49 49 static int tcli_write(dev_t, struct uio *, cred_t *);
50 50 static int tcli_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
51 51 static int tcli_attach(dev_info_t *, ddi_attach_cmd_t);
52 52 static int tcli_detach(dev_info_t *, ddi_detach_cmd_t);
53 53
54 54 static int tcli_info(dev_info_t *, ddi_info_cmd_t, void *, void **);
55 55
56 56 struct dstate {
57 57 dev_info_t *dip;
58 58 int oflag;
59 59 };
60 60
61 61 static void *dstates;
62 62
63 63 #define INST_TO_MINOR(i) (i)
64 64 #define MINOR_TO_INST(mn) (mn)
65 65
66 66 static struct cb_ops tcli_cb_ops = {
67 67 tcli_open, /* open */
68 68 tcli_close, /* close */
69 69 nodev, /* strategy */
70 70 nodev, /* print */
71 71 nodev, /* dump */
72 72 tcli_read, /* read */
73 73 tcli_write, /* write */
74 74 tcli_ioctl, /* ioctl */
75 75 nodev, /* devmap */
76 76 nodev, /* mmap */
77 77 nodev, /* segmap */
78 78 nochpoll, /* poll */
79 79 ddi_prop_op, /* prop_op */
80 80 NULL, /* streamtab */
81 81 D_NEW | D_MP | D_HOTPLUG, /* flag */
82 82 CB_REV, /* cb_rev */
83 83 nodev, /* aread */
84 84 nodev /* awrite */
85 85 };
86 86
87 87
88 88 static struct dev_ops tcli_ops = {
89 89 DEVO_REV, /* devo_rev */
90 90 0, /* refcnt */
91 91 tcli_info, /* getinfo */
92 92 nulldev, /* identify */
93 93 nulldev, /* probe */
94 94 tcli_attach, /* attach */
95 95 tcli_detach, /* detach */
96 96 nodev, /* reset */
97 97 &tcli_cb_ops, /* driver ops */
98 98 (struct bus_ops *)0, /* bus ops */
99 99 NULL, /* power */
↓ open down ↓ |
99 lines elided |
↑ open up ↑ |
100 100 ddi_quiesce_not_needed, /* quiesce */
101 101 };
102 102
103 103 static struct modldrv modldrv = {
104 104 &mod_driverops,
105 105 "vhci client test driver",
106 106 &tcli_ops
107 107 };
108 108
109 109 static struct modlinkage modlinkage = {
110 - MODREV_1, &modldrv, NULL
110 + MODREV_1, { &modldrv, NULL }
111 111 };
112 112
113 113 int
114 114 _init(void)
115 115 {
116 116 int e;
117 117
118 118 if ((e = ddi_soft_state_init(&dstates,
119 119 sizeof (struct dstate), 0)) != 0) {
120 120 return (e);
121 121 }
122 122
123 123 if ((e = mod_install(&modlinkage)) != 0) {
124 124 ddi_soft_state_fini(&dstates);
125 125 }
126 126
127 127 return (e);
128 128 }
129 129
130 130 int
131 131 _fini(void)
132 132 {
133 133 int e;
134 134
135 135 if ((e = mod_remove(&modlinkage)) != 0) {
136 136 return (e);
137 137 }
138 138 ddi_soft_state_fini(&dstates);
139 139 return (e);
140 140 }
141 141
142 142 int
143 143 _info(struct modinfo *modinfop)
144 144 {
145 145 return (mod_info(&modlinkage, modinfop));
146 146 }
147 147
148 148 /*ARGSUSED*/
149 149 static int
150 150 tcli_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
151 151 {
152 152 int instance = ddi_get_instance(devi);
153 153 struct dstate *dstatep;
154 154 int rval;
155 155
156 156 if (cmd != DDI_ATTACH)
157 157 return (DDI_SUCCESS);
158 158
159 159 if (ddi_soft_state_zalloc(dstates, instance) != DDI_SUCCESS) {
160 160 cmn_err(CE_CONT, "%s%d: can't allocate state\n",
161 161 ddi_get_name(devi), instance);
162 162 return (DDI_FAILURE);
163 163 }
164 164
165 165 dstatep = ddi_get_soft_state(dstates, instance);
166 166 dstatep->dip = devi;
167 167
168 168 rval = ddi_create_minor_node(devi, "client", S_IFCHR,
169 169 (INST_TO_MINOR(instance)), DDI_PSEUDO, NULL);
170 170 if (rval == DDI_FAILURE) {
171 171 ddi_remove_minor_node(devi, NULL);
172 172 ddi_soft_state_free(dstates, instance);
173 173 cmn_err(CE_WARN, "%s%d: can't create minor nodes",
174 174 ddi_get_name(devi), instance);
175 175 return (DDI_FAILURE);
176 176 }
177 177
178 178 ddi_report_dev(devi);
179 179 return (DDI_SUCCESS);
180 180 }
181 181
182 182 /*ARGSUSED*/
183 183 static int
184 184 tcli_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
185 185 {
186 186 int instance;
187 187
188 188 if (cmd != DDI_DETACH)
189 189 return (DDI_SUCCESS);
190 190
191 191 ddi_remove_minor_node(devi, NULL);
192 192 instance = ddi_get_instance(devi);
193 193 ddi_soft_state_free(dstates, instance);
194 194 return (DDI_SUCCESS);
195 195 }
196 196
197 197 /* ARGSUSED */
198 198 static int
199 199 tcli_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
200 200 {
201 201 dev_t dev;
202 202 int instance;
203 203
204 204 if (infocmd != DDI_INFO_DEVT2INSTANCE)
205 205 return (DDI_FAILURE);
206 206
207 207 dev = (dev_t)arg;
208 208 instance = MINOR_TO_INST(getminor(dev));
209 209 *result = (void *)(uintptr_t)instance;
210 210 return (DDI_SUCCESS);
211 211 }
212 212
213 213
214 214 /*ARGSUSED*/
215 215 static int
216 216 tcli_open(dev_t *devp, int flag, int otyp, cred_t *cred)
217 217 {
218 218 minor_t minor;
219 219 struct dstate *dstatep;
220 220
221 221 if (otyp != OTYP_BLK && otyp != OTYP_CHR)
222 222 return (EINVAL);
223 223
224 224 minor = getminor(*devp);
225 225 if ((dstatep = ddi_get_soft_state(dstates,
226 226 MINOR_TO_INST(minor))) == NULL)
227 227 return (ENXIO);
228 228
229 229 dstatep->oflag = 1;
230 230
231 231 return (0);
232 232 }
233 233
234 234 /*ARGSUSED*/
235 235 static int
236 236 tcli_close(dev_t dev, int flag, int otyp, cred_t *cred)
237 237 {
238 238 struct dstate *dstatep;
239 239 minor_t minor = getminor(dev);
240 240
241 241 if (otyp != OTYP_BLK && otyp != OTYP_CHR)
242 242 return (EINVAL);
243 243
244 244 dstatep = ddi_get_soft_state(dstates, MINOR_TO_INST(minor));
245 245
246 246 if (dstatep == NULL)
247 247 return (ENXIO);
248 248
249 249 dstatep->oflag = 0;
250 250
251 251 return (0);
252 252 }
253 253
254 254 /*ARGSUSED*/
255 255 static int
256 256 tcli_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp,
257 257 int *rvalp)
258 258 {
259 259 struct dstate *dstatep;
260 260 int instance;
261 261
262 262 instance = MINOR_TO_INST(getminor(dev));
263 263 dstatep = ddi_get_soft_state(dstates, instance);
264 264
265 265 if (dstatep == NULL)
266 266 return (ENXIO);
267 267
268 268 return (0);
269 269 }
270 270
271 271 /*ARGSUSED*/
272 272 static int
273 273 tcli_read(dev_t dev, struct uio *uiop, cred_t *credp)
274 274 {
275 275 return (0);
276 276 }
277 277
278 278 /*ARGSUSED*/
279 279 static int
280 280 tcli_write(dev_t dev, struct uio *uiop, cred_t *credp)
281 281 {
282 282 return (0);
283 283 }
↓ open down ↓ |
163 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX