X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fusb%2Fstorage%2Fusb.h;h=009fb0953a56140e5e5353a190ca4aaf64debbc6;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=785f30be68c580a24d782fdd03071c43c7a1650d;hpb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;p=linux-2.6.git diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h index 785f30be6..009fb0953 100644 --- a/drivers/usb/storage/usb.h +++ b/drivers/usb/storage/usb.h @@ -45,9 +45,12 @@ #define _USB_H_ #include +#include #include #include #include +#include +#include struct us_data; struct scsi_cmnd; @@ -62,17 +65,8 @@ struct us_unusual_dev { __u8 useProtocol; __u8 useTransport; int (*initFunction)(struct us_data *); - unsigned int flags; }; -/* Flag definitions: these entries are static */ -#define US_FL_SINGLE_LUN 0x00000001 /* allow access to only LUN 0 */ -#define US_FL_MODE_XLATE 0 /* [no longer used] */ -#define US_FL_NEED_OVERRIDE 0x00000004 /* unusual_devs entry is necessary */ -#define US_FL_IGNORE_SER 0 /* [no longer used] */ -#define US_FL_SCM_MULT_TARG 0x00000020 /* supports multiple targets */ -#define US_FL_FIX_INQUIRY 0x00000040 /* INQUIRY response needs faking */ -#define US_FL_FIX_CAPACITY 0x00000080 /* READ CAPACITY response too big */ /* Dynamic flag definitions: used in set_bit() etc. */ #define US_FLIDX_URB_ACTIVE 18 /* 0x00040000 current_urb is in use */ @@ -82,14 +76,9 @@ struct us_unusual_dev { #define ABORTING_OR_DISCONNECTING ((1UL << US_FLIDX_ABORTING) | \ (1UL << US_FLIDX_DISCONNECTING)) #define US_FLIDX_RESETTING 22 /* 0x00400000 device reset in progress */ +#define US_FLIDX_TIMED_OUT 23 /* 0x00800000 SCSI midlayer timed out */ -/* processing state machine states */ -#define US_STATE_IDLE 1 -#define US_STATE_RUNNING 2 -#define US_STATE_RESETTING 3 -#define US_STATE_ABORTING 4 - #define USB_STOR_STRING_LEN 32 /* @@ -100,19 +89,24 @@ struct us_unusual_dev { */ #define US_IOBUF_SIZE 64 /* Size of the DMA-mapped I/O buffer */ +#define US_SENSE_SIZE 18 /* Size of the autosense data buffer */ typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*); typedef int (*trans_reset)(struct us_data*); typedef void (*proto_cmnd)(struct scsi_cmnd*, struct us_data*); -typedef void (*extra_data_destructor)(void *); /* extra data destructor */ +typedef void (*extra_data_destructor)(void *); /* extra data destructor */ +typedef void (*pm_hook)(struct us_data *, int); /* power management hook */ + +#define US_SUSPEND 0 +#define US_RESUME 1 /* we allocate one of these for every device that we remember */ 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) you must hold dev_mutex to change pusb_dev */ - struct semaphore dev_semaphore; /* protect pusb_dev */ + struct mutex dev_mutex; /* protect pusb_dev */ struct usb_device *pusb_dev; /* this usb_device */ struct usb_interface *pusb_intf; /* this interface */ struct us_unusual_dev *unusual_dev; /* device-filter entry */ @@ -124,11 +118,9 @@ struct us_data { unsigned int recv_intr_pipe; /* information about the device */ - char vendor[USB_STOR_STRING_LEN]; - char product[USB_STOR_STRING_LEN]; - char serial[USB_STOR_STRING_LEN]; char *transport_name; char *protocol_name; + __le32 bcs_signature; u8 subclass; u8 protocol; u8 max_lun; @@ -142,33 +134,38 @@ struct us_data { proto_cmnd proto_handler; /* protocol handler */ /* SCSI interfaces */ - struct Scsi_Host *host; /* our dummy host data */ struct scsi_cmnd *srb; /* current srb */ - - /* thread information */ - int pid; /* control thread */ - int sm_state; /* what we are doing */ + unsigned int tag; /* current dCBWTag */ /* control and bulk communications data */ struct urb *current_urb; /* USB requests */ struct usb_ctrlrequest *cr; /* control requests */ struct usb_sg_request current_sg; /* scatter-gather req. */ unsigned char *iobuf; /* I/O buffer */ + unsigned char *sensebuf; /* sense data buffer */ dma_addr_t cr_dma; /* buffer DMA addresses */ dma_addr_t iobuf_dma; /* mutual exclusion and synchronization structures */ - struct semaphore sema; /* to sleep thread on */ - struct completion notify; /* thread begin/end */ - wait_queue_head_t dev_reset_wait; /* wait during reset */ + struct semaphore sema; /* to sleep thread on */ + struct completion notify; /* thread begin/end */ + wait_queue_head_t delay_wait; /* wait during scan, reset */ /* subdriver information */ void *extra; /* Any extra data */ extra_data_destructor extra_destructor;/* extra data destructor */ +#ifdef CONFIG_PM + pm_hook suspend_resume_hook; +#endif }; -/* The structure which defines our driver */ -extern struct usb_driver usb_storage_driver; +/* Convert between us_data and the corresponding Scsi_Host */ +static struct Scsi_Host inline *us_to_host(struct us_data *us) { + return container_of((void *) us, struct Scsi_Host, hostdata); +} +static struct us_data inline *host_to_us(struct Scsi_Host *host) { + return (struct us_data *) host->hostdata; +} /* Function to fill an inquiry response. See usb.c for details */ extern void fill_inquiry_response(struct us_data *us,