Print this page
fixup .text where possible
7127 remove -Wno-missing-braces from Makefile.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 */
↓ open down ↓ |
106 lines elided |
↑ open up ↑ |
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 - &av1394_modldrv,
118 - NULL,
117 + { &av1394_modldrv,
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);
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 231 #ifndef __lock_lint
232 232 avp->av_dip = dip;
233 233 avp->av_instance = instance;
234 234 #endif
235 235
236 236 if (av1394_add_events(avp) != DDI_SUCCESS) {
237 237 av1394_cleanup(avp, 2);
238 238 AV1394_TNF_EXIT(av1394_attach);
239 239 return (DDI_FAILURE);
240 240 }
241 241
242 242 if (av1394_isoch_attach(avp) != DDI_SUCCESS) {
243 243 av1394_cleanup(avp, 3);
244 244 AV1394_TNF_EXIT(av1394_attach);
245 245 return (DDI_FAILURE);
246 246 }
247 247
248 248 if (av1394_async_attach(avp) != DDI_SUCCESS) {
249 249 av1394_cleanup(avp, 4);
250 250 AV1394_TNF_EXIT(av1394_attach);
251 251 return (DDI_FAILURE);
252 252 }
253 253
254 254 #ifndef __lock_lint
255 255 avp->av_dev_state = AV1394_DEV_ONLINE;
256 256 #endif
257 257
258 258 ddi_report_dev(dip);
259 259
260 260 AV1394_TNF_EXIT(av1394_attach);
261 261 return (DDI_SUCCESS);
262 262 }
263 263
264 264 static int
265 265 av1394_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
266 266 {
267 267 int instance = ddi_get_instance(dip);
268 268 av1394_inst_t *avp;
269 269
270 270 AV1394_TNF_ENTER(av1394_detach);
271 271
272 272 if ((avp = AV1394_INST2STATE(instance)) == NULL) {
273 273 TNF_PROBE_0(av1394_detach_error_instance,
274 274 AV1394_TNF_INST_ERROR, "");
275 275 AV1394_TNF_EXIT(av1394_detach);
276 276 return (DDI_FAILURE);
277 277 }
278 278
279 279 switch (cmd) {
280 280 case DDI_DETACH:
281 281 av1394_cleanup(avp, AV1394_CLEANUP_LEVEL_MAX);
282 282 AV1394_TNF_EXIT(av1394_detach);
283 283 return (DDI_SUCCESS);
284 284 case DDI_SUSPEND:
285 285 return (av1394_cpr_suspend(avp));
286 286 default:
287 287 AV1394_TNF_EXIT(av1394_detach);
288 288 return (DDI_FAILURE);
289 289 }
290 290 }
291 291
292 292 /*ARGSUSED*/
293 293 static int
294 294 av1394_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg,
295 295 void **result)
296 296 {
297 297 dev_t dev = (dev_t)arg;
298 298 av1394_inst_t *avp;
299 299 int rval = DDI_FAILURE;
300 300
301 301 switch (infocmd) {
302 302 case DDI_INFO_DEVT2DEVINFO:
303 303 if ((avp = AV1394_DEV2STATE(dev)) != NULL) {
304 304 *result = avp->av_dip;
305 305 rval = DDI_SUCCESS;
306 306 } else {
307 307 *result = NULL;
308 308 }
309 309 break;
310 310 case DDI_INFO_DEVT2INSTANCE:
311 311 *result = (void *)(uintptr_t)AV1394_DEV2INST(dev);
312 312 rval = DDI_SUCCESS;
313 313 break;
314 314 }
315 315
316 316 return (rval);
317 317 }
318 318
319 319 /*ARGSUSED*/
320 320 static int
321 321 av1394_open(dev_t *dev, int flag, int otyp, cred_t *cr)
322 322 {
323 323 av1394_inst_t *avp = AV1394_DEV2STATE(*dev);
324 324 int ret = ENXIO;
325 325
326 326 AV1394_TNF_ENTER(av1394_open);
327 327 if (avp != NULL) {
328 328 if (AV1394_DEV_IS_ISOCH(*dev)) {
329 329 ret = 0;
330 330 } else if (AV1394_DEV_IS_ASYNC(*dev)) {
331 331 ret = av1394_async_open(avp, flag);
332 332 }
333 333 }
334 334 AV1394_TNF_EXIT(av1394_open);
335 335 return (ret);
336 336 }
337 337
338 338 /*ARGSUSED*/
339 339 static int
340 340 av1394_close(dev_t dev, int flag, int otyp, cred_t *cr)
341 341 {
342 342 av1394_inst_t *avp = AV1394_DEV2STATE(dev);
343 343 int ret = ENXIO;
344 344
345 345 AV1394_TNF_ENTER(av1394_close);
346 346 if (avp != NULL) {
347 347 if (AV1394_DEV_IS_ISOCH(dev)) {
348 348 ret = av1394_isoch_close(avp, flag);
349 349 } else if (AV1394_DEV_IS_ASYNC(dev)) {
350 350 ret = av1394_async_close(avp, flag);
351 351 }
352 352 }
353 353 AV1394_TNF_EXIT(av1394_close);
354 354 return (ret);
355 355 }
356 356
357 357 /*ARGSUSED*/
358 358 static int
359 359 av1394_read(dev_t dev, struct uio *uiop, cred_t *cr)
360 360 {
361 361 av1394_inst_t *avp = AV1394_DEV2STATE(dev);
362 362 int ret = ENXIO;
363 363
364 364 AV1394_TNF_ENTER(av1394_read);
365 365 if (avp != NULL) {
366 366 if (AV1394_DEV_IS_ISOCH(dev)) {
367 367 ret = av1394_isoch_read(avp, uiop);
368 368 } else if (AV1394_DEV_IS_ASYNC(dev)) {
369 369 ret = av1394_async_read(avp, uiop);
370 370 }
371 371 }
372 372 AV1394_TNF_EXIT(av1394_read);
373 373 return (ret);
374 374 }
375 375
376 376 /*ARGSUSED*/
377 377 static int
378 378 av1394_write(dev_t dev, struct uio *uiop, cred_t *cr)
379 379 {
380 380 av1394_inst_t *avp = AV1394_DEV2STATE(dev);
381 381 int ret = ENXIO;
382 382
383 383 AV1394_TNF_ENTER(av1394_write);
384 384 if (avp != NULL) {
385 385 if (AV1394_DEV_IS_ISOCH(dev)) {
386 386 ret = av1394_isoch_write(avp, uiop);
387 387 } else if (AV1394_DEV_IS_ASYNC(dev)) {
388 388 ret = av1394_async_write(avp, uiop);
389 389 }
390 390 }
391 391 AV1394_TNF_EXIT(av1394_write);
392 392 return (ret);
393 393 }
394 394
395 395 /*ARGSUSED*/
396 396 static int
397 397 av1394_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cr, int *rvalp)
398 398 {
399 399 av1394_inst_t *avp = AV1394_DEV2STATE(dev);
400 400 int ret = ENXIO;
401 401
402 402 AV1394_TNF_ENTER(av1394_ioctl);
403 403 if (avp != NULL) {
404 404 if (AV1394_DEV_IS_ISOCH(dev)) {
405 405 ret = av1394_isoch_ioctl(avp, cmd, arg, mode, rvalp);
406 406 } else if (AV1394_DEV_IS_ASYNC(dev)) {
407 407 ret = av1394_async_ioctl(avp, cmd, arg, mode, rvalp);
408 408 }
409 409 }
410 410 AV1394_TNF_EXIT(av1394_ioctl);
411 411 return (ret);
412 412 }
413 413
414 414 /*ARGSUSED*/
415 415 static int
416 416 av1394_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off, size_t len,
417 417 size_t *maplen, uint_t model)
418 418 {
419 419 av1394_inst_t *avp = AV1394_DEV2STATE(dev);
420 420 int ret = ENXIO;
421 421
422 422 AV1394_TNF_ENTER(av1394_devmap);
423 423 if ((avp != NULL) && (AV1394_DEV_IS_ISOCH(dev))) {
424 424 ret = av1394_isoch_devmap(avp, dhp, off, len, maplen, model);
425 425 }
426 426 AV1394_TNF_EXIT(av1394_devmap);
427 427 return (ret);
428 428 }
429 429
430 430 static int
431 431 av1394_poll(dev_t dev, short events, int anyyet, short *reventsp,
432 432 struct pollhead **phpp)
433 433 {
434 434 av1394_inst_t *avp = AV1394_DEV2STATE(dev);
435 435 int ret = ENXIO;
436 436
437 437 AV1394_TNF_ENTER(av1394_poll);
438 438 if ((avp != NULL) && AV1394_DEV_IS_ASYNC(dev)) {
439 439 ret = av1394_async_poll(avp, events, anyyet, reventsp, phpp);
440 440 }
441 441 AV1394_TNF_EXIT(av1394_poll);
442 442 return (ret);
443 443 }
444 444
445 445
446 446 /*
447 447 *
448 448 * --- configuration routines
449 449 *
450 450 * av1394_cleanup()
451 451 * Cleanup after attach
452 452 */
453 453 static void
454 454 av1394_cleanup(av1394_inst_t *avp, int level)
455 455 {
456 456 ASSERT((level > 0) && (level <= AV1394_CLEANUP_LEVEL_MAX));
457 457
458 458 AV1394_TNF_ENTER(av1394_cleanup);
459 459 switch (level) {
460 460 default:
461 461 av1394_async_detach(avp);
462 462 /* FALLTHRU */
463 463 case 4:
464 464 av1394_isoch_detach(avp);
465 465 /* FALLTHRU */
466 466 case 3:
467 467 av1394_remove_events(avp);
468 468 /* FALLTHRU */
469 469 case 2:
470 470 av1394_t1394_detach(avp);
471 471 mutex_destroy(&avp->av_mutex);
472 472 /* FALLTHRU */
473 473 case 1:
474 474 ddi_soft_state_free(av1394_statep, avp->av_instance);
475 475 }
476 476 AV1394_TNF_EXIT(av1394_cleanup);
477 477 }
478 478
479 479 static int
480 480 av1394_t1394_attach(av1394_inst_t *avp, dev_info_t *dip)
481 481 {
482 482 int ret;
483 483
484 484 AV1394_TNF_ENTER(av1394_t1394_attach);
485 485
486 486 ret = t1394_attach(dip, T1394_VERSION_V1, 0, &avp->av_attachinfo,
487 487 &avp->av_t1394_hdl);
488 488
489 489 if (ret != DDI_SUCCESS) {
490 490 TNF_PROBE_1(av1394_t1394_attach_error, AV1394_TNF_INST_ERROR,
491 491 "", tnf_int, ret, ret);
492 492 }
493 493
494 494 AV1394_TNF_EXIT(av1394_t1394_attach);
495 495 return (ret);
496 496 }
497 497
498 498 static void
499 499 av1394_t1394_detach(av1394_inst_t *avp)
500 500 {
501 501 AV1394_TNF_ENTER(av1394_t1394_detach);
502 502
503 503 (void) t1394_detach(&avp->av_t1394_hdl, 0);
504 504
505 505 AV1394_TNF_EXIT(av1394_t1394_detach);
506 506 }
507 507
508 508 static int
509 509 av1394_add_events(av1394_inst_t *avp)
510 510 {
511 511 ddi_eventcookie_t br_evc, rem_evc, ins_evc;
512 512
513 513 if (ddi_get_eventcookie(avp->av_dip, DDI_DEVI_BUS_RESET_EVENT,
514 514 &br_evc) != DDI_SUCCESS) {
515 515 TNF_PROBE_0(av1394_add_events_error_bus_reset_cookie,
516 516 AV1394_TNF_INST_ERROR, "");
517 517 return (DDI_FAILURE);
518 518 }
519 519 if (ddi_add_event_handler(avp->av_dip, br_evc, av1394_bus_reset,
520 520 avp, &avp->av_reset_cb) != DDI_SUCCESS) {
521 521 TNF_PROBE_0(av1394_add_events_error_bus_reset_event,
522 522 AV1394_TNF_INST_ERROR, "");
523 523 return (DDI_FAILURE);
524 524 }
525 525
526 526 if (ddi_get_eventcookie(avp->av_dip, DDI_DEVI_REMOVE_EVENT,
527 527 &rem_evc) != DDI_SUCCESS) {
528 528 (void) ddi_remove_event_handler(avp->av_reset_cb);
529 529 TNF_PROBE_0(av1394_add_events_error_remove_cookie,
530 530 AV1394_TNF_INST_ERROR, "");
531 531 return (DDI_FAILURE);
532 532 }
533 533 if (ddi_add_event_handler(avp->av_dip, rem_evc, av1394_disconnect,
534 534 avp, &avp->av_remove_cb) != DDI_SUCCESS) {
535 535 (void) ddi_remove_event_handler(avp->av_reset_cb);
536 536 TNF_PROBE_0(av1394_add_events_error_remove_event,
537 537 AV1394_TNF_INST_ERROR, "");
538 538 return (DDI_FAILURE);
539 539 }
540 540
541 541 if (ddi_get_eventcookie(avp->av_dip, DDI_DEVI_INSERT_EVENT,
542 542 &ins_evc) != DDI_SUCCESS) {
543 543 (void) ddi_remove_event_handler(avp->av_remove_cb);
544 544 (void) ddi_remove_event_handler(avp->av_reset_cb);
545 545 TNF_PROBE_0(av1394_add_events_error_insert_cookie,
546 546 AV1394_TNF_INST_ERROR, "");
547 547 return (DDI_FAILURE);
548 548 }
549 549 if (ddi_add_event_handler(avp->av_dip, ins_evc, av1394_reconnect,
550 550 avp, &avp->av_insert_cb) != DDI_SUCCESS) {
551 551 (void) ddi_remove_event_handler(avp->av_remove_cb);
552 552 (void) ddi_remove_event_handler(avp->av_reset_cb);
553 553 TNF_PROBE_0(av1394_add_events_error_insert_event,
554 554 AV1394_TNF_INST_ERROR, "");
555 555 return (DDI_FAILURE);
556 556 }
557 557
558 558 return (DDI_SUCCESS);
559 559 }
560 560
561 561 static void
562 562 av1394_remove_events(av1394_inst_t *avp)
563 563 {
564 564 ddi_eventcookie_t evc;
565 565
566 566 if (ddi_get_eventcookie(avp->av_dip, DDI_DEVI_INSERT_EVENT,
567 567 &evc) == DDI_SUCCESS) {
568 568 (void) ddi_remove_event_handler(avp->av_insert_cb);
569 569 }
570 570
571 571 if (ddi_get_eventcookie(avp->av_dip, DDI_DEVI_REMOVE_EVENT,
572 572 &evc) == DDI_SUCCESS) {
573 573 (void) ddi_remove_event_handler(avp->av_remove_cb);
574 574 }
575 575
576 576 if (ddi_get_eventcookie(avp->av_dip, DDI_DEVI_BUS_RESET_EVENT,
577 577 &evc) == DDI_SUCCESS) {
578 578 (void) ddi_remove_event_handler(avp->av_reset_cb);
579 579 }
580 580 }
581 581
582 582 /*
583 583 *
584 584 * --- CPR
585 585 *
586 586 */
587 587 static int
588 588 av1394_cpr_suspend(av1394_inst_t *avp)
589 589 {
590 590 int ret;
591 591
592 592 AV1394_TNF_ENTER(av1394_cpr_suspend);
593 593
594 594 ret = av1394_isoch_cpr_suspend(avp);
595 595
596 596 if (ret == DDI_SUCCESS) {
597 597 mutex_enter(&avp->av_mutex);
598 598 avp->av_prev_dev_state = avp->av_dev_state;
599 599 avp->av_dev_state = AV1394_DEV_SUSPENDED;
600 600 mutex_exit(&avp->av_mutex);
601 601 }
602 602
603 603 AV1394_TNF_EXIT(av1394_cpr_suspend);
604 604 return (ret);
605 605 }
606 606
607 607 /*
608 608 * CPR resume should always succeed
609 609 */
610 610 static int
611 611 av1394_cpr_resume(av1394_inst_t *avp)
612 612 {
613 613 AV1394_TNF_ENTER(av1394_cpr_resume);
614 614
615 615 mutex_enter(&avp->av_mutex);
616 616 avp->av_dev_state = avp->av_prev_dev_state;
617 617 mutex_exit(&avp->av_mutex);
618 618
619 619 (void) av1394_async_cpr_resume(avp);
620 620
621 621 AV1394_TNF_EXIT(av1394_cpr_resume);
622 622 return (DDI_SUCCESS);
623 623 }
624 624
625 625 /*
626 626 *
627 627 * --- callbacks
628 628 *
629 629 */
630 630 /*ARGSUSED*/
631 631 static void
632 632 av1394_bus_reset(dev_info_t *dip, ddi_eventcookie_t evc, void *arg, void *data)
633 633 {
634 634 av1394_inst_t *avp = arg;
635 635
636 636 AV1394_TNF_ENTER(av1394_bus_reset);
637 637
638 638 if (avp == NULL) {
639 639 AV1394_TNF_EXIT(av1394_bus_reset);
640 640 return;
641 641 }
642 642
643 643 mutex_enter(&avp->av_mutex);
644 644 avp->av_attachinfo.localinfo = *(t1394_localinfo_t *)data;
645 645 mutex_exit(&avp->av_mutex);
646 646
647 647 av1394_async_bus_reset(avp);
648 648 av1394_cmp_bus_reset(avp);
649 649
650 650 AV1394_TNF_EXIT(av1394_bus_reset);
651 651 }
652 652
653 653 /*ARGSUSED*/
654 654 static void
655 655 av1394_disconnect(dev_info_t *dip, ddi_eventcookie_t evc, void *arg, void *data)
656 656 {
657 657 av1394_inst_t *avp = arg;
658 658
659 659 AV1394_TNF_ENTER(av1394_disconnect);
660 660
661 661 if (avp == NULL) {
662 662 AV1394_TNF_EXIT(av1394_disconnect);
663 663 return;
664 664 }
665 665
666 666 mutex_enter(&avp->av_mutex);
667 667 avp->av_dev_state = AV1394_DEV_DISCONNECTED;
668 668 mutex_exit(&avp->av_mutex);
669 669
670 670 AV1394_TNF_EXIT(av1394_disconnect);
671 671 }
672 672
673 673 /*ARGSUSED*/
674 674 static void
675 675 av1394_reconnect(dev_info_t *dip, ddi_eventcookie_t evc, void *arg, void *data)
676 676 {
677 677 av1394_inst_t *avp = arg;
678 678
679 679 AV1394_TNF_ENTER(av1394_disconnect);
680 680
681 681 if (avp == NULL) {
682 682 AV1394_TNF_EXIT(av1394_disconnect);
683 683 return;
684 684 }
685 685
686 686 mutex_enter(&avp->av_mutex);
687 687 avp->av_dev_state = AV1394_DEV_ONLINE;
688 688 avp->av_attachinfo.localinfo = *(t1394_localinfo_t *)data;
689 689 mutex_exit(&avp->av_mutex);
690 690
691 691 av1394_async_reconnect(avp);
692 692
693 693 AV1394_TNF_EXIT(av1394_disconnect);
694 694 }
↓ open down ↓ |
566 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX