/* SPDX-License-Identifier: GPL-2.0+ */ /* * Driver for USB Mass Storage compliant devices * Main Header File * * Current development and maintenance by: * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) * * Initial work by: * (c) 1999 Michael Gee (michael@linuxspecific.com) * * This driver is based on the 'USB Mass Storage Class' document. This * describes in detail the protocol used to communicate with such * devices. Clearly, the designers had SCSI and ATAPI commands in * mind when they created this document. The commands are all very * similar to commands in the SCSI-II and ATAPI specifications. * * It is important to note that in a number of cases this class * exhibits class-specific exemptions from the USB specification. * Notably the usage of NAK, STALL and ACK differs from the norm, in * that they are used to communicate wait, failed and OK on commands. * * Also, for certain devices, the interrupt endpoint is used to convey * status of a command.
*/
/* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */ #define US_FLIDX_URB_ACTIVE 0 /* current_urb is in use */ #define US_FLIDX_SG_ACTIVE 1 /* current_sg is in use */ #define US_FLIDX_ABORTING 2 /* abort is in progress */ #define US_FLIDX_DISCONNECTING 3 /* disconnect in progress */ #define US_FLIDX_RESETTING 4 /* device reset in progress */ #define US_FLIDX_TIMED_OUT 5 /* SCSI midlayer timed out */ #define US_FLIDX_SCAN_PENDING 6 /* scanning not yet done */ #define US_FLIDX_REDO_READ10 7 /* redo READ(10) command */ #define US_FLIDX_READ10_WORKED 8 /* previous READ(10) succeeded */
#define USB_STOR_STRING_LEN 32
/* * We provide a DMA-mapped I/O buffer for use with small USB transfers. * It turns out that CB[I] needs a 12-byte buffer and Bulk-only needs a * 31-byte buffer. But Freecom needs a 64-byte buffer, so that's the * size we'll allocate.
*/
#define US_IOBUF_SIZE 64 /* Size of the DMA-mapped I/O buffer */ #define US_SENSE_SIZE 18 /* Size of the autosense data buffer */
/* 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_mutex to change pusb_dev
*/ struct mutex dev_mutex; /* protect pusb_dev */ struct usb_device *pusb_dev; /* this usb_device */ struct usb_interface *pusb_intf; /* this interface */ conststruct us_unusual_dev *unusual_dev; /* device-filter entry */
u64 fflags; /* fixed flags from filter */ unsignedlong dflags; /* dynamic atomic bitflags */ unsignedint send_bulk_pipe; /* cached pipe values */ unsignedint recv_bulk_pipe; unsignedint send_ctrl_pipe; unsignedint recv_ctrl_pipe; unsignedint recv_intr_pipe;
/* information about the device */ char *transport_name; char *protocol_name;
__le32 bcs_signature;
u8 subclass;
u8 protocol;
u8 max_lun;
/* function pointers for this device */
trans_cmnd transport; /* transport function */
trans_reset transport_reset; /* transport device reset */
proto_cmnd proto_handler; /* protocol handler */
/* SCSI interfaces */ struct scsi_cmnd *srb; /* current srb */ unsignedint tag; /* current dCBWTag */ char scsi_name[32]; /* scsi_host name */
/* 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. */ unsignedchar *iobuf; /* I/O buffer */
dma_addr_t iobuf_dma; /* buffer DMA addresses */ struct task_struct *ctl_thread; /* the control thread */
/* mutual exclusion and synchronization structures */ struct completion cmnd_ready; /* to sleep thread on */ struct completion notify; /* thread begin/end */
wait_queue_head_t delay_wait; /* wait during reset */ struct delayed_work scan_dwork; /* for async scanning */
/* subdriver information */ void *extra; /* Any extra data */
extra_data_destructor extra_destructor;/* extra data destructor */ #ifdef CONFIG_PM
pm_hook suspend_resume_hook; #endif
/* hacks for READ CAPACITY bug handling */ int use_last_sector_hacks; int last_sector_retries;
};
/* Function to fill an inquiry response. See usb.c for details */ externvoid fill_inquiry_response(struct us_data *us, unsignedchar *data, unsignedint data_len);
/* * The scsi_lock() and scsi_unlock() macros protect the sm_state and the * single queue element srb for write access
*/ #define scsi_unlock(host) spin_unlock_irq(host->host_lock) #define scsi_lock(host) spin_lock_irq(host->host_lock)
/* General routines provided by the usb-storage standard core */ #ifdef CONFIG_PM externint usb_stor_suspend(struct usb_interface *iface, pm_message_t message); externint usb_stor_resume(struct usb_interface *iface); externint usb_stor_reset_resume(struct usb_interface *iface); #else #define usb_stor_suspend NULL #define usb_stor_resume NULL #define usb_stor_reset_resume NULL #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.