Skip to content

Commit

Permalink
USB: usb-storage: implement autosuspend
Browse files Browse the repository at this point in the history
This patch (as1400) adds runtime-PM support to usb-storage.  It
utilizes the SCSI layer's runtime-PM implementation, so its scope is
limited.  Currently the only effect is that disk-like devices (such as
card readers or flash drives) will be autosuspended if they aren't
mounted and their device files aren't open.  This would apply, for
example, to card readers that don't contain a memory card.

Unfortunately this won't interact very well with the removable-media
polling normally carried out by hal or DeviceKit.  Maybe those
programs can be changed to use a longer polling interval, or maybe the
default autosuspend time for usb-storage should be set to something
below 1 second.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: James Bottomley <James.Bottomley@suse.de>
Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Aug 10, 2010
1 parent 185c9bc commit f283925
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/usb/storage/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ static int usb_stor_control_thread(void * __us)
else {
US_DEBUG(usb_stor_show_command(us->srb));
us->proto_handler(us->srb, us);
usb_mark_last_busy(us->pusb_dev);
}

/* lock access to the state */
Expand Down Expand Up @@ -845,6 +846,7 @@ static int usb_stor_scan_thread(void * __us)
/* Should we unbind if no devices were detected? */
}

usb_autopm_put_interface(us->pusb_intf);
complete_and_exit(&us->scanning_done, 0);
}

Expand Down Expand Up @@ -968,6 +970,7 @@ int usb_stor_probe2(struct us_data *us)
goto BadDevice;
}

usb_autopm_get_interface_no_resume(us->pusb_intf);
wake_up_process(th);

return 0;
Expand Down Expand Up @@ -1040,6 +1043,7 @@ static struct usb_driver usb_storage_driver = {
.pre_reset = usb_stor_pre_reset,
.post_reset = usb_stor_post_reset,
.id_table = usb_storage_usb_ids,
.supports_autosuspend = 1,
.soft_unbind = 1,
};

Expand Down

0 comments on commit f283925

Please sign in to comment.