USB: remove dev->power.power_state
authorAlan Stern <stern@rowland.harvard.edu>
Thu, 6 Mar 2008 22:00:58 +0000 (17:00 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 25 Apr 2008 04:16:41 +0000 (21:16 -0700)
power.power_state is scheduled for removal.  This patch (as1053)
removes all uses of that field from drivers/usb.  Almost all of them
were write-only, the most significant exceptions being sl811-hcd.c and
u132-hcd.c.

Part of this patch was written by Pavel Machek.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: David Brownell <david-b@pacbell.net>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
18 files changed:
drivers/usb/core/driver.c
drivers/usb/core/hcd-pci.c
drivers/usb/core/usb.h
drivers/usb/gadget/dummy_hcd.c
drivers/usb/gadget/omap_udc.c
drivers/usb/host/ehci-dbg.c
drivers/usb/host/ehci-ps3.c
drivers/usb/host/isp116x-hcd.c
drivers/usb/host/ohci-dbg.c
drivers/usb/host/ohci-ep93xx.c
drivers/usb/host/ohci-omap.c
drivers/usb/host/ohci-ps3.c
drivers/usb/host/ohci-pxa27x.c
drivers/usb/host/ohci-sm501.c
drivers/usb/host/r8a66597-hcd.c
drivers/usb/host/sl811-hcd.c
drivers/usb/host/u132-hcd.c
drivers/usb/misc/usbtest.c

index ebccdefcc6f24fde54818da6e07045446a157ec2..2ea333a43d6588676a19cb9b0e9d86dafb2e29e2 100644 (file)
@@ -794,8 +794,6 @@ static int usb_suspend_device(struct usb_device *udev, pm_message_t msg)
 
  done:
        dev_vdbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status);
-       if (status == 0)
-               udev->dev.power.power_state.event = msg.event;
        return status;
 }
 
@@ -824,10 +822,8 @@ static int usb_resume_device(struct usb_device *udev)
 
  done:
        dev_vdbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status);
-       if (status == 0) {
+       if (status == 0)
                udev->autoresume_disabled = 0;
-               udev->dev.power.power_state.event = PM_EVENT_ON;
-       }
        return status;
 }
 
@@ -1180,8 +1176,7 @@ static int usb_resume_both(struct usb_device *udev)
                }
        } else {
 
-               /* Needed for setting udev->dev.power.power_state.event,
-                * for possible debugging message, and for reset_resume. */
+               /* Needed for reset-resume */
                status = usb_resume_device(udev);
        }
 
@@ -1194,7 +1189,8 @@ static int usb_resume_both(struct usb_device *udev)
 
  done:
        dev_vdbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status);
-       udev->reset_resume = 0;
+       if (!status)
+               udev->reset_resume = 0;
        return status;
 }
 
index 84760ddbc3325cba6cfdc8b219c3d70f32e0a5ab..739407bb8492b6e29fa9453dc7d18b672a606716 100644 (file)
@@ -73,7 +73,6 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
        if (pci_enable_device(dev) < 0)
                return -ENODEV;
        dev->current_state = PCI_D0;
