# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.629 -> 1.630 # drivers/usb/storage/usb.c 1.29 -> 1.30 # drivers/usb/storage/transport.c 1.24 -> 1.25 # drivers/usb/storage/scsiglue.c 1.24 -> 1.25 # drivers/usb/storage/usb.h 1.14 -> 1.15 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/07/07 mdharm-usb@one-eyed-alien.net 1.630 # [PATCH] PATCH: usb-storage: consolidate, cleanup, etc. # # This patch fixes some spelling errors and adds some BUG_ON() calls so we # can make sure that all this new code is working properly. # -------------------------------------------- # diff -Nru a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c --- a/drivers/usb/storage/scsiglue.c Sun Jul 7 12:35:42 2002 +++ b/drivers/usb/storage/scsiglue.c Sun Jul 7 12:35:42 2002 @@ -114,9 +114,10 @@ /* Kill the control threads * * Enqueue the command, wake up the thread, and wait for - * notification that it's exited. + * notification that it has exited. */ US_DEBUGP("-- sending exit command to thread\n"); + BUG_ON(atomic_read(&us->sm_state) != US_STATE_IDLE); us->srb = NULL; up(&(us->sema)); wait_for_completion(&(us->notify)); @@ -136,7 +137,7 @@ return DID_BAD_TARGET << 16; } -/* run command */ +/* queue a command */ /* This is always called with scsi_lock(srb->host) held */ static int queuecommand( Scsi_Cmnd *srb , void (*done)(Scsi_Cmnd *)) { @@ -146,6 +147,7 @@ srb->host_scribble = (unsigned char *)us; /* enqueue the command */ + BUG_ON(atomic_read(&us->sm_state) != US_STATE_IDLE || us->srb != NULL); srb->scsi_done = done; us->srb = srb; @@ -186,6 +188,7 @@ int result; US_DEBUGP("device_reset() called\n" ); + BUG_ON(atomic_read(&us->sm_state) != US_STATE_IDLE); /* set the state and release the lock */ atomic_set(&us->sm_state, US_STATE_RESETTING); diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c --- a/drivers/usb/storage/transport.c Sun Jul 7 12:35:42 2002 +++ b/drivers/usb/storage/transport.c Sun Jul 7 12:35:42 2002 @@ -849,6 +849,7 @@ /* Normally the current state is RUNNING. If the control thread * hasn't even started processing this command, the state will be * IDLE. Anything else is a bug. */ + BUG_ON((state != US_STATE_RUNNING && state != US_STATE_IDLE)); /* set state to abort and release the lock */ atomic_set(&us->sm_state, US_STATE_ABORTING); diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c --- a/drivers/usb/storage/usb.c Sun Jul 7 12:35:42 2002 +++ b/drivers/usb/storage/usb.c Sun Jul 7 12:35:42 2002 @@ -473,7 +473,7 @@ } /* Set up the URB, the usb_ctrlrequest, and the IRQ pipe and handler. - * ss->dev_semaphore should already be locked. + * ss->dev_semaphore must already be locked. * Note that this function assumes that all the data in the us_data * strucuture is current. This includes the ep_int field, which gives us * the endpoint for the interrupt. diff -Nru a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h --- a/drivers/usb/storage/usb.h Sun Jul 7 12:35:42 2002 +++ b/drivers/usb/storage/usb.h Sun Jul 7 12:35:42 2002 @@ -131,7 +131,6 @@ */ struct semaphore dev_semaphore; /* protect pusb_dev */ struct usb_device *pusb_dev; /* this usb_device */ - unsigned long flags; /* from filter initially */ /* information about the device -- always good */ @@ -164,8 +163,8 @@ Scsi_Cmnd *srb; /* current srb */ /* thread information */ - int pid; /* control thread */ - atomic_t sm_state; + int pid; /* control thread */ + atomic_t sm_state; /* what we are doing */ /* interrupt info for CBI devices -- only good if attached */ struct semaphore ip_waitq; /* for CBI interrupts */ @@ -177,7 +176,7 @@ unsigned char irqdata[2]; /* data from USB IRQ */ /* control and bulk communications data */ - struct semaphore current_urb_sem; /* to protect irq_urb */ + struct semaphore current_urb_sem; /* protect current_urb */ struct urb *current_urb; /* non-int USB requests */ struct usb_ctrlrequest *dr; /* control requests */