Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 89842ae6 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman
Browse files

USB: fix interface runtime-PM settings



This patch (as1379) reworks the logic for handling USB interface
runtime-PM settings -- hopefully it's right this time!  The problem is
that when a driver is unbound or binding fails, runtime PM for the
interface always gets disabled.  But pm_runtime_disable() nests, so it
shouldn't be called unless the interface was previously enabled for
runtime PM.

Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Reported-by: default avatarRob Duncan <Robert.Duncan@exar.com>
Tested-by: default avatarRob Duncan <Robert.Duncan@exar.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 54b5acf3
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -334,6 +334,7 @@ static int usb_probe_interface(struct device *dev)
	usb_cancel_queued_reset(intf);

	/* Unbound interfaces are always runtime-PM-disabled and -suspended */
	if (driver->supports_autosuspend)
		pm_runtime_disable(dev);
	pm_runtime_set_suspended(dev);

@@ -389,6 +390,7 @@ static int usb_unbind_interface(struct device *dev)
	intf->needs_remote_wakeup = 0;

	/* Unbound interfaces are always runtime-PM-disabled and -suspended */
	if (driver->supports_autosuspend)
		pm_runtime_disable(dev);
	pm_runtime_set_suspended(dev);

@@ -438,14 +440,17 @@ int usb_driver_claim_interface(struct usb_driver *driver,

	iface->condition = USB_INTERFACE_BOUND;

	/* Claimed interfaces are initially inactive (suspended).  They are
	 * runtime-PM-enabled only if the driver has autosuspend support.
	 * They are sensitive to their children's power states.
	/* Claimed interfaces are initially inactive (suspended) and
	 * runtime-PM-enabled, but only if the driver has autosuspend
	 * support.  Otherwise they are marked active, to prevent the
	 * device from being autosuspended, but left disabled.  In either
	 * case they are sensitive to their children's power states.
	 */
	pm_runtime_set_suspended(dev);
	pm_suspend_ignore_children(dev, false);
	if (driver->supports_autosuspend)
		pm_runtime_enable(dev);
	else
		pm_runtime_set_active(dev);

	/* if interface was already added, bind now; else let
	 * the future device_add() bind it, bypassing probe()