dev->driver = &driver->drvwrap.driver;
usb_set_intfdata(iface, priv);
- mutex_lock_nested(&udev->pm_mutex, udev->level);
+ usb_pm_lock(udev);
iface->condition = USB_INTERFACE_BOUND;
mark_active(iface);
iface->pm_usage_cnt = !(driver->supports_autosuspend);
- mutex_unlock(&udev->pm_mutex);
+ usb_pm_unlock(udev);
/* if interface was already added, bind now; else let
* the future device_add() bind it, bypassing probe()
dev->driver = NULL;
usb_set_intfdata(iface, NULL);
- mutex_lock_nested(&udev->pm_mutex, udev->level);
+ usb_pm_lock(udev);
iface->condition = USB_INTERFACE_UNBOUND;
mark_quiesced(iface);
iface->needs_remote_wakeup = 0;
- mutex_unlock(&udev->pm_mutex);
+ usb_pm_unlock(udev);
}
EXPORT_SYMBOL(usb_driver_release_interface);
#ifdef CONFIG_PM
-/* Caller has locked udev->pm_mutex */
+/* Caller has locked udev's pm_mutex */
static int suspend_device(struct usb_device *udev, pm_message_t msg)
{
struct usb_device_driver *udriver;
return status;
}
-/* Caller has locked udev->pm_mutex */
+/* Caller has locked udev's pm_mutex */
static int resume_device(struct usb_device *udev)
{
struct usb_device_driver *udriver;
return status;
}
-/* Caller has locked intf's usb_device's pm_mutex */
+/* Caller has locked intf's usb_device's pm mutex */
static int suspend_interface(struct usb_interface *intf, pm_message_t msg)
{
struct usb_driver *driver;
/* Propagate the resume up the tree, if necessary */
if (udev->state == USB_STATE_SUSPENDED) {
if (parent) {
- mutex_lock_nested(&parent->pm_mutex, parent->level);
+ usb_pm_lock(parent);
parent->auto_pm = 1;
status = usb_resume_both(parent);
} else {
if (status == 0)
status = resume_device(udev);
if (parent)
- mutex_unlock(&parent->pm_mutex);
+ usb_pm_unlock(parent);
} else {
/* Needed only for setting udev->dev.power.power_state.event
*/
void usb_autosuspend_device(struct usb_device *udev, int dec_usage_cnt)
{
- mutex_lock_nested(&udev->pm_mutex, udev->level);
+ usb_pm_lock(udev);
udev->pm_usage_cnt -= dec_usage_cnt;
if (udev->pm_usage_cnt <= 0)
queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
USB_AUTOSUSPEND_DELAY);
- mutex_unlock(&udev->pm_mutex);
+ usb_pm_unlock(udev);
// dev_dbg(&udev->dev, "%s: cnt %d\n",
// __FUNCTION__, udev->pm_usage_cnt);
}
{
int status;
- mutex_lock_nested(&udev->pm_mutex, udev->level);
+ usb_pm_lock(udev);
udev->pm_usage_cnt += inc_usage_cnt;
udev->auto_pm = 1;
status = usb_resume_both(udev);
if (status != 0)
udev->pm_usage_cnt -= inc_usage_cnt;
- mutex_unlock(&udev->pm_mutex);
+ usb_pm_unlock(udev);
// dev_dbg(&udev->dev, "%s: status %d cnt %d\n",
// __FUNCTION__, status, udev->pm_usage_cnt);
return status;
{
struct usb_device *udev = interface_to_usbdev(intf);
- mutex_lock_nested(&udev->pm_mutex, udev->level);
+ usb_pm_lock(udev);
if (intf->condition != USB_INTERFACE_UNBOUND &&
--intf->pm_usage_cnt <= 0) {
queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
USB_AUTOSUSPEND_DELAY);
}
- mutex_unlock(&udev->pm_mutex);
+ usb_pm_unlock(udev);
// dev_dbg(&intf->dev, "%s: cnt %d\n",
// __FUNCTION__, intf->pm_usage_cnt);
}
struct usb_device *udev = interface_to_usbdev(intf);
int status;
- mutex_lock_nested(&udev->pm_mutex, udev->level);
+ usb_pm_lock(udev);
if (intf->condition == USB_INTERFACE_UNBOUND)
status = -ENODEV;
else {
if (status != 0)
--intf->pm_usage_cnt;
}
- mutex_unlock(&udev->pm_mutex);
+ usb_pm_unlock(udev);
// dev_dbg(&intf->dev, "%s: status %d cnt %d\n",
// __FUNCTION__, status, intf->pm_usage_cnt);
return status;
if (is_usb_device(dev)) {
struct usb_device *udev = to_usb_device(dev);
- mutex_lock_nested(&udev->pm_mutex, udev->level);
+ usb_pm_lock(udev);
udev->auto_pm = 0;
status = usb_suspend_both(udev, message);
- mutex_unlock(&udev->pm_mutex);
+ usb_pm_unlock(udev);
} else
status = 0;
return status;
if (is_usb_device(dev)) {
struct usb_device *udev = to_usb_device(dev);
- mutex_lock_nested(&udev->pm_mutex, udev->level);
+ usb_pm_lock(udev);
udev->auto_pm = 0;
status = usb_resume_both(udev);
- mutex_unlock(&udev->pm_mutex);
+ usb_pm_unlock(udev);
/* Rebind drivers that had no suspend method? */
} else