-       dev->dev.power.power_state = PMSG_ON;
 
        if (!dev->irq) {
                dev_err(&dev->dev,
@@ -302,8 +301,6 @@ int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message)
 
 done:
        if (retval == 0) {
-               dev->dev.power.power_state = PMSG_SUSPEND;
-
 #ifdef CONFIG_PPC_PMAC
                /* Disable ASIC clocks for USB */
                if (machine_is(powermac)) {
@@ -406,8 +403,6 @@ int usb_hcd_pci_resume(struct pci_dev *dev)
        pci_set_master(dev);
        pci_restore_state(dev);
 
-       dev->dev.power.power_state = PMSG_ON;
-
        clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
 
        if (hcd->driver->resume) {
index 2375194a9d43a7d9a6440f097e951d2f8b27f56d..1bf8ccb9c58dab72f243ff82168fda9cc427f6cc 100644 (file)
@@ -114,13 +114,11 @@ static inline int is_usb_device_driver(struct device_driver *drv)
 static inline void mark_active(struct usb_interface *f)
 {
        f->is_active = 1;
-       f->dev.power.power_state.event = PM_EVENT_ON;
 }
 
 static inline void mark_quiesced(struct usb_interface *f)
 {
        f->is_active = 0;
-       f->dev.power.power_state.event = PM_EVENT_SUSPEND;
 }
 
 static inline int is_active(const struct usb_interface *f)
index cbe44535c0f0a4520af8b004ff84bad0264e1008..e454775c2ff2f884b6323f2a56c051b8e892af52 100644 (file)
@@ -900,7 +900,6 @@ static int dummy_udc_suspend (struct platform_device *pdev, pm_message_t state)
        set_link_state (dum);
        spin_unlock_irq (&dum->lock);
 
-       pdev->dev.power.power_state = state;
        usb_hcd_poll_rh_status (dummy_to_hcd (dum));
        return 0;
 }
@@ -915,7 +914,6 @@ static int dummy_udc_resume (struct platform_device *pdev)
        set_link_state (dum);
        spin_unlock_irq (&dum->lock);
 
-       pdev->dev.power.power_state = PMSG_ON;
        usb_hcd_poll_rh_status (dummy_to_hcd (dum));
        return 0;
 }
index ee1e9a314cd1b07fa08f8460d6bb13364b021984..56277d24f0418c88a06bd8954498359abb6b51b2 100644 (file)
@@ -1265,8 +1265,6 @@ static int can_pullup(struct omap_udc *udc)
 
 static void pullup_enable(struct omap_udc *udc)
 {
-       udc->gadget.dev.parent->power.power_state = PMSG_ON;
-       udc->gadget.dev.power.power_state = PMSG_ON;
        UDC_SYSCON1_REG |= UDC_PULLUP_EN;
        if (!gadget_is_otg(&udc->gadget) && !cpu_is_omap15xx())
                OTG_CTRL_REG |= OTG_BSESSVLD;
@@ -3061,8 +3059,6 @@ static int omap_udc_suspend(struct platform_device *dev, pm_message_t message)
                omap_pullup(&udc->gadget, 0);
        }
 
-       udc->gadget.dev.power.power_state = PMSG_SUSPEND;
-       udc->gadget.dev.parent->power.power_state = PMSG_SUSPEND;
        return 0;
 }
 
index 38eb92e5dc42b6522d62c4af1eeccfeb8576aa4a..4af90df8e7dec7e2aa3ea96a88b8de05de1a9f12 100644 (file)
@@ -670,7 +670,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
 
        spin_lock_irqsave (&ehci->lock, flags);
 
-       if (buf->bus->controller->power.power_state.event) {
+       if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
                size = scnprintf (next, size,
                        "bus %s, device %s (driver " DRIVER_VERSION ")\n"
                        "%s\n"
index bbda58eb881304052be475a0604c682cd87d6041..69782221bcf358edd99607dbcbf843cb5c371ea6 100644 (file)
@@ -125,7 +125,6 @@ static int ps3_ehci_probe(struct ps3_system_bus_device *dev)
                goto fail_irq;
        }
 
-       dev->core.power.power_state = PMSG_ON;
        dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */
 
        hcd = usb_create_hcd(&ps3_ehci_hc_driver, &dev->core, dev->core.bus_id);
index 203a3359a648db28cea4ee6984115b242e9817cc..66d773c726f65b4d4402a9b38614a719b4ffb1ee 100644 (file)
@@ -1442,11 +1442,6 @@ static int isp116x_bus_resume(struct usb_hcd *hcd)
                break;
        case HCCONTROL_USB_OPER:
                spin_unlock_irq(&isp116x->lock);
-               /* Without setting power_state here the
-                  SUSPENDED state won't be removed from
-                  sysfs/usbN/power.state as a response to remote
-                  wakeup. Maybe in the future. */
-               hcd->self.root_hub->dev.power.power_state = PMSG_ON;
                return 0;
        default:
                /* HCCONTROL_USB_RESET: this may happen, when during
@@ -1460,7 +1455,6 @@ static int isp116x_bus_resume(struct usb_hcd *hcd)
                if ((isp116x->rhdesca & RH_A_NDP) == 2)
                        isp116x_hub_control(hcd, SetPortFeature,
                                            USB_PORT_FEAT_POWER, 2, NULL, 0);
-               hcd->self.root_hub->dev.power.power_state = PMSG_ON;
                return 0;
        }
 
@@ -1486,8 +1480,6 @@ static int isp116x_bus_resume(struct usb_hcd *hcd)
        isp116x_write_reg32(isp116x, HCCONTROL,
                            (val & ~HCCONTROL_HCFS) | HCCONTROL_USB_OPER);
        spin_unlock_irq(&isp116x->lock);
-       /* see analogous comment above */
-       hcd->self.root_hub->dev.power.power_state = PMSG_ON;
        hcd->state = HC_STATE_RUNNING;
 
        return 0;
@@ -1663,7 +1655,6 @@ static int __devinit isp116x_probe(struct platform_device *pdev)
 static int isp116x_suspend(struct platform_device *dev, pm_message_t state)
 {
        VDBG("%s: state %x\n", __func__, state.event);
-       dev->dev.power.power_state = state;
        return 0;
 }
 
@@ -1672,8 +1663,7 @@ static int isp116x_suspend(struct platform_device *dev, pm_message_t state)
 */
 static int isp116x_resume(struct platform_device *dev)
 {
-       VDBG("%s:  state %x\n", __func__, dev->power.power_state.event);
-       dev->dev.power.power_state = PMSG_ON;
+       VDBG("%s\n", __func__);
        return 0;
 }
 
index a22c30aa745d69f1a15b3fa85d844a2d768f99ce..e06bfaebec5416d52e1510d472ebc62a219f52ed 100644 (file)
@@ -655,7 +655,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
                hcd->product_desc,
                hcd_name);
 
-       if (bus->controller->power.power_state.event) {
+       if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
                size -= scnprintf (next, size,
                        "SUSPENDED (no register access)\n");
                goto done;
index 156e93a9d0df3f3ee2ee96c7fc29241e9885a05c..40c683f8987de0548f9239fd623d9a036bf2fe64 100644 (file)
@@ -177,7 +177,6 @@ static int ohci_hcd_ep93xx_drv_suspend(struct platform_device *pdev, pm_message_
 
        ep93xx_stop_hc(&pdev->dev);
        hcd->state = HC_STATE_SUSPENDED;
-       pdev->dev.power.power_state = PMSG_SUSPEND;
 
        return 0;
 }
@@ -193,7 +192,6 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev)
        ohci->next_statechange = jiffies;
 
        ep93xx_start_hc(&pdev->dev);
-       pdev->dev.power.power_state = PMSG_ON;
        usb_hcd_resume_root_hub(hcd);
 
        return 0;
index 7bfca1ed1b585e73413fbba86aaf16a5d9c3c42f..2aafa7b6c81fa2292af6cbad5f113eb3f33efac3 100644 (file)
@@ -505,7 +505,6 @@ static int ohci_omap_suspend(struct platform_device *dev, pm_message_t message)
 
        omap_ohci_clock_power(0);
        ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED;
-       dev->dev.power.power_state = PMSG_SUSPEND;
        return 0;
 }
 
@@ -518,7 +517,6 @@ static int ohci_omap_resume(struct platform_device *dev)
        ohci->next_statechange = jiffies;
 
        omap_ohci_clock_power(1);
-       dev->dev.power.power_state = PMSG_ON;
        usb_hcd_resume_root_hub(platform_get_drvdata(dev));
        return 0;
 }
index 01a0caeaa6bcc9345b74131baa03d3acfb956439..c1935ae537f80a90779d6eaea502dd4d02ee267d 100644 (file)
@@ -127,7 +127,6 @@ static int ps3_ohci_probe(struct ps3_system_bus_device *dev)
                goto fail_irq;
        }
 
-       dev->core.power.power_state = PMSG_ON;
        dev->core.dma_mask = &dummy_mask; /* FIXME: for improper usb code */
 
        hcd = usb_create_hcd(&ps3_ohci_hc_driver, &dev->core, dev->core.bus_id);
index 8ad9b3b604b5e0aeb9185281af70649617c7b48d..5d470263eed85e75837cb5623f5428b84404b75b 100644 (file)
@@ -339,7 +339,6 @@ static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_
 
        pxa27x_stop_hc(&pdev->dev);
        hcd->state = HC_STATE_SUSPENDED;
-       pdev->dev.power.power_state = PMSG_SUSPEND;
 
        return 0;
 }
@@ -357,7 +356,6 @@ static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev)
        if ((status = pxa27x_start_hc(&pdev->dev)) < 0)
                return status;
 
-       pdev->dev.power.power_state = PMSG_ON;
        usb_hcd_resume_root_hub(hcd);
 
        return 0;
index 8ffcd3e5f56bb0efaf7bc67026bff491c4807bb0..ab1e366d7790e718da9b75bec531fd75b499c330 100644 (file)
@@ -224,7 +224,6 @@ static int ohci_sm501_suspend(struct platform_device *pdev, pm_message_t msg)
 
        sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 0);
        ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED;
-       dev->power.power_state = PMSG_SUSPEND;
        return 0;
 }
 
@@ -238,7 +237,6 @@ static int ohci_sm501_resume(struct platform_device *pdev)
        ohci->next_statechange = jiffies;
 
        sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1);
