aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/usb.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2006-01-11 09:55:29 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-20 17:49:55 -0500
commit4186ecf8ad16dd05759a09594de6a87e48759ba6 (patch)
tree3ee5292d9f4a36e3eb359b586289ec972bcbaf39 /drivers/usb/storage/usb.c
parent35cce732d9d4d9af6b4ad4d26d8f8c0eddb573a2 (diff)
[PATCH] USB: convert a bunch of USB semaphores to mutexes
the patch below converts a bunch of semaphores-used-as-mutex in the USB code to mutexes Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/storage/usb.c')
-rw-r--r--drivers/usb/storage/usb.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index dbcf23980ff1..dd108634348e 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -55,6 +55,7 @@
55#include <linux/init.h> 55#include <linux/init.h>
56#include <linux/slab.h> 56#include <linux/slab.h>
57#include <linux/kthread.h> 57#include <linux/kthread.h>
58#include <linux/mutex.h>
58 59
59#include <scsi/scsi.h> 60#include <scsi/scsi.h>
60#include <scsi/scsi_cmnd.h> 61#include <scsi/scsi_cmnd.h>
@@ -188,7 +189,7 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message)
188 struct us_data *us = usb_get_intfdata(iface); 189 struct us_data *us = usb_get_intfdata(iface);
189 190
190 /* Wait until no command is running */ 191 /* Wait until no command is running */
191 down(&us->dev_semaphore); 192 mutex_lock(&us->dev_mutex);
192 193
193 US_DEBUGP("%s\n", __FUNCTION__); 194 US_DEBUGP("%s\n", __FUNCTION__);
194 if (us->suspend_resume_hook) 195 if (us->suspend_resume_hook)
@@ -198,7 +199,7 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message)
198 /* When runtime PM is working, we'll set a flag to indicate 199 /* When runtime PM is working, we'll set a flag to indicate
199 * whether we should autoresume when a SCSI request arrives. */ 200 * whether we should autoresume when a SCSI request arrives. */
200 201
201 up(&us->dev_semaphore); 202 mutex_unlock(&us->dev_mutex);
202 return 0; 203 return 0;
203} 204}
204 205
@@ -206,14 +207,14 @@ static int storage_resume(struct usb_interface *iface)
206{ 207{
207 struct us_data *us = usb_get_intfdata(iface); 208 struct us_data *us = usb_get_intfdata(iface);
208 209
209 down(&us->dev_semaphore); 210 mutex_lock(&us->dev_mutex);
210 211
211 US_DEBUGP("%s\n", __FUNCTION__); 212 US_DEBUGP("%s\n", __FUNCTION__);
212 if (us->suspend_resume_hook) 213 if (us->suspend_resume_hook)
213 (us->suspend_resume_hook)(us, US_RESUME); 214 (us->suspend_resume_hook)(us, US_RESUME);
214 iface->dev.power.power_state.event = PM_EVENT_ON; 215 iface->dev.power.power_state.event = PM_EVENT_ON;
215 216
216 up(&us->dev_semaphore); 217 mutex_unlock(&us->dev_mutex);
217 return 0; 218 return 0;
218} 219}
219 220
@@ -276,12 +277,12 @@ static int usb_stor_control_thread(void * __us)
276 US_DEBUGP("*** thread awakened.\n"); 277 US_DEBUGP("*** thread awakened.\n");
277 278
278 /* lock the device pointers */ 279 /* lock the device pointers */
279 down(&(us->dev_semaphore)); 280 mutex_lock(&(us->dev_mutex));
280 281
281 /* if the device has disconnected, we are free to exit */ 282 /* if the device has disconnected, we are free to exit */
282 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 283 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
283 US_DEBUGP("-- exiting\n"); 284 US_DEBUGP("-- exiting\n");
284 up(&(us->dev_semaphore)); 285 mutex_unlock(&us->dev_mutex);
285 break; 286 break;
286 } 287 }
287 288
@@ -370,7 +371,7 @@ SkipForAbort:
370 scsi_unlock(host); 371 scsi_unlock(host);
371 372
372 /* unlock the device pointers */ 373 /* unlock the device pointers */
373 up(&(us->dev_semaphore)); 374 mutex_unlock(&us->dev_mutex);
374 } /* for (;;) */ 375 } /* for (;;) */
375 376
376 scsi_host_put(host); 377 scsi_host_put(host);
@@ -815,8 +816,8 @@ static void quiesce_and_remove_host(struct us_data *us)
815 * The thread will exit when it sees the DISCONNECTING flag. */ 816 * The thread will exit when it sees the DISCONNECTING flag. */
816 817
817 /* Wait for the current command to finish, then remove the host */ 818 /* Wait for the current command to finish, then remove the host */
818 down(&us->dev_semaphore); 819 mutex_lock(&us->dev_mutex);
819 up(&us->dev_semaphore); 820 mutex_unlock(&us->dev_mutex);
820 821
821 /* queuecommand won't accept any new commands and the control 822 /* queuecommand won't accept any new commands and the control
822 * thread won't execute a previously-queued command. If there 823 * thread won't execute a previously-queued command. If there
@@ -870,9 +871,9 @@ retry:
870 /* For bulk-only devices, determine the max LUN value */ 871 /* For bulk-only devices, determine the max LUN value */
871 if (us->protocol == US_PR_BULK && 872 if (us->protocol == US_PR_BULK &&
872 !(us->flags & US_FL_SINGLE_LUN)) { 873 !(us->flags & US_FL_SINGLE_LUN)) {
873 down(&us->dev_semaphore); 874 mutex_lock(&us->dev_mutex);
874 us->max_lun = usb_stor_Bulk_max_lun(us); 875 us->max_lun = usb_stor_Bulk_max_lun(us);
875 up(&us->dev_semaphore); 876 mutex_unlock(&us->dev_mutex);
876 } 877 }
877 scsi_scan_host(us_to_host(us)); 878 scsi_scan_host(us_to_host(us));
878 printk(KERN_DEBUG "usb-storage: device scan complete\n"); 879 printk(KERN_DEBUG "usb-storage: device scan complete\n");
@@ -912,7 +913,7 @@ static int storage_probe(struct usb_interface *intf,
912 913
913 us = host_to_us(host); 914 us = host_to_us(host);
914 memset(us, 0, sizeof(struct us_data)); 915 memset(us, 0, sizeof(struct us_data));
915 init_MUTEX(&(us->dev_semaphore)); 916 mutex_init(&(us->dev_mutex));
916 init_MUTEX_LOCKED(&(us->sema)); 917 init_MUTEX_LOCKED(&(us->sema));
917 init_completion(&(us->notify)); 918 init_completion(&(us->notify));
918 init_waitqueue_head(&us->delay_wait); 919 init_waitqueue_head(&us->delay_wait);