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

Commit 0c0382e3 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman
Browse files

[PATCH] USB: Rename hcd->hub_suspend to hcd->bus_suspend



This patch (as580) is perhaps the only result from the long discussion I
had with David about his changes to the root-hub suspend/resume code.  It
renames the hub_suspend and hub_resume methods in struct usb_hcd to
bus_suspend and bus_resume.  These are more descriptive names, since the
methods really do suspend or resume an entire USB bus, and less likely to
be confused with the hub_suspend and hub_resume routines in hub.c.

It also takes David's advice about removing the layer of bus glue, where
those methods are called.  And it implements a related change that David
made to the other HCDs but forgot to put into dummy_hcd.

Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent bb200f6e
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -1433,16 +1433,16 @@ hcd_endpoint_disable (struct usb_device *udev, struct usb_host_endpoint *ep)

#ifdef	CONFIG_PM

static int hcd_hub_suspend (struct usb_bus *bus)
int hcd_bus_suspend (struct usb_bus *bus)
{
	struct usb_hcd		*hcd;
	int			status;

	hcd = container_of (bus, struct usb_hcd, self);
	if (!hcd->driver->hub_suspend)
	if (!hcd->driver->bus_suspend)
		return -ENOENT;
	hcd->state = HC_STATE_QUIESCING;
	status = hcd->driver->hub_suspend (hcd);
	status = hcd->driver->bus_suspend (hcd);
	if (status == 0)
		hcd->state = HC_STATE_SUSPENDED;
	else
@@ -1451,18 +1451,18 @@ static int hcd_hub_suspend (struct usb_bus *bus)
	return status;
}

static int hcd_hub_resume (struct usb_bus *bus)
int hcd_bus_resume (struct usb_bus *bus)
{
	struct usb_hcd		*hcd;
	int			status;

	hcd = container_of (bus, struct usb_hcd, self);
	if (!hcd->driver->hub_resume)
	if (!hcd->driver->bus_resume)
		return -ENOENT;
	if (hcd->state == HC_STATE_RUNNING)
		return 0;
	hcd->state = HC_STATE_RESUMING;
	status = hcd->driver->hub_resume (hcd);
	status = hcd->driver->bus_resume (hcd);
	if (status == 0)
		hcd->state = HC_STATE_RUNNING;
	else {
@@ -1590,10 +1590,6 @@ static struct usb_operations usb_hcd_operations = {
	.buffer_alloc =		hcd_buffer_alloc,
	.buffer_free =		hcd_buffer_free,
	.disable =		hcd_endpoint_disable,
#ifdef	CONFIG_PM
	.hub_suspend =		hcd_hub_suspend,
	.hub_resume =		hcd_hub_resume,
#endif
};

/*-------------------------------------------------------------------------*/
+17 −6
Original line number Diff line number Diff line
@@ -154,10 +154,6 @@ struct usb_operations {

	void (*disable)(struct usb_device *udev,
			struct usb_host_endpoint *ep);

	/* global suspend/resume of bus */
	int (*hub_suspend)(struct usb_bus *);
	int (*hub_resume)(struct usb_bus *);
};

/* each driver provides one of these, and hardware init support */
@@ -212,8 +208,8 @@ struct hc_driver {
	int		(*hub_control) (struct usb_hcd *hcd,
				u16 typeReq, u16 wValue, u16 wIndex,
				char *buf, u16 wLength);
	int		(*hub_suspend)(struct usb_hcd *);
	int		(*hub_resume)(struct usb_hcd *);
	int		(*bus_suspend)(struct usb_hcd *);
	int		(*bus_resume)(struct usb_hcd *);
	int		(*start_port_reset)(struct usb_hcd *, unsigned port_num);
	void		(*hub_irq_enable)(struct usb_hcd *);
		/* Needed only if port-change IRQs are level-triggered */
@@ -379,6 +375,21 @@ extern int usb_find_interface_driver (struct usb_device *dev,

#define usb_endpoint_out(ep_dir)	(!((ep_dir) & USB_DIR_IN))

#ifdef CONFIG_PM
extern int hcd_bus_suspend (struct usb_bus *bus);
extern int hcd_bus_resume (struct usb_bus *bus);
#else
static inline int hcd_bus_suspend(struct usb_bus *bus)
{
	return 0;
}

static inline int hcd_bus_resume (struct usb_bus *bus)
{
	return 0;
}
#endif /* CONFIG_PM */

/*
 * USB device fs stuff
 */
+4 −4
Original line number Diff line number Diff line
@@ -1917,8 +1917,8 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
	/* "global suspend" of the downstream HC-to-USB interface */
	if (!hdev->parent) {
		struct usb_bus	*bus = hdev->bus;
		if (bus && bus->op->hub_suspend) {
			int	status = bus->op->hub_suspend (bus);
		if (bus) {
			int	status = hcd_bus_suspend (bus);

			if (status != 0) {
				dev_dbg(&hdev->dev, "'global' suspend %d\n",
@@ -1943,8 +1943,8 @@ static int hub_resume(struct usb_interface *intf)
	/* "global resume" of the downstream HC-to-USB interface */
	if (!hdev->parent) {
		struct usb_bus	*bus = hdev->bus;
		if (bus && bus->op->hub_resume) {
			status = bus->op->hub_resume (bus);
		if (bus) {
			status = hcd_bus_resume (bus);
			if (status) {
				dev_dbg(&intf->dev, "'global' resume %d\n",
					status);
+4 −18
Original line number Diff line number Diff line
@@ -1751,7 +1751,7 @@ static int dummy_hub_control (
	return retval;
}

static int dummy_hub_suspend (struct usb_hcd *hcd)
static int dummy_bus_suspend (struct usb_hcd *hcd)
{
	struct dummy *dum = hcd_to_dummy (hcd);

@@ -1762,7 +1762,7 @@ static int dummy_hub_suspend (struct usb_hcd *hcd)
	return 0;
}

static int dummy_hub_resume (struct usb_hcd *hcd)
static int dummy_bus_resume (struct usb_hcd *hcd)
{
	struct dummy *dum = hcd_to_dummy (hcd);

@@ -1894,8 +1894,8 @@ static const struct hc_driver dummy_hcd = {

	.hub_status_data = 	dummy_hub_status,
	.hub_control = 		dummy_hub_control,
	.hub_suspend =		dummy_hub_suspend,
	.hub_resume =		dummy_hub_resume,
	.bus_suspend =		dummy_bus_suspend,
	.bus_resume =		dummy_bus_resume,
};

static int dummy_hcd_probe (struct device *dev)
@@ -1936,13 +1936,6 @@ static int dummy_hcd_suspend (struct device *dev, pm_message_t state)
	dev_dbg (dev, "%s\n", __FUNCTION__);
	hcd = dev_get_drvdata (dev);

#ifndef CONFIG_USB_SUSPEND
	/* Otherwise this would never happen */
	usb_lock_device (hcd->self.root_hub);
	dummy_hub_suspend (hcd);
	usb_unlock_device (hcd->self.root_hub);
#endif

	hcd->state = HC_STATE_SUSPENDED;
	return 0;
}
@@ -1955,13 +1948,6 @@ static int dummy_hcd_resume (struct device *dev)
	hcd = dev_get_drvdata (dev);
	hcd->state = HC_STATE_RUNNING;

#ifndef CONFIG_USB_SUSPEND
	/* Otherwise this would never happen */
	usb_lock_device (hcd->self.root_hub);
	dummy_hub_resume (hcd);
	usb_unlock_device (hcd->self.root_hub);
#endif

	usb_hcd_poll_rh_status (hcd);
	return 0;
}
+4 −4
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@

#ifdef	CONFIG_PM

static int ehci_hub_suspend (struct usb_hcd *hcd)
static int ehci_bus_suspend (struct usb_hcd *hcd)
{
	struct ehci_hcd		*ehci = hcd_to_ehci (hcd);
	int			port;
@@ -83,7 +83,7 @@ static int ehci_hub_suspend (struct usb_hcd *hcd)


/* caller has locked the root hub, and should reset/reinit on error */
static int ehci_hub_resume (struct usb_hcd *hcd)
static int ehci_bus_resume (struct usb_hcd *hcd)
{
	struct ehci_hcd		*ehci = hcd_to_ehci (hcd);
	u32			temp;
@@ -159,8 +159,8 @@ static int ehci_hub_resume (struct usb_hcd *hcd)

#else

#define ehci_hub_suspend	NULL
#define ehci_hub_resume		NULL
#define ehci_bus_suspend	NULL
#define ehci_bus_resume		NULL

#endif	/* CONFIG_PM */

Loading