Lines Matching defs:ugenp

176 	ugen_state_t		*ugenp = kmem_zalloc(sizeof (ugen_state_t),
181 hdl->hdl_ugenp = ugenp;
191 if ((rval = usb_get_dev_data(dip, &ugenp->ug_dev_data,
194 USB_DPRINTF_L2(UGEN_PRINT_ATTA, ugenp->ug_log_hdl,
201 mutex_init(&ugenp->ug_mutex, NULL, MUTEX_DRIVER,
202 ugenp->ug_dev_data->dev_iblock_cookie);
204 mutex_enter(&ugenp->ug_mutex);
205 ugenp->ug_dip = dip;
206 ugenp->ug_instance = ddi_get_instance(dip);
207 ugenp->ug_hdl = hdl;
217 ugenp->ug_log_hdl = usb_alloc_log_hdl(dip, name, &ugen_errlevel,
222 ugenp->ug_log_hdl = usb_alloc_log_hdl(dip, "ugen",
234 mutex_exit(&ugenp->ug_mutex);
247 mutex_exit(&ugenp->ug_mutex);
257 USB_DPRINTF_L4(UGEN_PRINT_ATTA, ugenp->ug_log_hdl,
262 USB_DPRINTF_L4(UGEN_PRINT_ATTA, ugenp->ug_log_hdl,
267 mutex_exit(&ugenp->ug_mutex);
284 ugen_state_t *ugenp = usb_ugen_hdl_impl->hdl_ugenp;
286 if (ugenp) {
287 mutex_destroy(&ugenp->ug_mutex);
288 usb_free_log_hdl(ugenp->ug_log_hdl);
290 ugenp->ug_dev_data);
291 kmem_free(ugenp, sizeof (*ugenp));
310 ugen_state_t *ugenp;
318 ugenp = usb_ugen_hdl_impl->hdl_ugenp;
322 USB_DPRINTF_L4(UGEN_PRINT_ATTA, ugenp->ug_log_hdl,
330 ugen_cpr_resume(ugenp);
340 mutex_enter(&ugenp->ug_mutex);
341 ugenp->ug_ser_cookie =
343 ugenp->ug_cleanup_flags |= UGEN_INIT_LOCKS;
347 &ugenp->ug_max_bulk_xfer_sz) != USB_SUCCESS) {
348 USB_DPRINTF_L2(UGEN_PRINT_ATTA, ugenp->ug_log_hdl,
350 mutex_exit(&ugenp->ug_mutex);
356 ugen_minor_node_table_create(ugenp);
359 if (ugen_ds_init(ugenp) != USB_SUCCESS) {
360 USB_DPRINTF_L2(UGEN_PRINT_ATTA, ugenp->ug_log_hdl,
362 mutex_exit(&ugenp->ug_mutex);
368 if (ugen_epxs_init(ugenp) != USB_SUCCESS) {
369 USB_DPRINTF_L2(UGEN_PRINT_ATTA, ugenp->ug_log_hdl,
371 mutex_exit(&ugenp->ug_mutex);
377 ugen_minor_node_table_shrink(ugenp);
380 ugenp->ug_dev_state = USB_DEV_ONLINE;
382 mutex_exit(&ugenp->ug_mutex);
385 if (ugenp->ug_hdl->hdl_flags & USB_UGEN_ENABLE_PM) {
386 ugen_pm_init(ugenp);
398 mutex_enter(&ugenp->ug_mutex);
399 ugenp->ug_initial_cfgidx = usb_get_current_cfgidx(dip);
400 mutex_exit(&ugenp->ug_mutex);
411 if (ugenp) {
412 USB_DPRINTF_L2(UGEN_PRINT_ATTA, ugenp->ug_log_hdl,
414 (void) ugen_cleanup(ugenp);
432 ugen_state_t *ugenp = usb_ugen_hdl_impl->hdl_ugenp;
434 USB_DPRINTF_L4(UGEN_PRINT_ATTA, ugenp->ug_log_hdl,
439 rval = ugen_cleanup(ugenp);
443 rval = ugen_cpr_suspend(ugenp);
460 ugen_cleanup(ugen_state_t *ugenp)
462 dev_info_t *dip = ugenp->ug_dip;
464 USB_DPRINTF_L4(UGEN_PRINT_ATTA, ugenp->ug_log_hdl, "ugen_cleanup");
466 if (ugenp->ug_cleanup_flags & UGEN_INIT_LOCKS) {
469 ugen_epx_shutdown(ugenp);
482 (void) usb_serialize_access(ugenp->ug_ser_cookie,
484 usb_release_access(ugenp->ug_ser_cookie);
486 mutex_enter(&ugenp->ug_mutex);
487 ASSERT(ugenp->ug_open_count == 0);
488 ASSERT(ugenp->ug_pending_cmds == 0);
491 ugen_pm_destroy(ugenp);
492 ugen_epxs_destroy(ugenp);
493 ugen_ds_destroy(ugenp);
494 ugen_minor_node_table_destroy(ugenp);
499 (ugenp->ug_dev_state != USB_DEV_DISCONNECTED)) {
500 int idx = ugenp->ug_initial_cfgidx;
501 mutex_exit(&ugenp->ug_mutex);
505 mutex_exit(&ugenp->ug_mutex);
508 usb_fini_serialization(ugenp->ug_ser_cookie);
514 ugen_free_devt(ugenp);
524 ugen_cpr_suspend(ugen_state_t *ugenp)
530 USB_DPRINTF_L4(UGEN_PRINT_CPR, ugenp->ug_log_hdl,
533 mutex_enter(&ugenp->ug_mutex);
534 switch (ugenp->ug_dev_state) {
537 USB_DPRINTF_L4(UGEN_PRINT_CPR, ugenp->ug_log_hdl,
540 prev_state = ugenp->ug_dev_state;
541 ugenp->ug_dev_state = USB_DEV_SUSPENDED;
543 if (ugenp->ug_open_count) {
546 if (ugenp->ug_pending_cmds == 0) {
550 mutex_exit(&ugenp->ug_mutex);
552 mutex_enter(&ugenp->ug_mutex);
556 if (ugenp->ug_pending_cmds) {
557 ugenp->ug_dev_state = prev_state;
560 ugenp->ug_log_hdl,
562 ugenp->ug_pending_cmds);
568 mutex_exit(&ugenp->ug_mutex);
569 (void) usb_serialize_access(ugenp->ug_ser_cookie,
572 ugen_epx_shutdown(ugenp);
574 usb_release_access(ugenp->ug_ser_cookie);
576 mutex_enter(&ugenp->ug_mutex);
580 ugen_ds_change(ugenp);
581 ugen_ds_poll_wakeup(ugenp);
592 mutex_exit(&ugenp->ug_mutex);
601 ugen_cpr_resume(ugen_state_t *ugenp)
603 USB_DPRINTF_L4(UGEN_PRINT_CPR, ugenp->ug_log_hdl,
606 ugen_restore_state(ugenp);
617 ugen_state_t *ugenp;
624 ugenp = usb_ugen_hdl_impl->hdl_ugenp;
626 USB_DPRINTF_L4(UGEN_PRINT_HOTPLUG, ugenp->ug_log_hdl,
630 (void) usb_serialize_access(ugenp->ug_ser_cookie, USB_WAIT, 0);
632 mutex_enter(&ugenp->ug_mutex);
633 ugenp->ug_dev_state = USB_DEV_DISCONNECTED;
634 if (ugenp->ug_open_count) {
635 mutex_exit(&ugenp->ug_mutex);
638 (void) ugen_epx_shutdown(ugenp);
640 mutex_enter(&ugenp->ug_mutex);
645 ugen_ds_change(ugenp);
646 ugen_ds_poll_wakeup(ugenp);
648 mutex_exit(&ugenp->ug_mutex);
649 usb_release_access(ugenp->ug_ser_cookie);
663 ugen_state_t *ugenp = usb_ugen_hdl_impl->hdl_ugenp;
665 USB_DPRINTF_L4(UGEN_PRINT_HOTPLUG, ugenp->ug_log_hdl,
668 ugen_restore_state(ugenp);
682 ugen_restore_state(ugen_state_t *ugenp)
684 dev_info_t *dip = ugenp->ug_dip;
686 USB_DPRINTF_L4(UGEN_PRINT_HOTPLUG, ugenp->ug_log_hdl,
690 if (ugenp->ug_hdl->hdl_flags & USB_UGEN_ENABLE_PM) {
691 ugen_pm_busy_component(ugenp);
696 if (usb_check_same_device(dip, ugenp->ug_log_hdl,
699 mutex_enter(&ugenp->ug_mutex);
700 ugenp->ug_dev_state = USB_DEV_DISCONNECTED;
703 ugen_ds_change(ugenp);
704 ugen_ds_poll_wakeup(ugenp);
706 mutex_exit(&ugenp->ug_mutex);
708 if (ugenp->ug_hdl->hdl_flags & USB_UGEN_ENABLE_PM) {
709 ugen_pm_idle_component(ugenp);
719 (void) usb_serialize_access(ugenp->ug_ser_cookie, USB_WAIT, 0);
721 mutex_enter(&ugenp->ug_mutex);
722 switch (ugenp->ug_dev_state) {
724 ugenp->ug_dev_state = (ugenp->ug_open_count == 0) ?
729 ugenp->ug_dev_state = (ugenp->ug_open_count == 0) ?
734 USB_DPRINTF_L4(UGEN_PRINT_HOTPLUG, ugenp->ug_log_hdl,
736 ugenp->ug_dev_state, ugenp->ug_open_count);
739 ugen_ds_change(ugenp);
740 ugen_ds_poll_wakeup(ugenp);
742 mutex_exit(&ugenp->ug_mutex);
743 usb_release_access(ugenp->ug_ser_cookie);
745 if (ugenp->ug_hdl->hdl_flags & USB_UGEN_ENABLE_PM) {
746 ugen_pm_idle_component(ugenp);
761 ugen_state_t *ugenp;
770 ugenp = usb_ugen_hdl_impl->hdl_ugenp;
772 if (ugen_is_valid_minor_node(ugenp, *devp) != USB_SUCCESS) {
777 minor_node_type = UGEN_MINOR_TYPE(ugenp, *devp);
779 USB_DPRINTF_L4(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
781 USB_DPRINTF_L3(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
784 UGEN_MINOR_CFGVAL(ugenp, *devp), UGEN_MINOR_CFGIDX(ugenp, *devp),
785 UGEN_MINOR_IF(ugenp, *devp), UGEN_MINOR_ALT(ugenp, *devp),
786 UGEN_MINOR_EPIDX(ugenp, *devp), UGEN_MINOR_TYPE(ugenp, *devp));
789 if ((rval = ugen_check_open_flags(ugenp, *devp, flag)) != 0) {
790 USB_DPRINTF_L2(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
797 if (usb_serialize_access(ugenp->ug_ser_cookie,
799 USB_DPRINTF_L2(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
805 mutex_enter(&ugenp->ug_mutex);
811 switch (ugenp->ug_dev_state) {
817 mutex_exit(&ugenp->ug_mutex);
825 mutex_exit(&ugenp->ug_mutex);
830 mutex_exit(&ugenp->ug_mutex);
835 if (ugenp->ug_hdl->hdl_flags & USB_UGEN_ENABLE_PM) {
836 ugen_pm_busy_component(ugenp);
837 (void) pm_raise_power(ugenp->ug_dip, 0,
841 rval = ugen_epx_open(ugenp, *devp, flag);
843 mutex_enter(&ugenp->ug_mutex);
844 ugenp->ug_open_count++;
845 mutex_exit(&ugenp->ug_mutex);
847 if (ugenp->ug_hdl->hdl_flags &
849 ugen_pm_idle_component(ugenp);
855 rval = ugen_eps_open(ugenp, *devp, flag);
857 mutex_enter(&ugenp->ug_mutex);
858 ugenp->ug_open_count++;
859 mutex_exit(&ugenp->ug_mutex);
864 rval = ugen_ds_open(ugenp, *devp, flag);
873 mutex_enter(&ugenp->ug_mutex);
875 USB_DPRINTF_L4(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
877 getminor(*devp), rval, ugenp->ug_dev_state,
878 ugenp->ug_open_count);
880 mutex_exit(&ugenp->ug_mutex);
882 usb_release_access(ugenp->ug_ser_cookie);
898 ugen_state_t *ugenp;
906 ugenp = usb_ugen_hdl_impl->hdl_ugenp;
907 if (ugen_is_valid_minor_node(ugenp, dev) != USB_SUCCESS) {
912 minor_node_type = UGEN_MINOR_TYPE(ugenp, dev);
914 USB_DPRINTF_L4(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
918 if (usb_serialize_access(ugenp->ug_ser_cookie,
920 USB_DPRINTF_L4(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
929 ugen_epx_close(ugenp, dev, flag);
930 if (ugenp->ug_hdl->hdl_flags & USB_UGEN_ENABLE_PM) {
931 ugen_pm_idle_component(ugenp);
936 ugen_eps_close(ugenp, dev, flag);
940 ugen_ds_close(ugenp, dev, flag);
944 usb_release_access(ugenp->ug_ser_cookie);
949 mutex_enter(&ugenp->ug_mutex);
951 ASSERT(ugenp->ug_open_count > 0);
952 if ((--ugenp->ug_open_count == 0) &&
953 ((ugenp->ug_dev_state == USB_UGEN_DEV_UNAVAILABLE_RESUME) ||
954 (ugenp->ug_dev_state ==
956 ugenp->ug_dev_state = USB_DEV_ONLINE;
959 ugen_ds_change(ugenp);
960 ugen_ds_poll_wakeup(ugenp);
964 USB_DPRINTF_L4(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
966 getminor(dev), ugenp->ug_dev_state, ugenp->ug_open_count);
968 if (ugenp->ug_open_count == 0) {
969 ASSERT(ugen_epxs_check_open_nodes(ugenp) == USB_FAILURE);
972 mutex_exit(&ugenp->ug_mutex);
974 usb_release_access(ugenp->ug_ser_cookie);
988 ugen_state_t *ugenp;
996 ugenp = usb_ugen_hdl_impl->hdl_ugenp;
998 if (ugen_is_valid_minor_node(ugenp, dev) != USB_SUCCESS) {
1013 ugen_state_t *ugenp;
1021 ugenp = usb_ugen_hdl_impl->hdl_ugenp;
1023 if (ugen_is_valid_minor_node(ugenp, dev) != USB_SUCCESS) {
1042 ugen_state_t *ugenp;
1052 ugenp = usb_ugen_hdl_impl->hdl_ugenp;
1053 if (ugen_is_valid_minor_node(ugenp, dev) != USB_SUCCESS) {
1058 minor_node_type = UGEN_MINOR_TYPE(ugenp, dev);
1059 ep_index = UGEN_MINOR_EPIDX(ugenp, dev);
1060 epp = &ugenp->ug_ep[ep_index];
1062 mutex_enter(&ugenp->ug_mutex);
1064 USB_DPRINTF_L4(UGEN_PRINT_POLL, ugenp->ug_log_hdl,
1069 ugenp->ug_ds.dev_stat, ugenp->ug_ds.dev_state);
1073 if (ugenp->ug_dev_state == USB_DEV_ONLINE) {
1128 if (ugenp->ug_ds.dev_stat & UGEN_DEV_STATUS_CHANGED)
1132 *phpp = &ugenp->ug_ds.dev_pollhead;
1133 ugenp->ug_ds.dev_stat |=
1145 if (ugenp->ug_ds.dev_stat & UGEN_DEV_STATUS_CHANGED)
1149 *phpp = &ugenp->ug_ds.dev_pollhead;
1150 ugenp->ug_ds.dev_stat |=
1155 mutex_exit(&ugenp->ug_mutex);
1157 USB_DPRINTF_L4(UGEN_PRINT_POLL, ugenp->ug_log_hdl,
1172 ugen_state_t *ugenp = ugen_devt2state(dev);
1173 int minor_node_type = UGEN_MINOR_TYPE(ugenp, dev);
1175 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1178 if (ugen_is_valid_minor_node(ugenp, dev) != USB_SUCCESS) {
1183 mutex_enter(&ugenp->ug_mutex);
1184 ugenp->ug_pending_cmds++;
1185 mutex_exit(&ugenp->ug_mutex);
1191 rval = ugen_epx_req(ugenp, bp);
1195 rval = ugen_eps_req(ugenp, bp);
1199 rval = ugen_ds_req(ugenp, bp);
1208 mutex_enter(&ugenp->ug_mutex);
1209 ugenp->ug_pending_cmds--;
1211 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1215 getminor(dev), rval, ugenp->ug_pending_cmds);
1217 mutex_exit(&ugenp->ug_mutex);
1238 ugen_state_t *ugenp = ugen_devt2state(dev);
1239 int minor_node_type = UGEN_MINOR_TYPE(ugenp, dev);
1240 uint_t ep_index = UGEN_MINOR_EPIDX(ugenp, dev);
1241 ugen_ep_t *epp = &ugenp->ug_ep[ep_index];
1243 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1251 if (bp->b_bcount > ugenp->ug_max_bulk_xfer_sz) {
1252 bp->b_bcount = ugenp->ug_max_bulk_xfer_sz;
1277 ugen_get_ep_descr(ugen_state_t *ugenp, dev_t dev, uint8_t *bmAttr,
1280 uint_t alt = UGEN_MINOR_ALT(ugenp, dev);
1281 uint_t ifc = UGEN_MINOR_IF(ugenp, dev);
1282 uint_t cfgidx = UGEN_MINOR_CFGIDX(ugenp, dev);
1288 int epidx = UGEN_MINOR_EPIDX(ugenp, dev);
1290 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1294 dev_cfg = &ugenp->ug_dev_data->dev_cfg[cfgidx];
1317 ugen_check_open_flags(ugen_state_t *ugenp, dev_t dev, int flag)
1320 int minor_node_type = UGEN_MINOR_TYPE(ugenp, dev);
1325 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1328 dev, minor_node_type, flag, UGEN_MINOR_EPIDX(ugenp, dev));
1332 epp = &ugenp->ug_ep[UGEN_MINOR_EPIDX(ugenp, dev)];
1343 if (UGEN_MINOR_EPIDX(ugenp, dev) != 0) {
1344 if ((rval = ugen_get_ep_descr(ugenp, dev, &bmAttribute,
1347 ugenp->ug_log_hdl, "ugen_get_descr: fail");
1356 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1428 ugen_epxs_init(ugen_state_t *ugenp)
1430 usb_cfg_data_t *dev_cfg = ugenp->ug_dev_data->dev_cfg;
1436 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1441 mutex_init(&ugenp->ug_ep[ep].ep_mutex, NULL, MUTEX_DRIVER,
1442 ugenp->ug_dev_data->dev_iblock_cookie);
1446 if (ugen_epxs_data_init(ugenp, NULL, 0, 0,
1447 ugenp->ug_dev_data->dev_curr_if, 0) != USB_SUCCESS) {
1448 USB_DPRINTF_L2(UGEN_PRINT_ATTA, ugenp->ug_log_hdl,
1458 for (cfgidx = 0; cfgidx < ugenp->ug_dev_data->dev_n_cfg; cfgidx++) {
1459 dev_cfg = &ugenp->ug_dev_data->dev_cfg[cfgidx];
1468 if (ugen_epxs_data_init(ugenp, ep_data,
1487 ugen_epxs_data_init(ugen_state_t *ugenp, usb_ep_data_t *ep_data,
1497 epp = &ugenp->ug_ep[ep_index];
1499 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1508 ugenp->ug_dev_data->dev_iblock_cookie);
1524 ugenp->ug_dip, 0);
1531 return (ugen_epxs_minor_nodes_create(ugenp, ep_descr,
1540 ugen_epxs_destroy(ugen_state_t *ugenp)
1545 ugen_epxs_data_destroy(ugenp, &ugenp->ug_ep[i]);
1551 ugen_epxs_data_destroy(ugen_state_t *ugenp, ugen_ep_t *epp)
1557 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1579 ugen_epxs_minor_nodes_create(ugen_state_t *ugenp, usb_ep_descr_t *ep_descr,
1583 int vid = ugenp->ug_dev_data->dev_descr->idVendor;
1584 int pid = ugenp->ug_dev_data->dev_descr->idProduct;
1588 int owns_device = (usb_owns_device(ugenp->ug_dip) ?
1599 USB_DPRINTF_L4(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
1604 if (ugenp->ug_instance >= UGEN_MINOR_INSTANCE_LIMIT(ugenp)) {
1605 USB_DPRINTF_L0(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
1606 "instance number too high (%d)", ugenp->ug_instance);
1620 minor_index = ugen_minor_index_create(ugenp, minor_code);
1622 USB_DPRINTF_L1(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
1630 minor = (minor_index << UGEN_MINOR_IDX_SHIFT(ugenp)) |
1631 ugenp->ug_instance << UGEN_MINOR_INSTANCE_SHIFT(ugenp);
1661 USB_DPRINTF_L3(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
1667 if ((ddi_create_minor_node(ugenp->ug_dip, node_name,
1673 ugen_store_devt(ugenp, minor);
1676 minor_index = ugen_minor_index_create(ugenp, minor_code);
1678 USB_DPRINTF_L1(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
1687 minor = (minor_index << UGEN_MINOR_IDX_SHIFT(ugenp)) |
1688 ugenp->ug_instance << UGEN_MINOR_INSTANCE_SHIFT(ugenp);
1692 USB_DPRINTF_L3(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
1698 if ((ddi_create_minor_node(ugenp->ug_dip, node_name,
1704 ugen_store_devt(ugenp, minor);
1714 ugen_epx_shutdown(ugen_state_t *ugenp)
1718 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1722 ugen_ep_t *epp = &ugenp->ug_ep[i];
1728 (void) ugen_epx_close_pipe(ugenp, epp);
1741 ugen_cfgval2idx(ugen_state_t *ugenp, uint_t cfgval)
1743 usb_cfg_data_t *dev_cfg = ugenp->ug_dev_data->dev_cfg;
1746 for (cfgidx = 0; cfgidx < ugenp->ug_dev_data->dev_n_cfg; cfgidx++) {
1747 dev_cfg = &ugenp->ug_dev_data->dev_cfg[cfgidx];
1754 ASSERT(cfgidx < ugenp->ug_dev_data->dev_n_cfg);
1764 ugen_epxs_check_open_nodes(ugen_state_t *ugenp)
1769 ugen_ep_t *epp = &ugenp->ug_ep[i];
1773 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1793 ugen_epxs_check_alt_switch(ugen_state_t *ugenp, uchar_t iface, uchar_t cfgidx)
1798 ugen_ep_t *epp = &ugenp->ug_ep[i];
1802 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1830 ugen_epxs_switch_cfg_alt(ugen_state_t *ugenp, ugen_ep_t *epp, dev_t dev)
1834 uint_t new_alt = UGEN_MINOR_ALT(ugenp, dev);
1835 uint_t new_if = UGEN_MINOR_IF(ugenp, dev);
1837 uint_t new_cfgidx = UGEN_MINOR_CFGIDX(ugenp, dev);
1842 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1845 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1851 (ugenp->ug_dev_data->dev_n_cfg == 1) &&
1852 (ugenp->ug_dev_data->dev_cfg[0].cfg_n_if == 1) &&
1853 (ugenp->ug_dev_data->
1855 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
1857 ugenp->ug_dev_data->dev_n_cfg,
1858 ugenp->ug_dev_data->
1875 if ((ugenp->ug_dev_data->dev_n_cfg > 1) &&
1876 usb_get_cfg(ugenp->ug_dip, &cfgval,
1881 cur_cfgidx = ugen_cfgval2idx(ugenp, cfgval);
1890 if (ugen_epxs_check_open_nodes(ugenp) ==
1902 if ((rval = usb_set_cfg(ugenp->ug_dip,
1906 ugenp->ug_log_hdl,
1909 UGEN_MINOR_CFGIDX(ugenp, dev), rval);
1931 ((ugenp->ug_dev_data->dev_cfg[new_cfgidx].
1933 (usb_get_alt_if(ugenp->ug_dip, new_if, &alt,
1936 if (ugen_epxs_check_alt_switch(ugenp, cur_if,
1942 if ((rval = usb_set_alt_if(ugenp->ug_dip, new_if,
1946 ugenp->ug_log_hdl,
1958 ugen_update_ep_descr(ugenp, epp);
1969 ugen_update_ep_descr(ugen_state_t *ugenp, ugen_ep_t *epp)
1971 usb_cfg_data_t *dev_cfg = ugenp->ug_dev_data->dev_cfg;
1977 dev_cfg = &ugenp->ug_dev_data->dev_cfg[epp->ep_cfgidx];
2002 ugen_epx_open(ugen_state_t *ugenp, dev_t dev, int flag)
2004 ugen_ep_t *epp = &ugenp->ug_ep[UGEN_MINOR_EPIDX(ugenp, dev)];
2009 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2021 if ((rval = ugen_epxs_switch_cfg_alt(ugenp, epp, dev)) ==
2023 rval = ugen_epx_open_pipe(ugenp, epp, flag);
2026 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2042 ugen_epx_close(ugen_state_t *ugenp, dev_t dev, int flag)
2044 ugen_ep_t *epp = &ugenp->ug_ep[UGEN_MINOR_EPIDX(ugenp, dev)];
2047 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2052 ugen_epx_close_pipe(ugenp, epp);
2055 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2070 ugen_epx_open_pipe(ugen_state_t *ugenp, ugen_ep_t *epp, int flag)
2074 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2083 epp->ep_ph = ugenp->ug_dev_data->dev_default_ph;
2088 rval = usb_pipe_open(ugenp->ug_dip,
2106 ugenp, epp)) != USB_SUCCESS) {
2109 usb_pipe_close(ugenp->ug_dip,
2178 ugen_epx_close_pipe(ugen_state_t *ugenp, ugen_ep_t *epp)
2180 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2221 if (epp->ep_ph == ugenp->ug_dev_data->dev_default_ph) {
2224 (void) usb_pipe_drain_reqs(ugenp->ug_dip,
2230 usb_pipe_close(ugenp->ug_dip,
2255 ugen_epx_req(ugen_state_t *ugenp, struct buf *bp)
2258 ugen_ep_t *epp = &ugenp->ug_ep[UGEN_MINOR_EPIDX(ugenp, dev)];
2262 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2272 mutex_enter(&ugenp->ug_mutex);
2273 switch (ugenp->ug_dev_state) {
2303 USB_DPRINTF_L3(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2307 mutex_exit(&ugenp->ug_mutex);
2322 rval = ugen_epx_ctrl_req(ugenp, epp, bp, &wait);
2326 rval = ugen_epx_bulk_req(ugenp, epp, bp, &wait);
2331 rval = ugen_epx_intr_IN_req(ugenp, epp, bp, &wait);
2333 rval = ugen_epx_intr_OUT_req(ugenp, epp, bp, &wait);
2339 rval = ugen_epx_isoc_IN_req(ugenp, epp, bp, &wait);
2341 rval = ugen_epx_isoc_OUT_req(ugenp, epp, bp, &wait);
2356 ugenp->ug_log_hdl,
2358 UGEN_MINOR_EPIDX(ugenp, dev));
2365 usb_pipe_reset(ugenp->ug_dip, epp->ep_ph,
2367 (void) usb_pipe_drain_reqs(ugenp->ug_dip,
2381 USB_DPRINTF_L3(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2397 USB_DPRINTF_L3(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2408 ugen_epx_ctrl_req(ugen_state_t *ugenp, ugen_ep_t *epp,
2416 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2448 reqp = usb_alloc_ctrl_req(ugenp->ug_dip, wLength, USB_FLAGS_NOSLEEP);
2466 reqp->ctrl_client_private = (usb_opaque_t)ugenp;
2476 (usb_owns_device(ugenp->ug_dip) == B_FALSE))) {
2550 ugen_state_t *ugenp = (ugen_state_t *)reqp->ctrl_client_private;
2554 epp = &ugenp->ug_ep[0];
2559 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2597 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2606 ugen_epx_bulk_req(ugen_state_t *ugenp, ugen_ep_t *epp,
2610 usb_bulk_req_t *reqp = usb_alloc_bulk_req(ugenp->ug_dip,
2613 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2631 reqp->bulk_client_private = (usb_opaque_t)ugenp;
2668 ugen_state_t *ugenp = (ugen_state_t *)reqp->bulk_client_private;
2671 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2724 ugen_epx_intr_IN_req(ugen_state_t *ugenp, ugen_ep_t *epp,
2730 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2757 if (ugen_epx_intr_IN_start_polling(ugenp,
2802 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2814 ugen_epx_intr_IN_start_polling(ugen_state_t *ugenp, ugen_ep_t *epp)
2829 USB_DPRINTF_L3(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2836 reqp = usb_alloc_intr_req(ugenp->ug_dip, 0,
2838 reqp->intr_client_private = (usb_opaque_t)ugenp;
2858 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2878 ugen_epx_intr_IN_stop_polling(ugen_state_t *ugenp, ugen_ep_t *epp)
2883 USB_DPRINTF_L3(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2899 ugen_epx_intr_IN_poll_wakeup(ugen_state_t *ugenp, ugen_ep_t *epp)
2904 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2921 ugen_state_t *ugenp = (ugen_state_t *)reqp->intr_client_private;
2932 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2945 USB_DPRINTF_L3(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2955 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2960 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2979 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2995 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
2999 ugen_epx_intr_IN_poll_wakeup(ugenp, epp);
3005 ugen_epx_intr_IN_stop_polling(ugenp, epp);
3019 if ((ugen_epx_intr_IN_req(ugenp, epp, epp->ep_bp, &wait) ==
3036 ugen_epx_intr_OUT_req(ugen_state_t *ugenp, ugen_ep_t *epp,
3042 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3046 reqp = usb_alloc_intr_req(ugenp->ug_dip, bp->b_bcount,
3057 reqp->intr_client_private = (usb_opaque_t)ugenp;
3091 ugen_state_t *ugenp = (ugen_state_t *)reqp->intr_client_private;
3094 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3139 ugen_epx_isoc_IN_req(ugen_state_t *ugenp, ugen_ep_t *epp,
3147 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3206 if ((rval = ugen_epx_isoc_IN_start_polling(ugenp,
3259 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3271 ugen_epx_isoc_IN_start_polling(ugen_state_t *ugenp, ugen_ep_t *epp)
3289 USB_DPRINTF_L3(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3300 if ((reqp = usb_alloc_isoc_req(ugenp->ug_dip, n_pkt, pkts_len,
3302 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3310 reqp->isoc_client_private = (usb_opaque_t)ugenp;
3332 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3353 ugen_epx_isoc_IN_stop_polling(ugen_state_t *ugenp, ugen_ep_t *epp)
3357 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3373 ugen_epx_isoc_IN_poll_wakeup(ugen_state_t *ugenp, ugen_ep_t *epp)
3378 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3395 ugen_state_t *ugenp = (ugen_state_t *)reqp->isoc_client_private;
3408 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3419 USB_DPRINTF_L3(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3423 ugen_epx_isoc_IN_stop_polling(ugenp, epp);
3434 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3448 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3469 ugenp->ug_log_hdl,
3480 USB_DPRINTF_L3(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3488 USB_DPRINTF_L3(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3507 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3523 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3528 ugen_epx_isoc_IN_poll_wakeup(ugenp, epp);
3540 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3560 if ((ugen_epx_isoc_IN_req(ugenp, epp, epp->ep_bp, &wait) ==
3577 ugen_epx_isoc_OUT_req(ugen_state_t *ugenp, ugen_ep_t *epp,
3589 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3609 (n_pkt > usb_get_max_pkts_per_isoc_request(ugenp->ug_dip)) ||
3611 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3646 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3668 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3680 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3692 if ((rval = ugen_epx_isoc_IN_start_polling(ugenp,
3702 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3711 USB_DPRINTF_L3(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3722 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3741 reqp = usb_alloc_isoc_req(ugenp->ug_dip, n_pkt, pkts_len,
3751 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3761 reqp->isoc_client_private = (usb_opaque_t)ugenp;
3785 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3795 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3809 ugen_state_t *ugenp = (ugen_state_t *)reqp->isoc_client_private;
3812 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3884 ugen_eps_open(ugen_state_t *ugenp, dev_t dev, int flag)
3886 ugen_ep_t *epp = &ugenp->ug_ep[UGEN_MINOR_EPIDX(ugenp, dev)];
3890 USB_DPRINTF_L4(UGEN_PRINT_STAT, ugenp->ug_log_hdl,
3912 ugen_eps_close(ugen_state_t *ugenp, dev_t dev, int flag)
3914 ugen_ep_t *epp = &ugenp->ug_ep[UGEN_MINOR_EPIDX(ugenp, dev)];
3917 USB_DPRINTF_L4(UGEN_PRINT_STAT, ugenp->ug_log_hdl,
3926 USB_DPRINTF_L4(UGEN_PRINT_STAT, ugenp->ug_log_hdl,
3940 ugen_eps_req(ugen_state_t *ugenp, struct buf *bp)
3942 ugen_ep_t *epp = &ugenp->ug_ep[UGEN_MINOR_EPIDX(ugenp, bp->b_edev)];
3945 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3956 USB_DPRINTF_L3(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3961 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3975 USB_DPRINTF_L2(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
3995 ugen_ds_init(ugen_state_t *ugenp)
3997 cv_init(&ugenp->ug_ds.dev_wait_cv, NULL, CV_DRIVER, NULL);
4000 if (ugen_ds_minor_nodes_create(ugenp) != USB_SUCCESS) {
4001 USB_DPRINTF_L2(UGEN_PRINT_ATTA, ugenp->ug_log_hdl,
4013 ugen_ds_destroy(ugen_state_t *ugenp)
4015 cv_destroy(&ugenp->ug_ds.dev_wait_cv);
4025 ugen_ds_open(ugen_state_t *ugenp, dev_t dev, int flag)
4027 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
4030 mutex_enter(&ugenp->ug_mutex);
4031 if ((ugenp->ug_ds.dev_stat & UGEN_DEV_STATUS_ACTIVE) == 0) {
4035 ugenp->ug_ds.dev_stat |= UGEN_DEV_STATUS_CHANGED |
4037 ugenp->ug_ds.dev_oflag = flag;
4038 mutex_exit(&ugenp->ug_mutex);
4042 mutex_exit(&ugenp->ug_mutex);
4050 ugen_ds_close(ugen_state_t *ugenp, dev_t dev, int flag)
4052 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
4055 mutex_enter(&ugenp->ug_mutex);
4056 ugenp->ug_ds.dev_stat = UGEN_DEV_STATUS_INACTIVE;
4057 mutex_exit(&ugenp->ug_mutex);
4067 ugen_ds_req(ugen_state_t *ugenp, struct buf *bp)
4069 int len = min(sizeof (ugenp->ug_ds.dev_state), bp->b_bcount);
4071 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
4074 mutex_enter(&ugenp->ug_mutex);
4075 if ((ugenp->ug_ds.dev_oflag & (FNDELAY | FNONBLOCK)) == 0) {
4076 while ((ugenp->ug_ds.dev_stat &
4078 if (cv_wait_sig(&ugenp->ug_ds.dev_wait_cv,
4079 &ugenp->ug_mutex) <= 0) {
4080 mutex_exit(&ugenp->ug_mutex);
4085 } else if ((ugenp->ug_ds.dev_stat & UGEN_DEV_STATUS_CHANGED) ==
4088 mutex_exit(&ugenp->ug_mutex);
4093 ugenp->ug_ds.dev_stat &= ~UGEN_DEV_STATUS_CHANGED;
4094 switch (ugenp->ug_dev_state) {
4096 ugenp->ug_ds.dev_state = USB_DEV_STAT_ONLINE;
4100 ugenp->ug_ds.dev_state = USB_DEV_STAT_DISCONNECTED;
4105 ugenp->ug_ds.dev_state = USB_DEV_STAT_RESUMED;
4110 ugenp->ug_ds.dev_state = USB_DEV_STAT_UNAVAILABLE;
4115 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
4117 ugenp->ug_dev_state, ugenp->ug_ds.dev_stat);
4119 bcopy(&ugenp->ug_ds.dev_state, bp->b_un.b_addr, len);
4122 mutex_exit(&ugenp->ug_mutex);
4129 ugen_ds_change(ugen_state_t *ugenp)
4131 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
4134 ugenp->ug_ds.dev_stat |= UGEN_DEV_STATUS_CHANGED;
4135 cv_signal(&ugenp->ug_ds.dev_wait_cv);
4143 ugen_ds_poll_wakeup(ugen_state_t *ugenp)
4145 USB_DPRINTF_L4(UGEN_PRINT_XFER, ugenp->ug_log_hdl,
4148 if (ugenp->ug_ds.dev_stat & UGEN_DEV_STATUS_POLL_PENDING) {
4149 struct pollhead *phpp = &ugenp->ug_ds.dev_pollhead;
4150 ugenp->ug_ds.dev_stat &= ~UGEN_DEV_STATUS_POLL_PENDING;
4151 mutex_exit(&ugenp->ug_mutex);
4153 mutex_enter(&ugenp->ug_mutex);
4162 ugen_ds_minor_nodes_create(ugen_state_t *ugenp)
4165 int vid = ugenp->ug_dev_data->dev_descr->idVendor;
4166 int pid = ugenp->ug_dev_data->dev_descr->idProduct;
4169 int owns_device = (usb_owns_device(ugenp->ug_dip) ?
4172 USB_DPRINTF_L4(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
4174 UGEN_MINOR_IDX_SHIFT(ugenp),
4175 UGEN_MINOR_INSTANCE_SHIFT(ugenp));
4177 if (ugenp->ug_instance >= UGEN_MINOR_INSTANCE_LIMIT(ugenp)) {
4178 USB_DPRINTF_L0(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
4179 "instance number too high (%d)", ugenp->ug_instance);
4189 ugenp->ug_dev_data->dev_curr_if);
4192 minor_index = ugen_minor_index_create(ugenp,
4194 UGEN_MINOR_IDX_SHIFT(ugenp));
4197 USB_DPRINTF_L0(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
4202 minor = (minor_index << UGEN_MINOR_IDX_SHIFT(ugenp)) |
4203 ugenp->ug_instance << UGEN_MINOR_INSTANCE_SHIFT(ugenp);
4205 USB_DPRINTF_L4(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
4211 if ((ddi_create_minor_node(ugenp->ug_dip, node_name,
4217 ugen_store_devt(ugenp, minor);
4277 ugen_minor_index_create(ugen_state_t *ugenp, ugen_minor_t minor)
4282 for (i = 1; i < ugenp->ug_minor_node_table_index; i++) {
4283 if (ugenp->ug_minor_node_table[i] == minor) {
4288 if (ugenp->ug_minor_node_table_index <
4289 (ugenp->ug_minor_node_table_size/sizeof (ugen_minor_t))) {
4290 ugenp->ug_minor_node_table[ugenp->
4293 USB_DPRINTF_L4(UGEN_PRINT_ATTA, ugenp->ug_log_hdl,
4295 ugenp->ug_minor_node_table_index,
4298 return (ugenp->ug_minor_node_table_index++);
4307 ugen_devt2minor(ugen_state_t *ugenp, dev_t dev)
4309 USB_DPRINTF_L4(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
4311 UGEN_MINOR_GET_IDX(ugenp, dev),
4312 ugenp->ug_minor_node_table[UGEN_MINOR_GET_IDX(ugenp, dev)]);
4314 ASSERT(UGEN_MINOR_GET_IDX(ugenp, dev) <
4315 ugenp->ug_minor_node_table_index);
4317 return (ugenp->ug_minor_node_table[UGEN_MINOR_GET_IDX(ugenp, dev)]);
4322 ugen_is_valid_minor_node(ugen_state_t *ugenp, dev_t dev)
4324 int idx = UGEN_MINOR_GET_IDX(ugenp, dev);
4326 if ((idx < ugenp->ug_minor_node_table_index) &&
4331 USB_DPRINTF_L2(UGEN_PRINT_CBOPS, ugenp->ug_log_hdl,
4339 ugen_minor_node_table_create(ugen_state_t *ugenp)
4341 size_t size = sizeof (ugen_minor_t) * UGEN_MINOR_IDX_LIMIT(ugenp);
4344 ugenp->ug_minor_node_table = kmem_zalloc(size, KM_SLEEP);
4345 ugenp->ug_minor_node_table_size = size;
4346 ugenp->ug_minor_node_table_index = 1;
4351 ugen_minor_node_table_shrink(ugen_state_t *ugenp)
4354 if (ugenp->ug_minor_node_table_index < UGEN_MINOR_IDX_LIMIT(ugenp)) {
4356 ugenp->ug_minor_node_table_index;
4359 bcopy(ugenp->ug_minor_node_table, buf, newsize);
4360 kmem_free(ugenp->ug_minor_node_table,
4361 ugenp->ug_minor_node_table_size);
4362 ugenp->ug_minor_node_table = buf;
4363 ugenp->ug_minor_node_table_size = newsize;
4369 ugen_minor_node_table_destroy(ugen_state_t *ugenp)
4371 if (ugenp->ug_minor_node_table) {
4372 kmem_free(ugenp->ug_minor_node_table,
4373 ugenp->ug_minor_node_table_size);
4411 ugen_pm_init(ugen_state_t *ugenp)
4413 dev_info_t *dip = ugenp->ug_dip;
4416 USB_DPRINTF_L4(UGEN_PRINT_PM, ugenp->ug_log_hdl,
4422 mutex_enter(&ugenp->ug_mutex);
4423 ugenp->ug_pm = ugenpm;
4426 mutex_exit(&ugenp->ug_mutex);
4437 ugenp->ug_log_hdl,
4441 mutex_enter(&ugenp->ug_mutex);
4443 mutex_exit(&ugenp->ug_mutex);
4448 ugenp->ug_log_hdl,
4454 ugenp->ug_log_hdl,
4460 ugenp->ug_log_hdl, "ugen_pm_init: "
4464 USB_DPRINTF_L4(UGEN_PRINT_PM, ugenp->ug_log_hdl,
4474 ugen_pm_destroy(ugen_state_t *ugenp)
4476 dev_info_t *dip = ugenp->ug_dip;
4478 USB_DPRINTF_L4(UGEN_PRINT_PM, ugenp->ug_log_hdl,
4481 if (ugenp->ug_pm) {
4482 mutex_exit(&ugenp->ug_mutex);
4483 ugen_pm_busy_component(ugenp);
4484 mutex_enter(&ugenp->ug_mutex);
4486 if ((ugenp->ug_pm->pwr_wakeup_enabled) &&
4487 (ugenp->ug_dev_state != USB_DEV_DISCONNECTED)) {
4490 mutex_exit(&ugenp->ug_mutex);
4496 ugenp->ug_log_hdl, "ugen_pm_destroy: "
4505 mutex_exit(&ugenp->ug_mutex);
4508 ugen_pm_idle_component(ugenp);
4510 mutex_enter(&ugenp->ug_mutex);
4511 kmem_free(ugenp->ug_pm, sizeof (ugen_power_t));
4512 ugenp->ug_pm = NULL;
4530 ugen_state_t *ugenp;
4538 ugenp = usb_ugen_hdl_impl->hdl_ugenp;
4539 dip = ugenp->ug_dip;
4541 if (ugenp->ug_pm == NULL) {
4546 USB_DPRINTF_L4(UGEN_PRINT_PM, ugenp->ug_log_hdl,
4549 (void) usb_serialize_access(ugenp->ug_ser_cookie,
4556 mutex_enter(&ugenp->ug_mutex);
4557 switch (ugenp->ug_dev_state) {
4566 USB_DPRINTF_L2(UGEN_PRINT_PM, ugenp->ug_log_hdl,
4568 "dev_state=%d", ugenp->ug_dev_state);
4574 pm = ugenp->ug_pm;
4578 USB_DPRINTF_L2(UGEN_PRINT_PM, ugenp->ug_log_hdl,
4587 switch (ugenp->ug_dev_state) {
4590 if (ugenp->ug_pm->pwr_busy != 0) {
4594 ASSERT(ugenp->ug_open_count == 0);
4595 ASSERT(ugenp->ug_pending_cmds == 0);
4596 ugenp->ug_pm->pwr_current = USB_DEV_OS_PWR_OFF;
4597 mutex_exit(&ugenp->ug_mutex);
4601 mutex_enter(&ugenp->ug_mutex);
4615 switch (ugenp->ug_dev_state) {
4621 ugenp->ug_dev_state = USB_DEV_ONLINE;
4624 ugen_ds_change(ugenp);
4625 ugen_ds_poll_wakeup(ugenp);
4629 ugenp->ug_pm->pwr_current = USB_DEV_OS_FULL_PWR;
4630 mutex_exit(&ugenp->ug_mutex);
4632 mutex_enter(&ugenp->ug_mutex);
4637 USB_DPRINTF_L2(UGEN_PRINT_PM, ugenp->ug_log_hdl,
4643 mutex_exit(&ugenp->ug_mutex);
4644 usb_release_access(ugenp->ug_ser_cookie);
4705 ugen_store_devt(ugen_state_t *ugenp, minor_t minor)
4712 e->list_dev = makedevice(ddi_driver_major(ugenp->ug_dip), minor);
4713 e->list_state = ugenp;
4737 ugen_state_t *ugenp = NULL;
4746 ugenp = ugen_devt_cache[index].cache_state;
4750 return (ugenp);
4760 ugenp = t->list_state;
4765 ugenp;
4768 return (ugenp);
4774 return (ugenp);
4779 ugen_free_devt(ugen_state_t *ugenp)
4782 major_t major = ddi_driver_major(ugenp->ug_dip);
4783 int instance = ddi_get_instance(ugenp->ug_dip);
4789 ugenp->ug_hdl->hdl_minor_node_instance_mask) >>
4790 ugenp->ug_hdl->hdl_minor_node_instance_shift;