Commit 4d9e7d04 authored by Matthew Dharm's avatar Matthew Dharm Committed by Greg Kroah-Hartman

[PATCH] PATCH: usb-storage: merge bitfields into a unified system

This patch unifies all the bit tests and various flags into a single,
unified system.

Matt
parent 21ef9fc9
......@@ -198,7 +198,7 @@ static int device_reset( Scsi_Cmnd *srb )
US_DEBUGP("device_reset() called\n" );
/* if the device was removed, then we're already reset */
if (!test_bit(DEV_ATTACHED, &us->bitflags))
if (!(us->flags & US_FL_DEV_ATTACHED))
return SUCCESS;
scsi_unlock(srb->host);
......@@ -229,7 +229,7 @@ static int bus_reset( Scsi_Cmnd *srb )
US_DEBUGP("bus_reset() called\n");
/* if the device has been removed, this worked */
if (!test_bit(DEV_ATTACHED, &us->bitflags)) {
if (!(us->flags & US_FL_DEV_ATTACHED)) {
US_DEBUGP("-- device removed already\n");
return SUCCESS;
}
......@@ -331,8 +331,8 @@ static int proc_info (char *buffer, char **start, off_t offset, int length,
/* show the GUID of the device */
SPRINTF(" GUID: " GUID_FORMAT "\n", GUID_ARGS(us->guid));
SPRINTF(" Attached: %s\n", (test_bit(DEV_ATTACHED, &us->bitflags)
? "Yes" : "No"));
SPRINTF(" Attached: %s\n", (us->flags & US_FL_DEV_ATTACHED ?
"Yes" : "No"));
/*
* Calculate start of next buffer, and return value.
......
......@@ -878,7 +878,7 @@ void usb_stor_abort_transport(struct us_data *us)
up(&(us->current_urb_sem));
/* If we are waiting for an IRQ, simulate it */
if (test_bit(IP_WANTED, &us->bitflags)) {
if (test_bit(US_FLIDX_IP_WANTED, &us->flags)) {
US_DEBUGP("-- simulating missing IRQ\n");
usb_stor_CBI_irq(us->irq_urb);
}
......@@ -903,7 +903,7 @@ void usb_stor_CBI_irq(struct urb *urb)
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
/* was this a wanted interrupt? */
if (!test_and_clear_bit(IP_WANTED, &us->bitflags)) {
if (!test_and_clear_bit(US_FLIDX_IP_WANTED, &us->flags)) {
US_DEBUGP("ERROR: Unwanted interrupt received!\n");
return;
}
......@@ -919,7 +919,7 @@ void usb_stor_CBI_irq(struct urb *urb)
US_DEBUGP("-- device has been removed\n");
/* was this a wanted interrupt? */
if (!test_and_clear_bit(IP_WANTED, &us->bitflags))
if (!test_and_clear_bit(US_FLIDX_IP_WANTED, &us->flags))
return;
/* indicate a transport error -- this is the best we can do */
......@@ -943,7 +943,7 @@ void usb_stor_CBI_irq(struct urb *urb)
}
/* was this a wanted interrupt? */
if (!test_and_clear_bit(IP_WANTED, &us->bitflags)) {
if (!test_and_clear_bit(US_FLIDX_IP_WANTED, &us->flags)) {
US_DEBUGP("ERROR: Unwanted interrupt received!\n");
return;
}
......@@ -965,7 +965,7 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
init_MUTEX_LOCKED(&(us->ip_waitq));
/* Set up for status notification */
set_bit(IP_WANTED, &us->bitflags);
set_bit(US_FLIDX_IP_WANTED, &us->flags);
/* COMMAND STAGE */
/* let's send the command via the control pipe */
......@@ -978,7 +978,7 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
US_DEBUGP("Call to usb_stor_control_msg() returned %d\n", result);
if (result < 0) {
/* Reset flag for status notification */
clear_bit(IP_WANTED, &us->bitflags);
clear_bit(US_FLIDX_IP_WANTED, &us->flags);
}
/* did we abort this command? */
......@@ -1016,11 +1016,11 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
/* report any errors */
if (result == US_BULK_TRANSFER_ABORTED) {
clear_bit(IP_WANTED, &us->bitflags);
clear_bit(US_FLIDX_IP_WANTED, &us->flags);
return USB_STOR_TRANSPORT_ABORTED;
}
if (result == US_BULK_TRANSFER_FAILED) {
clear_bit(IP_WANTED, &us->bitflags);
clear_bit(US_FLIDX_IP_WANTED, &us->flags);
return USB_STOR_TRANSPORT_FAILED;
}
}
......
......@@ -396,7 +396,7 @@ static int usb_stor_control_thread(void * __us)
}
/* our device has gone - pretend not ready */
else if (!test_bit(DEV_ATTACHED, &us->bitflags)) {
else if (!(us->flags & US_FL_DEV_ATTACHED)) {
US_DEBUGP("Request is for removed device\n");
/* For REQUEST_SENSE, it's the data. But
* for anything else, it should look like
......@@ -420,7 +420,7 @@ static int usb_stor_control_thread(void * __us)
sizeof(usb_stor_sense_notready));
us->srb->result = CHECK_CONDITION << 1;
}
} /* test_bit(DEV_ATTACHED, &us->bitflags) */
} /* !(us->flags & US_FL_DEV_ATTACHED) */
/* Handle those devices which need us to fake
* their inquiry data */
......@@ -570,7 +570,7 @@ static void usb_stor_deallocate_urbs(struct us_data *ss)
}
/* mark the device as gone */
clear_bit(DEV_ATTACHED, &ss->bitflags);
ss->flags &= ~ US_FL_DEV_ATTACHED;
usb_put_dev(ss->pusb_dev);
ss->pusb_dev = NULL;
}
......@@ -726,7 +726,7 @@ static void * storage_probe(struct usb_device *dev, unsigned int ifnum,
*/
ss = us_list;
while ((ss != NULL) &&
(test_bit(DEV_ATTACHED, &ss->bitflags) ||
((ss->flags & US_FL_DEV_ATTACHED) ||
!GUID_EQUAL(guid, ss->guid)))
ss = ss->next;
......@@ -741,7 +741,7 @@ static void * storage_probe(struct usb_device *dev, unsigned int ifnum,
/* establish the connection to the new device upon reconnect */
ss->ifnum = ifnum;
ss->pusb_dev = dev;
set_bit(DEV_ATTACHED, &ss->bitflags);
ss->flags |= US_FL_DEV_ATTACHED;
/* copy over the endpoint data */
ss->ep_in = ep_in->bEndpointAddress &
......@@ -785,7 +785,7 @@ static void * storage_probe(struct usb_device *dev, unsigned int ifnum,
/* copy over the subclass and protocol data */
ss->subclass = subclass;
ss->protocol = protocol;
ss->flags = flags;
ss->flags = flags | US_FL_DEV_ATTACHED;
ss->unusual_dev = unusual_dev;
/* copy over the endpoint data */
......@@ -1000,7 +1000,6 @@ static void * storage_probe(struct usb_device *dev, unsigned int ifnum,
/* start up our control thread */
atomic_set(&ss->sm_state, US_STATE_IDLE);
set_bit(DEV_ATTACHED, &ss->bitflags);
ss->pid = kernel_thread(usb_stor_control_thread, ss,
CLONE_VM);
if (ss->pid < 0) {
......
......@@ -100,8 +100,11 @@ struct us_unusual_dev {
Win/MacOS compatibility */
#define US_FL_START_STOP 0x00000004 /* ignore START_STOP commands */
#define US_FL_IGNORE_SER 0x00000010 /* Ignore the serial number given */
#define US_FL_SCM_MULT_TARG 0x00000020 /* supports multiple targets */
#define US_FL_FIX_INQUIRY 0x00000040 /* INQUIRY response needs fixing */
#define US_FL_SCM_MULT_TARG 0x00000020 /* supports multiple targets */
#define US_FL_FIX_INQUIRY 0x00000040 /* INQUIRY response needs fixing */
#define US_FL_DEV_ATTACHED 0x00010000 /* is the device attached? */
#define US_FLIDX_IP_WANTED 17 /* 0x00020000 is an IRQ expected? */
/* kernel thread actions */
......@@ -128,12 +131,12 @@ struct us_data {
/* The device we're working with
* It's important to note:
* (o) you must hold dev_semaphore to change pusb_dev
* (o) DEV_ATTACHED in bitflags should change whenever pusb_dev does
* (o) DEV_ATTACHED in flags should change whenever pusb_dev does
*/
struct semaphore dev_semaphore; /* protect pusb_dev */
struct usb_device *pusb_dev; /* this usb_device */
unsigned int flags; /* from filter initially */
unsigned long flags; /* from filter initially */
/* information about the device -- always good */
char vendor[USB_STOR_STRING_LEN];
......@@ -172,9 +175,6 @@ struct us_data {
/* interrupt info for CBI devices -- only good if attached */
struct semaphore ip_waitq; /* for CBI interrupts */
unsigned long bitflags; /* single-bit flags: */
#define IP_WANTED 1 /* is an IRQ expected? */
#define DEV_ATTACHED 2 /* is the dev. attached?*/
/* interrupt communications data */
struct semaphore irq_urb_sem; /* to protect irq_urb */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment