This is a note to let you know that I've just added the patch titled

     Subject: usbcore: remove unused argument in autosuspend

to my gregkh-2.6 tree.  Its filename is

     usbcore-remove-unused-argument-in-autosuspend.patch

This tree can be found at 
    http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/


>From [EMAIL PROTECTED] Mon Nov 20 08:39:01 2006
Date: Mon, 20 Nov 2006 11:38:46 -0500 (EST)
From: Alan Stern <[EMAIL PROTECTED]>
To: Greg KH <[EMAIL PROTECTED]>
cc: USB development list <linux-usb-devel@lists.sourceforge.net>
Subject: usbcore: remove unused argument in autosuspend
Message-ID: <[EMAIL PROTECTED]>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

Thanks to several earlier patches, usb_autosuspend_device() and
usb_autoresume_device() are never called with a second argument other
than 1.  This patch (as819) removes the now-redundant argument.

It also consolidates some common code between those two routines,
putting it into a new subroutine called usb_autopm_do_device().  And
it includes a sizable kerneldoc update for the affected functions.

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

---
 drivers/usb/core/devio.c   |    4 -
 drivers/usb/core/driver.c  |  104 ++++++++++++++++++++++++---------------------
 drivers/usb/core/hub.c     |   12 ++---
 drivers/usb/core/message.c |    6 +-
 drivers/usb/core/usb.h     |    9 +--
 5 files changed, 72 insertions(+), 63 deletions(-)

