Date: Thu, 22 Apr 2010 22:00:16 +0000 (UTC) From: Andrew Thompson <thompsa@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r207079 - head/sys/dev/usb Message-ID: <201004222200.o3MM0GAQ004103@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: thompsa Date: Thu Apr 22 22:00:16 2010 New Revision: 207079 URL: http://svn.freebsd.org/changeset/base/207079 Log: Properly name the sxlocks, mutexes and condvars. Modified: head/sys/dev/usb/usb_dev.c head/sys/dev/usb/usb_device.c head/sys/dev/usb/usb_device.h head/sys/dev/usb/usb_request.c head/sys/dev/usb/usb_transfer.c Modified: head/sys/dev/usb/usb_dev.c ============================================================================== --- head/sys/dev/usb/usb_dev.c Thu Apr 22 21:41:50 2010 (r207078) +++ head/sys/dev/usb/usb_dev.c Thu Apr 22 22:00:16 2010 (r207079) @@ -284,7 +284,7 @@ error: usbd_enum_unlock(cpd->udev); if (--(cpd->udev->refcount) == 0) { - cv_signal(cpd->udev->default_cv + 1); + cv_signal(&cpd->udev->ref_cv); } } mtx_unlock(&usb_ref_lock); @@ -352,7 +352,7 @@ usb_unref_device(struct usb_cdev_privdat } if (crd->is_uref) { if (--(cpd->udev->refcount) == 0) { - cv_signal(cpd->udev->default_cv + 1); + cv_signal(&cpd->udev->ref_cv); } crd->is_uref = 0; } @@ -500,7 +500,7 @@ usb_fifo_create(struct usb_cdev_privdata /* update some fields */ f->fifo_index = n + USB_FIFO_TX; f->dev_ep_index = e; - f->priv_mtx = udev->default_mtx; + f->priv_mtx = &udev->device_mtx; f->priv_sc0 = ep; f->methods = &usb_ugen_methods; f->iface_index = ep->iface_index; @@ -527,7 +527,7 @@ usb_fifo_create(struct usb_cdev_privdata /* update some fields */ f->fifo_index = n + USB_FIFO_RX; f->dev_ep_index = e; - f->priv_mtx = udev->default_mtx; + f->priv_mtx = &udev->device_mtx; f->priv_sc0 = ep; f->methods = &usb_ugen_methods; f->iface_index = ep->iface_index; Modified: head/sys/dev/usb/usb_device.c ============================================================================== --- head/sys/dev/usb/usb_device.c Thu Apr 22 21:41:50 2010 (r207078) +++ head/sys/dev/usb/usb_device.c Thu Apr 22 22:00:16 2010 (r207079) @@ -655,7 +655,7 @@ usb_config_parse(struct usb_device *udev goto cleanup; if (cmd == USB_CFG_INIT) { - sx_assert(udev->default_sx + 1, SA_LOCKED); + sx_assert(&udev->enum_sx, SA_LOCKED); /* check for in-use endpoints */ @@ -1062,7 +1062,7 @@ usb_detach_device(struct usb_device *ude } DPRINTFN(4, "udev=%p\n", udev); - sx_assert(udev->default_sx + 1, SA_LOCKED); + sx_assert(&udev->enum_sx, SA_LOCKED); /* * First detach the child to give the child's detach routine a @@ -1380,7 +1380,7 @@ usb_suspend_resume(struct usb_device *ud } DPRINTFN(4, "udev=%p do_suspend=%d\n", udev, do_suspend); - sx_assert(udev->default_sx + 1, SA_LOCKED); + sx_assert(&udev->enum_sx, SA_LOCKED); USB_BUS_LOCK(udev->bus); /* filter the suspend events */ @@ -1419,13 +1419,13 @@ usbd_clear_stall_proc(struct usb_proc_ms /* Change lock */ USB_BUS_UNLOCK(udev->bus); - mtx_lock(udev->default_mtx); + mtx_lock(&udev->device_mtx); /* Start clear stall callback */ usbd_transfer_start(udev->default_xfer[1]); /* Change lock */ - mtx_unlock(udev->default_mtx); + mtx_unlock(&udev->device_mtx); USB_BUS_LOCK(udev->bus); } @@ -1491,16 +1491,16 @@ usb_alloc_device(device_t parent_dev, st return (NULL); } /* initialise our SX-lock */ - sx_init_flags(udev->default_sx, "USB device SX lock", SX_DUPOK); + sx_init_flags(&udev->ctrl_sx, "USB device SX lock", SX_DUPOK); /* initialise our SX-lock */ - sx_init_flags(udev->default_sx + 1, "USB config SX lock", SX_DUPOK); + sx_init_flags(&udev->enum_sx, "USB config SX lock", SX_DUPOK); - cv_init(udev->default_cv, "WCTRL"); - cv_init(udev->default_cv + 1, "UGONE"); + cv_init(&udev->ctrlreq_cv, "WCTRL"); + cv_init(&udev->ref_cv, "UGONE"); /* initialise our mutex */ - mtx_init(udev->default_mtx, "USB device mutex", NULL, MTX_DEF); + mtx_init(&udev->device_mtx, "USB device mutex", NULL, MTX_DEF); /* initialise generic clear stall */ udev->cs_msg[0].hdr.pm_callback = &usbd_clear_stall_proc; @@ -2005,7 +2005,7 @@ usb_free_device(struct usb_device *udev, mtx_lock(&usb_ref_lock); udev->refcount--; while (udev->refcount != 0) { - cv_wait(udev->default_cv + 1, &usb_ref_lock); + cv_wait(&udev->ref_cv, &usb_ref_lock); } mtx_unlock(&usb_ref_lock); @@ -2036,13 +2036,13 @@ usb_free_device(struct usb_device *udev, &udev->cs_msg[0], &udev->cs_msg[1]); USB_BUS_UNLOCK(udev->bus); - sx_destroy(udev->default_sx); - sx_destroy(udev->default_sx + 1); + sx_destroy(&udev->ctrl_sx); + sx_destroy(&udev->enum_sx); - cv_destroy(udev->default_cv); - cv_destroy(udev->default_cv + 1); + cv_destroy(&udev->ctrlreq_cv); + cv_destroy(&udev->ref_cv); - mtx_destroy(udev->default_mtx); + mtx_destroy(&udev->device_mtx); #if USB_HAVE_UGEN KASSERT(LIST_FIRST(&udev->pd_list) == NULL, ("leaked cdev entries")); #endif @@ -2588,7 +2588,7 @@ usbd_device_attached(struct usb_device * void usbd_enum_lock(struct usb_device *udev) { - sx_xlock(udev->default_sx + 1); + sx_xlock(&udev->enum_sx); /* * NEWBUS LOCK NOTE: We should check if any parent SX locks * are locked before locking Giant. Else the lock can be @@ -2603,7 +2603,7 @@ void usbd_enum_unlock(struct usb_device *udev) { mtx_unlock(&Giant); - sx_xunlock(udev->default_sx + 1); + sx_xunlock(&udev->enum_sx); } /* @@ -2614,5 +2614,5 @@ usbd_enum_unlock(struct usb_device *udev uint8_t usbd_enum_is_locked(struct usb_device *udev) { - return (sx_xlocked(udev->default_sx + 1)); + return (sx_xlocked(&udev->enum_sx)); } Modified: head/sys/dev/usb/usb_device.h ============================================================================== --- head/sys/dev/usb/usb_device.h Thu Apr 22 21:41:50 2010 (r207078) +++ head/sys/dev/usb/usb_device.h Thu Apr 22 22:00:16 2010 (r207079) @@ -113,9 +113,11 @@ struct usb_power_save { struct usb_device { struct usb_clear_stall_msg cs_msg[2]; /* generic clear stall * messages */ - struct sx default_sx[2]; - struct mtx default_mtx[1]; - struct cv default_cv[2]; + struct sx ctrl_sx; + struct sx enum_sx; + struct mtx device_mtx; + struct cv ctrlreq_cv; + struct cv ref_cv; struct usb_interface *ifaces; struct usb_endpoint default_ep; /* Control Endpoint 0 */ struct usb_endpoint *endpoints; Modified: head/sys/dev/usb/usb_request.c ============================================================================== --- head/sys/dev/usb/usb_request.c Thu Apr 22 21:41:50 2010 (r207078) +++ head/sys/dev/usb/usb_request.c Thu Apr 22 22:00:16 2010 (r207079) @@ -99,7 +99,7 @@ usbd_do_request_callback(struct usb_xfer usbd_transfer_submit(xfer); break; default: - cv_signal(xfer->xroot->udev->default_cv); + cv_signal(&xfer->xroot->udev->ctrlreq_cv); break; } } @@ -319,7 +319,7 @@ usbd_do_request_flags(struct usb_device * is achieved when multiple threads are involved: */ - sx_xlock(udev->default_sx); + sx_xlock(&udev->ctrl_sx); hr_func = usbd_get_hr_func(udev); @@ -457,7 +457,7 @@ usbd_do_request_flags(struct usb_device usbd_transfer_start(xfer); while (usbd_transfer_pending(xfer)) { - cv_wait(udev->default_cv, + cv_wait(&udev->ctrlreq_cv, xfer->xroot->xfer_mtx); } @@ -534,7 +534,7 @@ usbd_do_request_flags(struct usb_device USB_XFER_UNLOCK(xfer); done: - sx_xunlock(udev->default_sx); + sx_xunlock(&udev->ctrl_sx); if (mtx) { mtx_lock(mtx); Modified: head/sys/dev/usb/usb_transfer.c ============================================================================== --- head/sys/dev/usb/usb_transfer.c Thu Apr 22 21:41:50 2010 (r207078) +++ head/sys/dev/usb/usb_transfer.c Thu Apr 22 22:00:16 2010 (r207079) @@ -2821,7 +2821,7 @@ repeat: iface_index = 0; if (usbd_transfer_setup(udev, &iface_index, udev->default_xfer, usb_control_ep_cfg, USB_DEFAULT_XFER_MAX, NULL, - udev->default_mtx)) { + &udev->device_mtx)) { DPRINTFN(0, "could not setup default " "USB transfer\n"); } else {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004222200.o3MM0GAQ004103>