USB: fix wrong order of events in usb serial suspension
authorOliver Neukum <oliver@neukum.org>
Tue, 21 Jul 2009 06:47:34 +0000 (08:47 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 23 Sep 2009 13:46:29 +0000 (06:46 -0700)
if a subdriver has an additional suspend method, it must be called
first to allow the subdriver to return -EBUSY, because the second
half cannot be easily undone.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/serial/usb-serial.c

index 54bb37d419169b36fc5d9b603e4d2b395adbbcf8..45975b4984eabff36729c02d8ef877da1c6508ed 100644 (file)
@@ -1157,15 +1157,19 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
 
        serial->suspending = 1;
 
+       if (serial->type->suspend) {
+               r = serial->type->suspend(serial, message);
+               if (r < 0)
+                       goto err_out;
+       }
+
        for (i = 0; i < serial->num_ports; ++i) {
                port = serial->port[i];
                if (port)
                        kill_traffic(port);
        }
 
-       if (serial->type->suspend)
-               r = serial->type->suspend(serial, message);
-
+err_out:
        return r;
 }
 EXPORT_SYMBOL(usb_serial_suspend);