-       dev->power.power_state = PMSG_ON;
        usb_hcd_resume_root_hub(platform_get_drvdata(pdev));
        return 0;
 }
index afd4fbe7713cf71c2631c76469e35f697d3a9575..b46ff9a80b6618ce650066ca4b6d9a3aa57bb8a6 100644 (file)
@@ -2107,13 +2107,11 @@ static struct hc_driver r8a66597_hc_driver = {
 #if defined(CONFIG_PM)
 static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state)
 {
-       pdev->dev.power.power_state = state;
        return 0;
 }
 
 static int r8a66597_resume(struct platform_device *pdev)
 {
-       pdev->dev.power.power_state = PMSG_ON;
        return 0;
 }
 #else  /* if defined(CONFIG_PM) */
index 629bca0ebe8f2a56d366009597e770481f9a0770..df256d61e2c6fbd033e9379d67b79b0bd7352692 100644 (file)
@@ -94,12 +94,10 @@ static void port_power(struct sl811 *sl811, int is_on)
 
                sl811->port1 = (1 << USB_PORT_FEAT_POWER);
                sl811->irq_enable = SL11H_INTMASK_INSRMV;
-               hcd->self.controller->power.power_state = PMSG_ON;
        } else {
                sl811->port1 = 0;
                sl811->irq_enable = 0;
                hcd->state = HC_STATE_HALT;
-               hcd->self.controller->power.power_state = PMSG_SUSPEND;
        }
        sl811->ctrl1 = 0;
        sl811_write(sl811, SL11H_IRQ_ENABLE, 0);
@@ -1772,8 +1770,6 @@ sl811h_suspend(struct platform_device *dev, pm_message_t state)
                port_power(sl811, 0);
                break;
        }
-       if (retval == 0)
-               dev->dev.power.power_state = state;
        return retval;
 }
 
@@ -1786,15 +1782,13 @@ sl811h_resume(struct platform_device *dev)
        /* with no "check to see if VBUS is still powered" board hook,
         * let's assume it'd only be powered to enable remote wakeup.
         */
-       if (dev->dev.power.power_state.event == PM_EVENT_SUSPEND
-                       || !device_can_wakeup(&hcd->self.root_hub->dev)) {
+       if (!sl811->port1 || !device_can_wakeup(&hcd->self.root_hub->dev)) {
                sl811->port1 = 0;
                port_power(sl811, 1);
                usb_root_hub_lost_power(hcd->self.root_hub);
                return 0;
        }
 
-       dev->dev.power.power_state = PMSG_ON;
        return sl811h_bus_resume(hcd);
 }
 
index 8e117a795e93768a878bab49c805b4a5410a77e8..6e9b7edff5283dd068b33c3301bc52f2c1c4e01d 100644 (file)
@@ -1534,11 +1534,9 @@ static void u132_power(struct u132 *u132, int is_on)
                 if (u132->power)
                         return;
                 u132->power = 1;
-                hcd->self.controller->power.power_state = PMSG_ON;
         } else {
                 u132->power = 0;
                 hcd->state = HC_STATE_HALT;
-                hcd->self.controller->power.power_state = PMSG_SUSPEND;
         }
 }
 
@@ -3227,8 +3225,6 @@ static int u132_suspend(struct platform_device *pdev, pm_message_t state)
                         }
                        break;
                }
-                if (retval == 0)
-                        pdev->dev.power.power_state = state;
                 return retval;
         }
 }
@@ -3246,14 +3242,13 @@ static int u132_resume(struct platform_device *pdev)
                 return -ESHUTDOWN;
         } else {
                 int retval = 0;
-                if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
+               if (!u132->port[0].power) {
                         int ports = MAX_U132_PORTS;
                         while (ports-- > 0) {
                                 port_power(u132, ports, 1);
                         }
                         retval = 0;
                 } else {
-                        pdev->dev.power.power_state = PMSG_ON;
                         retval = u132_bus_resume(hcd);
                 }
                 return retval;
index 17100471e461fcf1637a6eaeda531f19eb011974..2c4fd4d6df955ad43cb7f87cc45f68bee487a6df 100644 (file)
@@ -1564,7 +1564,8 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
        if (mutex_lock_interruptible(&dev->lock))
                return -ERESTARTSYS;
 
-       if (intf->dev.power.power_state.event != PM_EVENT_ON) {
+       /* FIXME: What if a system sleep starts while a test is running? */
+       if (!intf->is_active) {
                mutex_unlock(&dev->lock);
                return -EHOSTUNREACH;
        }