--- gregkh-2.6.orig/drivers/usb/core/devio.c
+++ gregkh-2.6/drivers/usb/core/devio.c
@@ -561,7 +561,7 @@ static int usbdev_open(struct inode *ino
                dev = inode->i_private;
        if (!dev)
                goto out;
-       ret = usb_autoresume_device(dev, 1);
+       ret = usb_autoresume_device(dev);
        if (ret)
                goto out;
 
@@ -609,7 +609,7 @@ static int usbdev_release(struct inode *
                        releaseintf(ps, ifnum);
        }
        destroy_all_async(ps);
-       usb_autosuspend_device(dev, 1);
+       usb_autosuspend_device(dev);
        usb_unlock_device(dev);
        usb_put_dev(dev);
        put_pid(ps->disc_pid);
--- gregkh-2.6.orig/drivers/usb/core/driver.c
+++ gregkh-2.6/drivers/usb/core/driver.c
@@ -207,7 +207,7 @@ static int usb_probe_interface(struct de
        if (id) {
                dev_dbg(dev, "%s - got id\n", __FUNCTION__);
 
-               error = usb_autoresume_device(udev, 1);
+               error = usb_autoresume_device(udev);
                if (error)
                        return error;
 
@@ -231,7 +231,7 @@ static int usb_probe_interface(struct de
                } else
                        intf->condition = USB_INTERFACE_BOUND;
 
-               usb_autosuspend_device(udev, 1);
+               usb_autosuspend_device(udev);
        }
 
        return error;
@@ -249,7 +249,7 @@ static int usb_unbind_interface(struct d
 
        /* Autoresume for set_interface call below */
        udev = interface_to_usbdev(intf);
-       error = usb_autoresume_device(udev, 1);
+       error = usb_autoresume_device(udev);
 
        /* release all urbs for this interface */
        usb_disable_interface(interface_to_usbdev(intf), intf);
@@ -267,7 +267,7 @@ static int usb_unbind_interface(struct d
        intf->needs_remote_wakeup = 0;
 
        if (!error)
-               usb_autosuspend_device(udev, 1);
+               usb_autosuspend_device(udev);
 
        return 0;
 }
@@ -944,6 +944,8 @@ done:
        return status;
 }
 
+#ifdef CONFIG_USB_SUSPEND
+
 /* Internal routine to check whether we may autosuspend a device. */
 static int autosuspend_check(struct usb_device *udev)
 {
@@ -974,6 +976,12 @@ static int autosuspend_check(struct usb_
        return 0;
 }
 
+#else
+
+#define autosuspend_check(udev)                0
+
+#endif
+
 /**
  * usb_suspend_both - suspend a USB device and its interfaces
  * @udev: the usb_device to suspend
@@ -1052,7 +1060,7 @@ int usb_suspend_both(struct usb_device *
 
        /* If the suspend succeeded, propagate it up the tree */
        } else if (parent)
-               usb_autosuspend_device(parent, 1);
+               usb_autosuspend_device(parent);
 
        // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status);
        return status;
@@ -1100,11 +1108,11 @@ int usb_resume_both(struct usb_device *u
        /* Propagate the resume up the tree, if necessary */
        if (udev->state == USB_STATE_SUSPENDED) {
                if (parent) {
-                       status = usb_autoresume_device(parent, 1);
+                       status = usb_autoresume_device(parent);
                        if (status == 0) {
                                status = usb_resume_device(udev);
                                if (status) {
-                                       usb_autosuspend_device(parent, 1);
+                                       usb_autosuspend_device(parent);
 
                                        /* It's possible usb_resume_device()
                                         * failed after the port was
@@ -1150,39 +1158,53 @@ int usb_resume_both(struct usb_device *u
 
 #ifdef CONFIG_USB_SUSPEND
 
+/* Internal routine to adjust a device's usage counter and change
+ * its autosuspend state.
+ */
+static int usb_autopm_do_device(struct usb_device *udev, int inc_usage_cnt)
+{
+       int     status = 0;
+
+       usb_pm_lock(udev);
+       udev->pm_usage_cnt += inc_usage_cnt;
+       WARN_ON(udev->pm_usage_cnt < 0);
+       if (inc_usage_cnt >= 0 && udev->pm_usage_cnt > 0) {
+               udev->auto_pm = 1;
+               status = usb_resume_both(udev);
+               if (status != 0)
+                       udev->pm_usage_cnt -= inc_usage_cnt;
+       } else if (inc_usage_cnt <= 0 && autosuspend_check(udev) == 0)
+               queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
+                               USB_AUTOSUSPEND_DELAY);
+       usb_pm_unlock(udev);
+       return status;
+}
+
 /**
  * usb_autosuspend_device - delayed autosuspend of a USB device and its 
interfaces
  * @udev: the usb_device to autosuspend
- * @dec_usage_cnt: flag to decrement @udev's PM-usage counter
  *
  * This routine should be called when a core subsystem is finished using
  * @udev and wants to allow it to autosuspend.  Examples would be when
  * @udev's device file in usbfs is closed or after a configuration change.
  *
- * @dec_usage_cnt should be 1 if the subsystem previously incremented
- * @udev's usage counter (such as by passing 1 to usb_autoresume_device);
- * otherwise it should be 0.
- *
- * If the usage counter for @udev or any of its active interfaces is greater
- * than 0, the autosuspend request will not be queued.  (If an interface
- * driver does not support autosuspend then its usage counter is permanently
- * positive.)  Likewise, if an interface driver requires remote-wakeup
- * capability during autosuspend but remote wakeup is disabled, the
- * autosuspend will fail.
+ * @udev's usage counter is decremented.  If it or any of the usage counters
+ * for an active interface is greater than 0, no autosuspend request will be
+ * queued.  (If an interface driver does not support autosuspend then its
+ * usage counter is permanently positive.)  Furthermore, if an interface
+ * driver requires remote-wakeup capability during autosuspend but remote
+ * wakeup is disabled, the autosuspend will fail.
  *
  * Often the caller will hold @udev's device lock, but this is not
  * necessary.
  *
  * This routine can run only in process context.
  */
-void usb_autosuspend_device(struct usb_device *udev, int dec_usage_cnt)
+void usb_autosuspend_device(struct usb_device *udev)
 {
-       usb_pm_lock(udev);
-       udev->pm_usage_cnt -= dec_usage_cnt;
-       if (autosuspend_check(udev) == 0)
-               queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
-                               USB_AUTOSUSPEND_DELAY);
-       usb_pm_unlock(udev);
+       int     status;
+
+       status = usb_autopm_do_device(udev, -1);
        // dev_dbg(&udev->dev, "%s: cnt %d\n",
        //              __FUNCTION__, udev->pm_usage_cnt);
 }
@@ -1190,39 +1212,27 @@ void usb_autosuspend_device(struct usb_d
 /**
  * usb_autoresume_device - immediately autoresume a USB device and its 
interfaces
  * @udev: the usb_device to autoresume
- * @inc_usage_cnt: flag to increment @udev's PM-usage counter
  *
  * This routine should be called when a core subsystem wants to use @udev
- * and needs to guarantee that it is not suspended.  In addition, the
- * caller can prevent @udev from being autosuspended subsequently.  (Note
- * that this will not prevent suspend events originating in the PM core.)
- * Examples would be when @udev's device file in usbfs is opened (autosuspend
- * should be prevented until the file is closed) or when a remote-wakeup
- * request is received (later autosuspends should not be prevented).
- *
- * @inc_usage_cnt should be 1 to increment @udev's usage counter and prevent
- * autosuspends.  This prevention will persist until the usage counter is
- * decremented again (such as by passing 1 to usb_autosuspend_device).
- * Otherwise @inc_usage_cnt should be 0 to leave the usage counter unchanged.
- * Regardless, if the autoresume fails then the usage counter is not
- * incremented.
+ * and needs to guarantee that it is not suspended.  No autosuspend will
+ * occur until usb_autosuspend_device is called.  (Note that this will not
+ * prevent suspend events originating in the PM core.)  Examples would be
+ * when @udev's device file in usbfs is opened or when a remote-wakeup
+ * request is received.
+ *
+ * @udev's usage counter is incremented to prevent subsequent autosuspends.
+ * However if the autoresume fails then the usage counter is re-decremented.
  *
  * Often the caller will hold @udev's device lock, but this is not
  * necessary (and attempting it might cause deadlock).
  *
  * This routine can run only in process context.
  */
-int usb_autoresume_device(struct usb_device *udev, int inc_usage_cnt)
+int usb_autoresume_device(struct usb_device *udev)
 {
        int     status;
 
-       usb_pm_lock(udev);
-       udev->pm_usage_cnt += inc_usage_cnt;
-       udev->auto_pm = 1;
-       status = usb_resume_both(udev);
-       if (status != 0)
-               udev->pm_usage_cnt -= inc_usage_cnt;
-       usb_pm_unlock(udev);
+       status = usb_autopm_do_device(udev, 1);
        // dev_dbg(&udev->dev, "%s: status %d cnt %d\n",
        //              __FUNCTION__, status, udev->pm_usage_cnt);
        return status;
--- gregkh-2.6.orig/drivers/usb/core/hub.c
+++ gregkh-2.6/drivers/usb/core/hub.c
@@ -1234,7 +1234,7 @@ void usb_disconnect(struct usb_device **
        if (udev->parent) {
                usb_pm_lock(udev);
                if (!udev->discon_suspended)
-                       usb_autosuspend_device(udev->parent, 1);
+                       usb_autosuspend_device(udev->parent);
                usb_pm_unlock(udev);
        }
 
@@ -1366,7 +1366,7 @@ static int __usb_new_device(void *void_d
 
        /* Increment the parent's count of unsuspended children */
        if (udev->parent)
-               usb_autoresume_device(udev->parent, 1);
+               usb_autoresume_device(udev->parent);
 
 exit:
        module_put(THIS_MODULE);
@@ -1879,12 +1879,12 @@ static int remote_wakeup(struct usb_devi
        usb_lock_device(udev);
        if (udev->state == USB_STATE_SUSPENDED) {
                dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-");
-               status = usb_autoresume_device(udev, 1);
+               status = usb_autoresume_device(udev);
 
                /* Give the interface drivers a chance to do something,
                 * then autosuspend the device again. */
                if (status == 0)
-                       usb_autosuspend_device(udev, 1);
+                       usb_autosuspend_device(udev);
        }
        usb_unlock_device(udev);
        return status;
@@ -3097,7 +3097,7 @@ int usb_reset_composite_device(struct us
        }
 
        /* Prevent autosuspend during the reset */
-       usb_autoresume_device(udev, 1);
+       usb_autoresume_device(udev);
 
        if (iface && iface->condition != USB_INTERFACE_BINDING)
                iface = NULL;
@@ -3140,7 +3140,7 @@ int usb_reset_composite_device(struct us
                }
        }
 
-       usb_autosuspend_device(udev, 1);
+       usb_autosuspend_device(udev);
        return ret;
 }
 EXPORT_SYMBOL(usb_reset_composite_device);
--- gregkh-2.6.orig/drivers/usb/core/message.c
+++ gregkh-2.6/drivers/usb/core/message.c
@@ -1398,7 +1398,7 @@ free_interfaces:
        }
 
        /* Wake up the device so we can send it the Set-Config request */
-       ret = usb_autoresume_device(dev, 1);
+       ret = usb_autoresume_device(dev);
        if (ret)
                goto free_interfaces;
 
@@ -1421,7 +1421,7 @@ free_interfaces:
        dev->actconfig = cp;
        if (!cp) {
                usb_set_device_state(dev, USB_STATE_ADDRESS);
-               usb_autosuspend_device(dev, 1);
+               usb_autosuspend_device(dev);
                goto free_interfaces;
        }
        usb_set_device_state(dev, USB_STATE_CONFIGURED);
@@ -1490,7 +1490,7 @@ free_interfaces:
                usb_create_sysfs_intf_files (intf);
        }
 
-       usb_autosuspend_device(dev, 1);
+       usb_autosuspend_device(dev);
        return 0;
 }
 
--- gregkh-2.6.orig/drivers/usb/core/usb.h
+++ gregkh-2.6/drivers/usb/core/usb.h
@@ -64,14 +64,13 @@ static inline void usb_pm_unlock(struct 
 
 #define USB_AUTOSUSPEND_DELAY  (HZ*2)
 
-extern void usb_autosuspend_device(struct usb_device *udev, int dec_busy_cnt);
-extern int usb_autoresume_device(struct usb_device *udev, int inc_busy_cnt);
+extern void usb_autosuspend_device(struct usb_device *udev);
+extern int usb_autoresume_device(struct usb_device *udev);
 
 #else
 
-#define usb_autosuspend_device(udev, dec_busy_cnt)     do {} while (0)
-static inline int usb_autoresume_device(struct usb_device *udev,
-               int inc_busy_cnt)
+#define usb_autosuspend_device(udev)   do {} while (0)
+static inline int usb_autoresume_device(struct usb_device *udev)
 {
        return 0;
 }


Patches currently in gregkh-2.6 which might be from [EMAIL PROTECTED] are

usb/usb-hid-handle-stall-on-interrupt-endpoint.patch
usb/usb-resume_device-symbol-conflict.patch
usb/usb-expand-autosuspend-autoresume-api.patch
usb/usb-add-autosuspend-support-to-the-hub-driver.patch
usb/ehci-hcd-fix-budget_pool-allocation-for-machines-with-multiple-ehci-controllers.patch
usb/usb-core-don-t-match-interface-descriptors-for-vendor-specific-devices.patch
usb/usb-takes-31-devices-per-hub.patch
usb/usb-hub-root-hub-code-takes-more-than-15-devices.patch
usb/usb-ohci-disable-rhsc-inside-interrupt-handler.patch
usb/usb-ohci-hcd-fix-compiler-warning.patch
usb/usb-ohci-remove-stale-testing-code-from-root-hub-resume.patch
usb/usb-autosuspend-code-consolidation.patch
usb/usb-move-private-hub-declarations-out-of-public-header-file.patch
usb/ehci-fix-memory-pool-name-allocation.patch
usb/ehci-fix-root-hub-and-port-suspend-resume-problems.patch
usb/usb-core-fix-compiler-warning-about-usb_autosuspend_work.patch
usb/usb-net2280-don-t-send-unwanted-zero-length-packets.patch
usb/ohci-change-priority-level-of-resume-log-message.patch
usb/usb-hub-simplify-remote-wakeup-handling.patch
usb/usb-keep-count-of-unsuspended-children.patch
usb/usb-struct-usb_device-change-flag-to-bitflag.patch
usb/usbcore-remove-unused-argument-in-autosuspend.patch
usb/ohci-make-autostop-conditional-on-config_pm.patch

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
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