Print this page
8368 remove warlock leftovers from usr/src/uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/1394/targets/av1394/av1394.c
+++ new/usr/src/uts/common/io/1394/targets/av1394/av1394.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 * av1394 driver
29 29 */
30 30
31 31 #include <sys/param.h>
32 32 #include <sys/errno.h>
33 33 #include <sys/cred.h>
34 34 #include <sys/conf.h>
35 35 #include <sys/modctl.h>
36 36 #include <sys/stat.h>
37 37 #include <sys/ddi.h>
38 38 #include <sys/sunddi.h>
39 39
40 40 #include <sys/1394/targets/av1394/av1394_impl.h>
41 41
42 42 /* DDI/DKI entry points */
43 43 static int av1394_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
44 44 static int av1394_attach(dev_info_t *, ddi_attach_cmd_t);
45 45 static int av1394_detach(dev_info_t *, ddi_detach_cmd_t);
46 46 static int av1394_open(dev_t *, int, int, cred_t *);
47 47 static int av1394_close(dev_t, int, int, cred_t *);
48 48 static int av1394_read(dev_t, struct uio *, cred_t *);
49 49 static int av1394_write(dev_t, struct uio *, cred_t *);
50 50 static int av1394_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
51 51 static int av1394_devmap(dev_t, devmap_cookie_t, offset_t, size_t,
52 52 size_t *, uint_t);
53 53 static int av1394_poll(dev_t, short, int, short *, struct pollhead **);
54 54
55 55 /* configuration routines */
56 56 static void av1394_cleanup(av1394_inst_t *, int);
57 57 static int av1394_t1394_attach(av1394_inst_t *, dev_info_t *);
58 58 static void av1394_t1394_detach(av1394_inst_t *);
59 59 static int av1394_add_events(av1394_inst_t *);
60 60 static void av1394_remove_events(av1394_inst_t *);
61 61
62 62 /* CPR */
63 63 static int av1394_cpr_suspend(av1394_inst_t *);
64 64 static int av1394_cpr_resume(av1394_inst_t *);
65 65
66 66 /* callbacks */
67 67 static void av1394_bus_reset(dev_info_t *, ddi_eventcookie_t, void *,
68 68 void *);
69 69 static void av1394_disconnect(dev_info_t *, ddi_eventcookie_t, void *,
70 70 void *);
71 71 static void av1394_reconnect(dev_info_t *, ddi_eventcookie_t, void *,
72 72 void *);
73 73
74 74 extern struct mod_ops mod_driverops;
75 75
76 76 struct cb_ops av1394_cb_ops = {
77 77 av1394_open, /* open */
78 78 av1394_close, /* close */
79 79 nulldev, /* strategy */
80 80 nulldev, /* print */
81 81 nulldev, /* dump */
82 82 av1394_read, /* read */
83 83 av1394_write, /* write */
84 84 av1394_ioctl, /* ioctl */
85 85 av1394_devmap, /* devmap */
86 86 nulldev, /* mmap */
87 87 nulldev, /* segmap */
88 88 av1394_poll, /* poll */
89 89 ddi_prop_op, /* cb_prop_op */
90 90 NULL, /* streamtab */
91 91 D_MP | D_NEW | D_HOTPLUG | D_DEVMAP
92 92 };
93 93
94 94 static struct dev_ops av1394_ops = {
95 95 DEVO_REV, /* devo_rev */
96 96 0, /* refcnt */
97 97 av1394_getinfo, /* getinfo */
98 98 nulldev, /* identify */
99 99 nulldev, /* probe */
100 100 av1394_attach, /* attach */
101 101 av1394_detach, /* detach */
102 102 nodev, /* reset */
103 103 &av1394_cb_ops, /* driver operations */
104 104 NULL, /* bus operations */
105 105 NULL, /* power */
106 106 ddi_quiesce_not_supported, /* devo_quiesce */
107 107 };
108 108
109 109 static struct modldrv av1394_modldrv = {
110 110 &mod_driverops,
111 111 "IEEE 1394 AV driver",
112 112 &av1394_ops
113 113 };
114 114
115 115 static struct modlinkage av1394_modlinkage = {
116 116 MODREV_1,
117 117 &av1394_modldrv,
118 118 NULL,
119 119 };
120 120
121 121 static void *av1394_statep;
122 122
123 123 #ifndef NPROBE
124 124 extern int tnf_mod_load(void);
125 125 extern int tnf_mod_unload(struct modlinkage *mlp);
126 126 #endif
127 127
128 128 #define AV1394_INST2STATE(inst) (ddi_get_soft_state(av1394_statep, inst))
129 129 #define AV1394_DEV2STATE(dev) \
130 130 (ddi_get_soft_state(av1394_statep, AV1394_DEV2INST(dev)))
131 131
132 132 #define AV1394_TNF_ENTER(func) \
133 133 TNF_PROBE_0_DEBUG(func##_enter, AV1394_TNF_INST_STACK, "");
134 134
135 135 #define AV1394_TNF_EXIT(func) \
136 136 TNF_PROBE_0_DEBUG(func##_exit, AV1394_TNF_INST_STACK, "");
137 137
138 138 /*
139 139 *
140 140 * --- DDI/DKI entry points
141 141 *
142 142 */
143 143 int
144 144 _init(void)
145 145 {
146 146 int error;
147 147
148 148 #ifndef NPROBE
149 149 (void) tnf_mod_load();
150 150 #endif
151 151 error = ddi_soft_state_init(&av1394_statep, sizeof (av1394_inst_t), 1);
152 152 if (error != 0) {
153 153 #ifndef NPROBE
154 154 (void) tnf_mod_unload(&av1394_modlinkage);
155 155 #endif
156 156 return (error);
157 157 }
158 158
159 159 if ((error = mod_install(&av1394_modlinkage)) != 0) {
160 160 ddi_soft_state_fini(&av1394_statep);
161 161 #ifndef NPROBE
162 162 (void) tnf_mod_unload(&av1394_modlinkage);
163 163 #endif
164 164 }
165 165
166 166 return (error);
167 167 }
168 168
169 169 int
170 170 _fini(void)
171 171 {
172 172 int error;
173 173
174 174 if ((error = mod_remove(&av1394_modlinkage)) == 0) {
175 175 ddi_soft_state_fini(&av1394_statep);
176 176 #ifndef NPROBE
177 177 (void) tnf_mod_unload(&av1394_modlinkage);
178 178 #endif
179 179 }
180 180
181 181 return (error);
182 182 }
183 183
184 184 int
185 185 _info(struct modinfo *modinfop)
186 186 {
187 187 return (mod_info(&av1394_modlinkage, modinfop));
188 188 }
189 189
190 190 /*
191 191 * attach
192 192 */
193 193 static int
194 194 av1394_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
195 195 {
196 196 int instance = ddi_get_instance(dip);
197 197 av1394_inst_t *avp;
198 198
199 199 AV1394_TNF_ENTER(av1394_attach);
200 200
201 201 switch (cmd) {
202 202 case DDI_ATTACH:
203 203 break;
204 204 case DDI_RESUME:
205 205 if ((avp = AV1394_INST2STATE(instance)) == NULL) {
206 206 return (DDI_FAILURE);
207 207 }
208 208 return (av1394_cpr_resume(avp));
209 209 default:
210 210 AV1394_TNF_EXIT(av1394_attach);
211 211 return (DDI_FAILURE);
212 212 }
213 213
214 214 if (ddi_soft_state_zalloc(av1394_statep, instance) != 0) {
215 215 TNF_PROBE_0(av1394_attach_error_soft_state_zalloc,
216 216 AV1394_TNF_INST_ERROR, "");
217 217 AV1394_TNF_EXIT(av1394_attach);
218 218 return (DDI_FAILURE);
219 219 }
220 220 avp = AV1394_INST2STATE(instance);
↓ open down ↓ |
220 lines elided |
↑ open up ↑ |
221 221
222 222 if (av1394_t1394_attach(avp, dip) != DDI_SUCCESS) {
223 223 av1394_cleanup(avp, 1);
224 224 AV1394_TNF_EXIT(av1394_attach);
225 225 return (DDI_FAILURE);
226 226 }
227 227
228 228 mutex_init(&avp->av_mutex, NULL, MUTEX_DRIVER,
229 229 avp->av_attachinfo.iblock_cookie);
230 230
231 -#ifndef __lock_lint
232 231 avp->av_dip = dip;
233 232 avp->av_instance = instance;
234 -#endif
235 233
236 234 if (av1394_add_events(avp) != DDI_SUCCESS) {
237 235 av1394_cleanup(avp, 2);
238 236 AV1394_TNF_EXIT(av1394_attach);
239 237 return (DDI_FAILURE);
240 238 }
241 239
242 240 if (av1394_isoch_attach(avp) != DDI_SUCCESS) {
243 241 av1394_cleanup(avp, 3);
244 242 AV1394_TNF_EXIT(av1394_attach);
245 243 return (DDI_FAILURE);
246 244 }
247 245
248 246 if (av1394_async_attach(avp) != DDI_SUCCESS) {
249 247 av1394_cleanup(avp, 4);
250 248 AV1394_TNF_EXIT(av1394_attach);
251 249 return (DDI_FAILURE);
252 250 }
253 251
254 -#ifndef __lock_lint
255 252 avp->av_dev_state = AV1394_DEV_ONLINE;
256 -#endif
257 253
258 254 ddi_report_dev(dip);
259 255
260 256 AV1394_TNF_EXIT(av1394_attach);
261 257 return (DDI_SUCCESS);
262 258 }
263 259
264 260 static int
265 261 av1394_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
266 262 {
267 263 int instance = ddi_get_instance(dip);
268 264 av1394_inst_t *avp;
269 265
270 266 AV1394_TNF_ENTER(av1394_detach);
271 267
272 268 if ((avp = AV1394_INST2STATE(instance)) == NULL) {
273 269 TNF_PROBE_0(av1394_detach_error_instance,
274 270 AV1394_TNF_INST_ERROR, "");
275 271 AV1394_TNF_EXIT(av1394_detach);
276 272 return (DDI_FAILURE);
277 273 }
278 274
279 275 switch (cmd) {
280 276 case DDI_DETACH:
281 277 av1394_cleanup(avp, AV1394_CLEANUP_LEVEL_MAX);
282 278 AV1394_TNF_EXIT(av1394_detach);
283 279 return (DDI_SUCCESS);
284 280 case DDI_SUSPEND:
285 281 return (av1394_cpr_suspend(avp));
286 282 default:
287 283 AV1394_TNF_EXIT(av1394_detach);
288 284 return (DDI_FAILURE);
289 285 }
290 286 }
291 287
292 288 /*ARGSUSED*/
293 289 static int
294 290 av1394_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg,
295 291 void **result)
296 292 {
297 293 dev_t dev = (dev_t)arg;
298 294 av1394_inst_t *avp;
299 295 int rval = DDI_FAILURE;
300 296
301 297 switch (infocmd) {
302 298 case DDI_INFO_DEVT2DEVINFO:
303 299 if ((avp = AV1394_DEV2STATE(dev)) != NULL) {
304 300 *result = avp->av_dip;
305 301 rval = DDI_SUCCESS;
306 302 } else {
307 303 *result = NULL;
308 304 }
309 305 break;
310 306 case DDI_INFO_DEVT2INSTANCE:
311 307 *result = (void *)(uintptr_t)AV1394_DEV2INST(dev);
312 308 rval = DDI_SUCCESS;
313 309 break;
314 310 }
315 311
316 312 return (rval);
317 313 }
318 314
319 315 /*ARGSUSED*/
320 316 static int
321 317 av1394_open(dev_t *dev, int flag, int otyp, cred_t *cr)
322 318 {
323 319 av1394_inst_t *avp = AV1394_DEV2STATE(*dev);
324 320 int ret = ENXIO;
325 321
326 322 AV1394_TNF_ENTER(av1394_open);
327 323 if (avp != NULL) {
328 324 if (AV1394_DEV_IS_ISOCH(*dev)) {
329 325 ret = 0;
330 326 } else if (AV1394_DEV_IS_ASYNC(*dev)) {
331 327 ret = av1394_async_open(avp, flag);
332 328 }
333 329 }
334 330 AV1394_TNF_EXIT(av1394_open);
335 331 return (ret);
336 332 }
337 333
338 334 /*ARGSUSED*/
339 335 static int
340 336 av1394_close(dev_t dev, int flag, int otyp, cred_t *cr)
341 337 {
342 338 av1394_inst_t *avp = AV1394_DEV2STATE(dev);
343 339 int ret = ENXIO;
344 340
345 341 AV1394_TNF_ENTER(av1394_close);
346 342 if (avp != NULL) {
347 343 if (AV1394_DEV_IS_ISOCH(dev)) {
348 344 ret = av1394_isoch_close(avp, flag);
349 345 } else if (AV1394_DEV_IS_ASYNC(dev)) {
350 346 ret = av1394_async_close(avp, flag);
351 347 }
352 348 }
353 349 AV1394_TNF_EXIT(av1394_close);
354 350 return (ret);
355 351 }
356 352
357 353 /*ARGSUSED*/
358 354 static int
359 355 av1394_read(dev_t dev, struct uio *uiop, cred_t *cr)
360 356 {
361 357 av1394_inst_t *avp = AV1394_DEV2STATE(dev);
362 358 int ret = ENXIO;
363 359
364 360 AV1394_TNF_ENTER(av1394_read);
365 361 if (avp != NULL) {
366 362 if (AV1394_DEV_IS_ISOCH(dev)) {
367 363 ret = av1394_isoch_read(avp, uiop);
368 364 } else if (AV1394_DEV_IS_ASYNC(dev)) {
369 365 ret = av1394_async_read(avp, uiop);
370 366 }
371 367 }
372 368 AV1394_TNF_EXIT(av1394_read);
373 369 return (ret);
374 370 }
375 371
376 372 /*ARGSUSED*/
377 373 static int
378 374 av1394_write(dev_t dev, struct uio *uiop, cred_t *cr)
379 375 {
380 376 av1394_inst_t *avp = AV1394_DEV2STATE(dev);
381 377 int ret = ENXIO;
382 378
383 379 AV1394_TNF_ENTER(av1394_write);
384 380 if (avp != NULL) {
385 381 if (AV1394_DEV_IS_ISOCH(dev)) {
386 382 ret = av1394_isoch_write(avp, uiop);
387 383 } else if (AV1394_DEV_IS_ASYNC(dev)) {
388 384 ret = av1394_async_write(avp, uiop);
389 385 }
390 386 }
391 387 AV1394_TNF_EXIT(av1394_write);
392 388 return (ret);
393 389 }
394 390
395 391 /*ARGSUSED*/
396 392 static int
397 393 av1394_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cr, int *rvalp)
398 394 {
399 395 av1394_inst_t *avp = AV1394_DEV2STATE(dev);
400 396 int ret = ENXIO;
401 397
402 398 AV1394_TNF_ENTER(av1394_ioctl);
403 399 if (avp != NULL) {
404 400 if (AV1394_DEV_IS_ISOCH(dev)) {
405 401 ret = av1394_isoch_ioctl(avp, cmd, arg, mode, rvalp);
406 402 } else if (AV1394_DEV_IS_ASYNC(dev)) {
407 403 ret = av1394_async_ioctl(avp, cmd, arg, mode, rvalp);
408 404 }
409 405 }
410 406 AV1394_TNF_EXIT(av1394_ioctl);
411 407 return (ret);
412 408 }
413 409
414 410 /*ARGSUSED*/
415 411 static int
416 412 av1394_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, size_t len,
417 413 size_t *maplen, uint_t model)
418 414 {
419 415 av1394_inst_t *avp = AV1394_DEV2STATE(dev);
420 416 int ret = ENXIO;
421 417
422 418 AV1394_TNF_ENTER(av1394_devmap);
423 419 if ((avp != NULL) && (AV1394_DEV_IS_ISOCH(dev))) {
424 420 ret = av1394_isoch_devmap(avp, dhp, off, len, maplen, model);
425 421 }
426 422 AV1394_TNF_EXIT(av1394_devmap);
427 423 return (ret);
428 424 }
429 425
430 426 static int
431 427 av1394_poll(dev_t dev, short events, int anyyet, short *reventsp,
432 428 struct pollhead **phpp)
433 429 {
434 430 av1394_inst_t *avp = AV1394_DEV2STATE(dev);
435 431 int ret = ENXIO;
436 432
437 433 AV1394_TNF_ENTER(av1394_poll);
438 434 if ((avp != NULL) && AV1394_DEV_IS_ASYNC(dev)) {
439 435 ret = av1394_async_poll(avp, events, anyyet, reventsp, phpp);
440 436 }
441 437 AV1394_TNF_EXIT(av1394_poll);
442 438 return (ret);
443 439 }
444 440
445 441
446 442 /*
447 443 *
448 444 * --- configuration routines
449 445 *
450 446 * av1394_cleanup()
451 447 * Cleanup after attach
452 448 */
453 449 static void
454 450 av1394_cleanup(av1394_inst_t *avp, int level)
455 451 {
456 452 ASSERT((level > 0) && (level <= AV1394_CLEANUP_LEVEL_MAX));
457 453
458 454 AV1394_TNF_ENTER(av1394_cleanup);
459 455 switch (level) {
460 456 default:
461 457 av1394_async_detach(avp);
462 458 /* FALLTHRU */
463 459 case 4:
464 460 av1394_isoch_detach(avp);
465 461 /* FALLTHRU */
466 462 case 3:
467 463 av1394_remove_events(avp);
468 464 /* FALLTHRU */
469 465 case 2:
470 466 av1394_t1394_detach(avp);
471 467 mutex_destroy(&avp->av_mutex);
472 468 /* FALLTHRU */
473 469 case 1:
474 470 ddi_soft_state_free(av1394_statep, avp->av_instance);
475 471 }
476 472 AV1394_TNF_EXIT(av1394_cleanup);
477 473 }
478 474
479 475 static int
480 476 av1394_t1394_attach(av1394_inst_t *avp, dev_info_t *dip)
481 477 {
482 478 int ret;
483 479
484 480 AV1394_TNF_ENTER(av1394_t1394_attach);
485 481
486 482 ret = t1394_attach(dip, T1394_VERSION_V1, 0, &avp->av_attachinfo,
487 483 &avp->av_t1394_hdl);
488 484
489 485 if (ret != DDI_SUCCESS) {
490 486 TNF_PROBE_1(av1394_t1394_attach_error, AV1394_TNF_INST_ERROR,
491 487 "", tnf_int, ret, ret);
492 488 }
493 489
494 490 AV1394_TNF_EXIT(av1394_t1394_attach);
495 491 return (ret);
496 492 }
497 493
498 494 static void
499 495 av1394_t1394_detach(av1394_inst_t *avp)
500 496 {
501 497 AV1394_TNF_ENTER(av1394_t1394_detach);
502 498
503 499 (void) t1394_detach(&avp->av_t1394_hdl, 0);
504 500
505 501 AV1394_TNF_EXIT(av1394_t1394_detach);
506 502 }
507 503
508 504 static int
509 505 av1394_add_events(av1394_inst_t *avp)
510 506 {
511 507 ddi_eventcookie_t br_evc, rem_evc, ins_evc;
512 508
513 509 if (ddi_get_eventcookie(avp->av_dip, DDI_DEVI_BUS_RESET_EVENT,
514 510 &br_evc) != DDI_SUCCESS) {
515 511 TNF_PROBE_0(av1394_add_events_error_bus_reset_cookie,
516 512 AV1394_TNF_INST_ERROR, "");
517 513 return (DDI_FAILURE);
518 514 }
519 515 if (ddi_add_event_handler(avp->av_dip, br_evc, av1394_bus_reset,
520 516 avp, &avp->av_reset_cb) != DDI_SUCCESS) {
521 517 TNF_PROBE_0(av1394_add_events_error_bus_reset_event,
522 518 AV1394_TNF_INST_ERROR, "");
523 519 return (DDI_FAILURE);
524 520 }
525 521
526 522 if (ddi_get_eventcookie(avp->av_dip, DDI_DEVI_REMOVE_EVENT,
527 523 &rem_evc) != DDI_SUCCESS) {
528 524 (void) ddi_remove_event_handler(avp->av_reset_cb);
529 525 TNF_PROBE_0(av1394_add_events_error_remove_cookie,
530 526 AV1394_TNF_INST_ERROR, "");
531 527 return (DDI_FAILURE);
532 528 }
533 529 if (ddi_add_event_handler(avp->av_dip, rem_evc, av1394_disconnect,
534 530 avp, &avp->av_remove_cb) != DDI_SUCCESS) {
535 531 (void) ddi_remove_event_handler(avp->av_reset_cb);
536 532 TNF_PROBE_0(av1394_add_events_error_remove_event,
537 533 AV1394_TNF_INST_ERROR, "");
538 534 return (DDI_FAILURE);
539 535 }
540 536
541 537 if (ddi_get_eventcookie(avp->av_dip, DDI_DEVI_INSERT_EVENT,
542 538 &ins_evc) != DDI_SUCCESS) {
543 539 (void) ddi_remove_event_handler(avp->av_remove_cb);
544 540 (void) ddi_remove_event_handler(avp->av_reset_cb);
545 541 TNF_PROBE_0(av1394_add_events_error_insert_cookie,
546 542 AV1394_TNF_INST_ERROR, "");
547 543 return (DDI_FAILURE);
548 544 }
549 545 if (ddi_add_event_handler(avp->av_dip, ins_evc, av1394_reconnect,
550 546 avp, &avp->av_insert_cb) != DDI_SUCCESS) {
551 547 (void) ddi_remove_event_handler(avp->av_remove_cb);
552 548 (void) ddi_remove_event_handler(avp->av_reset_cb);
553 549 TNF_PROBE_0(av1394_add_events_error_insert_event,
554 550 AV1394_TNF_INST_ERROR, "");
555 551 return (DDI_FAILURE);
556 552 }
557 553
558 554 return (DDI_SUCCESS);
559 555 }
560 556
561 557 static void
562 558 av1394_remove_events(av1394_inst_t *avp)
563 559 {
564 560 ddi_eventcookie_t evc;
565 561
566 562 if (ddi_get_eventcookie(avp->av_dip, DDI_DEVI_INSERT_EVENT,
567 563 &evc) == DDI_SUCCESS) {
568 564 (void) ddi_remove_event_handler(avp->av_insert_cb);
569 565 }
570 566
571 567 if (ddi_get_eventcookie(avp->av_dip, DDI_DEVI_REMOVE_EVENT,
572 568 &evc) == DDI_SUCCESS) {
573 569 (void) ddi_remove_event_handler(avp->av_remove_cb);
574 570 }
575 571
576 572 if (ddi_get_eventcookie(avp->av_dip, DDI_DEVI_BUS_RESET_EVENT,
577 573 &evc) == DDI_SUCCESS) {
578 574 (void) ddi_remove_event_handler(avp->av_reset_cb);
579 575 }
580 576 }
581 577
582 578 /*
583 579 *
584 580 * --- CPR
585 581 *
586 582 */
587 583 static int
588 584 av1394_cpr_suspend(av1394_inst_t *avp)
589 585 {
590 586 int ret;
591 587
592 588 AV1394_TNF_ENTER(av1394_cpr_suspend);
593 589
594 590 ret = av1394_isoch_cpr_suspend(avp);
595 591
596 592 if (ret == DDI_SUCCESS) {
597 593 mutex_enter(&avp->av_mutex);
598 594 avp->av_prev_dev_state = avp->av_dev_state;
599 595 avp->av_dev_state = AV1394_DEV_SUSPENDED;
600 596 mutex_exit(&avp->av_mutex);
601 597 }
602 598
603 599 AV1394_TNF_EXIT(av1394_cpr_suspend);
604 600 return (ret);
605 601 }
606 602
607 603 /*
608 604 * CPR resume should always succeed
609 605 */
610 606 static int
611 607 av1394_cpr_resume(av1394_inst_t *avp)
612 608 {
613 609 AV1394_TNF_ENTER(av1394_cpr_resume);
614 610
615 611 mutex_enter(&avp->av_mutex);
616 612 avp->av_dev_state = avp->av_prev_dev_state;
617 613 mutex_exit(&avp->av_mutex);
618 614
619 615 (void) av1394_async_cpr_resume(avp);
620 616
621 617 AV1394_TNF_EXIT(av1394_cpr_resume);
622 618 return (DDI_SUCCESS);
623 619 }
624 620
625 621 /*
626 622 *
627 623 * --- callbacks
628 624 *
629 625 */
630 626 /*ARGSUSED*/
631 627 static void
632 628 av1394_bus_reset(dev_info_t *dip, ddi_eventcookie_t evc, void *arg, void *data)
633 629 {
634 630 av1394_inst_t *avp = arg;
635 631
636 632 AV1394_TNF_ENTER(av1394_bus_reset);
637 633
638 634 if (avp == NULL) {
639 635 AV1394_TNF_EXIT(av1394_bus_reset);
640 636 return;
641 637 }
642 638
643 639 mutex_enter(&avp->av_mutex);
644 640 avp->av_attachinfo.localinfo = *(t1394_localinfo_t *)data;
645 641 mutex_exit(&avp->av_mutex);
646 642
647 643 av1394_async_bus_reset(avp);
648 644 av1394_cmp_bus_reset(avp);
649 645
650 646 AV1394_TNF_EXIT(av1394_bus_reset);
651 647 }
652 648
653 649 /*ARGSUSED*/
654 650 static void
655 651 av1394_disconnect(dev_info_t *dip, ddi_eventcookie_t evc, void *arg, void *data)
656 652 {
657 653 av1394_inst_t *avp = arg;
658 654
659 655 AV1394_TNF_ENTER(av1394_disconnect);
660 656
661 657 if (avp == NULL) {
662 658 AV1394_TNF_EXIT(av1394_disconnect);
663 659 return;
664 660 }
665 661
666 662 mutex_enter(&avp->av_mutex);
667 663 avp->av_dev_state = AV1394_DEV_DISCONNECTED;
668 664 mutex_exit(&avp->av_mutex);
669 665
670 666 AV1394_TNF_EXIT(av1394_disconnect);
671 667 }
672 668
673 669 /*ARGSUSED*/
674 670 static void
675 671 av1394_reconnect(dev_info_t *dip, ddi_eventcookie_t evc, void *arg, void *data)
676 672 {
677 673 av1394_inst_t *avp = arg;
678 674
679 675 AV1394_TNF_ENTER(av1394_disconnect);
680 676
681 677 if (avp == NULL) {
682 678 AV1394_TNF_EXIT(av1394_disconnect);
683 679 return;
684 680 }
685 681
686 682 mutex_enter(&avp->av_mutex);
687 683 avp->av_dev_state = AV1394_DEV_ONLINE;
688 684 avp->av_attachinfo.localinfo = *(t1394_localinfo_t *)data;
689 685 mutex_exit(&avp->av_mutex);
690 686
691 687 av1394_async_reconnect(avp);
692 688
693 689 AV1394_TNF_EXIT(av1394_disconnect);
694 690 }
↓ open down ↓ |
428 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX