From: Pavel Machek <pavel@suse.cz>

This fixes (part of) u32 vs.  pm_message_t confusion in USB.  It should cause
no code changes.

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/usb/core/hcd-pci.c    |   16 ++++++++--------
 25-akpm/drivers/usb/core/hcd.h        |    4 ++--
 25-akpm/drivers/usb/core/hub.c        |    4 ++--
 25-akpm/drivers/usb/core/usb.c        |    2 +-
 25-akpm/drivers/usb/host/ehci-hcd.c   |    2 +-
 25-akpm/drivers/usb/host/ohci-pci.c   |    2 +-
 25-akpm/drivers/usb/host/sl811-hcd.c  |    6 +++---
 25-akpm/drivers/usb/host/uhci-hcd.c   |    2 +-
 25-akpm/drivers/usb/input/hid-core.c  |    4 ++--
 25-akpm/drivers/video/aty/radeon_pm.c |    2 +-
 25-akpm/include/linux/usb.h           |    4 ++--
 drivers/usb/net/pegasus.c             |    0 
 12 files changed, 24 insertions(+), 24 deletions(-)

diff -puN drivers/usb/core/hcd.h~fix-u32-vs-pm_message_t-in-usb drivers/usb/core/hcd.h
--- 25/drivers/usb/core/hcd.h~fix-u32-vs-pm_message_t-in-usb	2005-03-20 16:57:42.000000000 -0800
+++ 25-akpm/drivers/usb/core/hcd.h	2005-03-20 16:57:42.000000000 -0800
@@ -175,7 +175,7 @@ struct hc_driver {
 	 * a whole, not just the root hub; they're for bus glue.
 	 */
 	/* called after all devices were suspended */
-	int	(*suspend) (struct usb_hcd *hcd, u32 state);
+	int	(*suspend) (struct usb_hcd *hcd, pm_message_t state);
 
 	/* called before any devices get resumed */
 	int	(*resume) (struct usb_hcd *hcd);
@@ -224,7 +224,7 @@ extern int usb_hcd_pci_probe (struct pci
 extern void usb_hcd_pci_remove (struct pci_dev *dev);
 
 #ifdef CONFIG_PM
-extern int usb_hcd_pci_suspend (struct pci_dev *dev, u32 state);
+extern int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t state);
 extern int usb_hcd_pci_resume (struct pci_dev *dev);
 #endif /* CONFIG_PM */
 
diff -puN drivers/usb/core/hcd-pci.c~fix-u32-vs-pm_message_t-in-usb drivers/usb/core/hcd-pci.c
--- 25/drivers/usb/core/hcd-pci.c~fix-u32-vs-pm_message_t-in-usb	2005-03-20 16:57:42.000000000 -0800
+++ 25-akpm/drivers/usb/core/hcd-pci.c	2005-03-20 16:57:42.000000000 -0800
@@ -205,11 +205,12 @@ static char __attribute_used__ *pci_stat
  *
  * Store this function in the HCD's struct pci_driver as suspend().
  */
-int usb_hcd_pci_suspend (struct pci_dev *dev, u32 state)
+int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t pmsg)
 {
 	struct usb_hcd		*hcd;
 	int			retval = 0;
 	int			has_pci_pm;
+	pci_power_t		state;
 
 	hcd = pci_get_drvdata(dev);
 
@@ -218,8 +219,10 @@ int usb_hcd_pci_suspend (struct pci_dev 
 	 * PM-sensitive HCDs may already have done this.
 	 */
 	has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM);
-	if (state > 4)
-		state = 4;
+
+	state = pci_choose_state(dev, pmsg);
+	if (state > PCI_D3cold)
+		state = PCI_D3cold;
 
 	switch (hcd->state) {
 
@@ -228,7 +231,7 @@ int usb_hcd_pci_suspend (struct pci_dev 
 	 */
 	case USB_STATE_RUNNING:
 		hcd->state = USB_STATE_QUIESCING;
-		retval = hcd->driver->suspend (hcd, state);
+		retval = hcd->driver->suspend (hcd, pmsg);
 		if (retval) {
 			dev_dbg (hcd->self.controller, 
 					"suspend fail, retval %d\n",
@@ -291,9 +294,6 @@ int usb_hcd_pci_suspend (struct pci_dev 
 		break;
 	}
 
-	/* update power_state **ONLY** to make sysfs happier */
-	if (retval == 0)
-		dev->dev.power.power_state = state;
 	return retval;
 }
 EXPORT_SYMBOL (usb_hcd_pci_suspend);
@@ -327,7 +327,7 @@ int usb_hcd_pci_resume (struct pci_dev *
 
 	if (has_pci_pm)
 		pci_set_power_state (dev, 0);
-	dev->dev.power.power_state = 0;
+	dev->dev.power.power_state = PMSG_ON;
 	retval = request_irq (dev->irq, usb_hcd_irq, SA_SHIRQ,
 				hcd->driver->description, hcd);
 	if (retval < 0) {
diff -puN drivers/usb/core/hub.c~fix-u32-vs-pm_message_t-in-usb drivers/usb/core/hub.c
--- 25/drivers/usb/core/hub.c~fix-u32-vs-pm_message_t-in-usb	2005-03-20 16:57:42.000000000 -0800
+++ 25-akpm/drivers/usb/core/hub.c	2005-03-20 16:57:42.000000000 -0800
@@ -1647,7 +1647,7 @@ static int __usb_suspend_device (struct 
  *
  * Returns 0 on success, else negative errno.
  */
-int usb_suspend_device(struct usb_device *udev, u32 state)
+int usb_suspend_device(struct usb_device *udev, pm_message_t state)
 {
 	int	port1, status;
 
@@ -1962,7 +1962,7 @@ static int hub_resume(struct usb_interfa
 
 #else	/* !CONFIG_USB_SUSPEND */
 
-int usb_suspend_device(struct usb_device *udev, u32 state)
+int usb_suspend_device(struct usb_device *udev, pm_message_t state)
 {
 	return 0;
 }
diff -puN drivers/usb/core/usb.c~fix-u32-vs-pm_message_t-in-usb drivers/usb/core/usb.c
--- 25/drivers/usb/core/usb.c~fix-u32-vs-pm_message_t-in-usb	2005-03-20 16:57:42.000000000 -0800
+++ 25-akpm/drivers/usb/core/usb.c	2005-03-20 16:57:42.000000000 -0800
@@ -1355,7 +1355,7 @@ void usb_buffer_unmap_sg (struct usb_dev
 			usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
 }
 
-static int usb_generic_suspend(struct device *dev, u32 state)
+static int usb_generic_suspend(struct device *dev, pm_message_t state)
 {
 	struct usb_interface *intf;
 	struct usb_driver *driver;
diff -puN drivers/usb/host/ehci-hcd.c~fix-u32-vs-pm_message_t-in-usb drivers/usb/host/ehci-hcd.c
--- 25/drivers/usb/host/ehci-hcd.c~fix-u32-vs-pm_message_t-in-usb	2005-03-20 16:57:42.000000000 -0800
+++ 25-akpm/drivers/usb/host/ehci-hcd.c	2005-03-20 16:57:42.000000000 -0800
@@ -721,7 +721,7 @@ static int ehci_get_frame (struct usb_hc
  * the right sort of wakeup.  
  */
 
-static int ehci_suspend (struct usb_hcd *hcd, u32 state)
+static int ehci_suspend (struct usb_hcd *hcd, pm_message_t state)
 {
 	struct ehci_hcd		*ehci = hcd_to_ehci (hcd);
 
diff -puN drivers/usb/host/ohci-pci.c~fix-u32-vs-pm_message_t-in-usb drivers/usb/host/ohci-pci.c
--- 25/drivers/usb/host/ohci-pci.c~fix-u32-vs-pm_message_t-in-usb	2005-03-20 16:57:42.000000000 -0800
+++ 25-akpm/drivers/usb/host/ohci-pci.c	2005-03-20 16:57:42.000000000 -0800
@@ -102,7 +102,7 @@ ohci_pci_start (struct usb_hcd *hcd)
 
 #ifdef	CONFIG_PM
 
-static int ohci_pci_suspend (struct usb_hcd *hcd, u32 state)
+static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t state)
 {
 	struct ohci_hcd		*ohci = hcd_to_ohci (hcd);
 
diff -puN drivers/usb/host/sl811-hcd.c~fix-u32-vs-pm_message_t-in-usb drivers/usb/host/sl811-hcd.c
--- 25/drivers/usb/host/sl811-hcd.c~fix-u32-vs-pm_message_t-in-usb	2005-03-20 16:57:42.000000000 -0800
+++ 25-akpm/drivers/usb/host/sl811-hcd.c	2005-03-20 16:57:42.000000000 -0800
@@ -101,12 +101,12 @@ static void port_power(struct sl811 *sl8
 
 		sl811->port1 = (1 << USB_PORT_FEAT_POWER);
 		sl811->irq_enable = SL11H_INTMASK_INSRMV;
-		hcd->self.controller->power.power_state = PM_SUSPEND_ON;
+		hcd->self.controller->power.power_state = PMSG_ON;
 	} else {
 		sl811->port1 = 0;
 		sl811->irq_enable = 0;
 		hcd->state = USB_STATE_HALT;
-		hcd->self.controller->power.power_state = PM_SUSPEND_DISK;
+		hcd->self.controller->power.power_state = PMSG_SUSPEND;
 	}
 	sl811->ctrl1 = 0;
 	sl811_write(sl811, SL11H_IRQ_ENABLE, 0);
@@ -1772,7 +1772,7 @@ sl811h_probe(struct device *dev)
  */
 
 static int
-sl811h_suspend(struct device *dev, u32 state, u32 phase)
+sl811h_suspend(struct device *dev, pm_message_t state, u32 phase)
 {
 	struct usb_hcd	*hcd = dev_get_drvdata(dev);
 	struct sl811	*sl811 = hcd_to_sl811(hcd);
diff -puN drivers/usb/host/uhci-hcd.c~fix-u32-vs-pm_message_t-in-usb drivers/usb/host/uhci-hcd.c
--- 25/drivers/usb/host/uhci-hcd.c~fix-u32-vs-pm_message_t-in-usb	2005-03-20 16:57:42.000000000 -0800
+++ 25-akpm/drivers/usb/host/uhci-hcd.c	2005-03-20 16:57:42.000000000 -0800
@@ -760,7 +760,7 @@ static void uhci_stop(struct usb_hcd *hc
 }
 
 #ifdef CONFIG_PM
-static int uhci_suspend(struct usb_hcd *hcd, u32 state)
+static int uhci_suspend(struct usb_hcd *hcd, pm_message_t state)
 {
 	struct uhci_hcd *uhci = hcd_to_uhci(hcd);
 
diff -puN drivers/usb/input/hid-core.c~fix-u32-vs-pm_message_t-in-usb drivers/usb/input/hid-core.c
--- 25/drivers/usb/input/hid-core.c~fix-u32-vs-pm_message_t-in-usb	2005-03-20 16:57:42.000000000 -0800
+++ 25-akpm/drivers/usb/input/hid-core.c	2005-03-20 16:57:43.000000000 -0800
@@ -1801,7 +1801,7 @@ static int hid_probe(struct usb_interfac
 	return 0;
 }
 
-static int hid_suspend(struct usb_interface *intf, u32 state)
+static int hid_suspend(struct usb_interface *intf, pm_message_t state)
 {
 	struct hid_device *hid = usb_get_intfdata (intf);
 
@@ -1816,7 +1816,7 @@ static int hid_resume(struct usb_interfa
 	struct hid_device *hid = usb_get_intfdata (intf);
 	int status;
 
-	intf->dev.power.power_state = PM_SUSPEND_ON;
+	intf->dev.power.power_state = PMSG_ON;
 	if (hid->open)
 		status = usb_submit_urb(hid->urbin, GFP_NOIO);
 	else
diff -puN drivers/usb/net/pegasus.c~fix-u32-vs-pm_message_t-in-usb drivers/usb/net/pegasus.c
diff -puN drivers/video/aty/radeon_pm.c~fix-u32-vs-pm_message_t-in-usb drivers/video/aty/radeon_pm.c
--- 25/drivers/video/aty/radeon_pm.c~fix-u32-vs-pm_message_t-in-usb	2005-03-20 16:57:42.000000000 -0800
+++ 25-akpm/drivers/video/aty/radeon_pm.c	2005-03-20 16:57:43.000000000 -0800
@@ -2522,7 +2522,7 @@ static int radeon_restore_pci_cfg(struct
 
 static/*extern*/ int susdisking = 0;
 
-int radeonfb_pci_suspend(struct pci_dev *pdev, u32 state)
+int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
         struct fb_info *info = pci_get_drvdata(pdev);
         struct radeonfb_info *rinfo = info->par;
diff -puN include/linux/usb.h~fix-u32-vs-pm_message_t-in-usb include/linux/usb.h
--- 25/include/linux/usb.h~fix-u32-vs-pm_message_t-in-usb	2005-03-20 16:57:42.000000000 -0800
+++ 25-akpm/include/linux/usb.h	2005-03-20 16:57:43.000000000 -0800
@@ -557,7 +557,7 @@ struct usb_driver {
 
 	int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf);
 
-	int (*suspend) (struct usb_interface *intf, u32 state);
+	int (*suspend) (struct usb_interface *intf, pm_message_t state);
 	int (*resume) (struct usb_interface *intf);
 
 	const struct usb_device_id *id_table;
@@ -976,7 +976,7 @@ extern int usb_bulk_msg(struct usb_devic
 	int timeout);
 
 /* selective suspend/resume */
-extern int usb_suspend_device(struct usb_device *dev, u32 state);
+extern int usb_suspend_device(struct usb_device *dev, pm_message_t state);
 extern int usb_resume_device(struct usb_device *dev);
 
 
_