Greg:

This patch (as736) makes the hub driver more readable by improving the 
usage of "#ifdef CONFIG_PM" and "#ifdef CONFIG_USB_SUSPEND".

Alan Stern



Signed-off-by: Alan Stern <[EMAIL PROTECTED]>

---

Index: usb-2.6/drivers/usb/core/hub.c
===================================================================
--- usb-2.6.orig/drivers/usb/core/hub.c
+++ usb-2.6/drivers/usb/core/hub.c
@@ -1042,7 +1042,7 @@ void usb_set_device_state(struct usb_dev
 }
 
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM
 
 /**
  * usb_root_hub_lost_power - called by HCD if the root hub lost Vbus power
@@ -1073,7 +1073,7 @@ void usb_root_hub_lost_power(struct usb_
 }
 EXPORT_SYMBOL_GPL(usb_root_hub_lost_power);
 
-#endif
+#endif /* CONFIG_PM */
 
 static void choose_address(struct usb_device *udev)
 {
@@ -1470,6 +1470,7 @@ static void hub_port_logical_disconnect(
        kick_khubd(hub);
 }
 
+#ifdef CONFIG_PM
 
 #ifdef CONFIG_USB_SUSPEND
 
@@ -1568,8 +1569,6 @@ static int __usb_port_suspend (struct us
        return status;
 }
 
-#endif
-
 /*
  * usb_port_suspend - suspend a usb device's upstream port
  * @udev: device that's no longer in active use
@@ -1592,11 +1591,7 @@ static int __usb_port_suspend (struct us
  */
 int usb_port_suspend(struct usb_device *udev)
 {
-#ifdef CONFIG_USB_SUSPEND
        return __usb_port_suspend(udev, udev->portnum);
-#else
-       return 0;
-#endif
 }
 
 /*
@@ -1660,8 +1655,6 @@ static int finish_port_resume(struct usb
        return status;
 }
 
-#ifdef CONFIG_USB_SUSPEND
-
 static int
 hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
 {
@@ -1721,8 +1714,6 @@ hub_port_resume(struct usb_hub *hub, int
        return status;
 }
 
-#endif
-
 /*
  * usb_port_resume - re-activate a suspended usb device's upstream port
  * @udev: device to re-activate
@@ -1738,17 +1729,15 @@ hub_port_resume(struct usb_hub *hub, int
  */
 int usb_port_resume(struct usb_device *udev)
 {
-       int     status = 0;
+       int     status;
 
        /* we change the device's upstream USB link,
         * but root hubs have no upstream USB link.
         */
        if (udev->parent) {
-#ifdef CONFIG_USB_SUSPEND
                // NOTE this fails if parent is also suspended...
                status = hub_port_resume(hdev_to_hub(udev->parent),
                                udev->portnum, udev);
-#endif
        } else
                status = finish_port_resume(udev);
        if (status < 0)
@@ -1760,8 +1749,6 @@ static int remote_wakeup(struct usb_devi
 {
        int     status = 0;
 
-#ifdef CONFIG_USB_SUSPEND
-
        /* don't repeat RESUME sequence if this device
         * was already woken up by some other task
         */
@@ -1776,10 +1763,42 @@ static int remote_wakeup(struct usb_devi
        if (status == 0)
                usb_resume_both(udev);
        usb_unlock_device(udev);
-#endif
        return status;
 }
 
+#else  /* CONFIG_USB_SUSPEND */
+
+/* When CONFIG_USB_SUSPEND isn't set, we never suspend or resume any ports. */
+
+int usb_port_suspend(struct usb_device *udev)
+{
+       return 0;
+}
+
+static inline int
+finish_port_resume(struct usb_device *udev)
+{
+       return 0;
+}
+
+static inline int
+hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
+{
+       return 0;
+}
+
+int usb_port_resume(struct usb_device *udev)
+{
+       return 0;
+}
+
+static inline int remote_wakeup(struct usb_device *udev)
+{
+       return 0;
+}
+
+#endif
+
 static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
 {
        struct usb_hub          *hub = usb_get_intfdata (intf);
@@ -1853,6 +1872,15 @@ static int hub_resume(struct usb_interfa
        return 0;
 }
 
+#else  /* CONFIG_PM */
+
+static inline int remote_wakeup(struct usb_device *udev)
+{
+       return 0;
+}
+
+#endif
+
 void usb_suspend_root_hub(struct usb_device *hdev)
 {
        struct usb_hub *hub = hdev_to_hub(hdev);
Index: usb-2.6/drivers/usb/core/usb.h
===================================================================
--- usb-2.6.orig/drivers/usb/core/usb.h
+++ usb-2.6/drivers/usb/core/usb.h
@@ -30,11 +30,22 @@ extern void usb_major_cleanup(void);
 extern int usb_host_init(void);
 extern void usb_host_cleanup(void);
 
+#ifdef CONFIG_PM
+
 extern int usb_suspend_both(struct usb_device *udev, pm_message_t msg);
 extern int usb_resume_both(struct usb_device *udev);
 extern int usb_port_suspend(struct usb_device *dev);
 extern int usb_port_resume(struct usb_device *dev);
 
+#else
+
+#define usb_suspend_both(udev, msg)    0
+#define usb_resume_both(udev)          0
+#define usb_port_suspend(dev)          0
+#define usb_port_resume(dev)           0
+
+#endif
+
 extern struct bus_type usb_bus_type;
 extern struct usb_device_driver usb_generic_driver;
 


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to