drivers/usb/storage/shuttle_usbat.c
Source file repositories/reference/linux-study-clean/drivers/usb/storage/shuttle_usbat.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/storage/shuttle_usbat.c- Extension
.c- Size
- 49410 bytes
- Lines
- 1873
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/module.hlinux/slab.hlinux/string_choices.hlinux/cdrom.hscsi/scsi.hscsi/scsi_cmnd.husb.htransport.hprotocol.hdebug.hscsiglue.hunusual_usbat.h
Detected Declarations
struct usbat_infofunction usbat_pack_ata_sector_cmdfunction typefunction usbat_readfunction usbat_writefunction usbat_bulk_readfunction usbat_bulk_writefunction onefunction usbat_get_statusfunction usbat_check_statusfunction usbat_set_shuttle_featuresfunction usbat_wait_not_busyfunction usbat_read_blockfunction usbat_write_blockfunction usbat_hp8200e_rw_block_testfunction usbat_multiple_writefunction usbat_read_blocksfunction usbat_write_blocksfunction usbat_read_user_iofunction usbat_write_user_iofunction usbat_device_resetfunction usbat_device_enable_cdtfunction usbat_flash_check_media_presentfunction usbat_flash_check_media_changedfunction usbat_flash_check_mediafunction usbat_identify_devicefunction usbat_set_transportfunction usbat_flash_get_sector_countfunction usbat_flash_read_datafunction usbat_flash_write_datafunction hugefunction commandfunction usbat_select_and_test_registersfunction init_usbatfunction usbat_hp8200e_transportfunction usbat_flash_transportfunction init_usbat_cdfunction init_usbat_flashfunction usbat_probe
Annotated Snippet
struct usbat_info {
int devicetype;
/* Used for Flash readers only */
unsigned long sectors; /* total sector count */
unsigned long ssize; /* sector size in bytes */
unsigned char sense_key;
unsigned long sense_asc; /* additional sense code */
unsigned long sense_ascq; /* additional sense code qualifier */
};
#define short_pack(LSB,MSB) ( ((u16)(LSB)) | ( ((u16)(MSB))<<8 ) )
#define LSB_of(s) ((s)&0xFF)
#define MSB_of(s) ((s)>>8)
static int transferred = 0;
static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us);
static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us);
static int init_usbat_cd(struct us_data *us);
static int init_usbat_flash(struct us_data *us);
/*
* The table of devices
*/
#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
vendorName, productName, useProtocol, useTransport, \
initFunction, flags) \
{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
.driver_info = (flags) }
static const struct usb_device_id usbat_usb_ids[] = {
# include "unusual_usbat.h"
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, usbat_usb_ids);
#undef UNUSUAL_DEV
/*
* The flags table
*/
#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
vendor_name, product_name, use_protocol, use_transport, \
init_function, Flags) \
{ \
.vendorName = vendor_name, \
.productName = product_name, \
.useProtocol = use_protocol, \
.useTransport = use_transport, \
.initFunction = init_function, \
}
static const struct us_unusual_dev usbat_unusual_dev_list[] = {
# include "unusual_usbat.h"
{ } /* Terminating entry */
};
#undef UNUSUAL_DEV
/*
* Convenience function to produce an ATA read/write sectors command
* Use cmd=0x20 for read, cmd=0x30 for write
*/
static void usbat_pack_ata_sector_cmd(unsigned char *buf,
unsigned char thistime,
u32 sector, unsigned char cmd)
{
buf[0] = 0;
buf[1] = thistime;
buf[2] = sector & 0xFF;
buf[3] = (sector >> 8) & 0xFF;
buf[4] = (sector >> 16) & 0xFF;
buf[5] = 0xE0 | ((sector >> 24) & 0x0F);
buf[6] = cmd;
}
/*
* Convenience function to get the device type (flash or hp8200)
*/
static int usbat_get_device_type(struct us_data *us)
{
return ((struct usbat_info*)us->extra)->devicetype;
}
/*
* Read a register from the device
Annotation
- Immediate include surface: `linux/errno.h`, `linux/module.h`, `linux/slab.h`, `linux/string_choices.h`, `linux/cdrom.h`, `scsi/scsi.h`, `scsi/scsi_cmnd.h`, `usb.h`.
- Detected declarations: `struct usbat_info`, `function usbat_pack_ata_sector_cmd`, `function type`, `function usbat_read`, `function usbat_write`, `function usbat_bulk_read`, `function usbat_bulk_write`, `function one`, `function usbat_get_status`, `function usbat_check_status`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.