drivers/usb/storage/alauda.c
Source file repositories/reference/linux-study-clean/drivers/usb/storage/alauda.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/storage/alauda.c- Extension
.c- Size
- 33545 bytes
- Lines
- 1275
- 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/module.hlinux/slab.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_device.husb.htransport.hprotocol.hdebug.hscsiglue.hunusual_alauda.h
Detected Declarations
struct alauda_media_infostruct alauda_infostruct alauda_card_infofunction nand_init_eccfunction nand_compute_eccfunction nand_compare_eccfunction nand_store_eccfunction alauda_free_mapsfunction alauda_get_media_statusfunction alauda_ack_mediafunction alauda_get_media_signaturefunction statusfunction alauda_init_mediafunction alauda_check_mediafunction alauda_check_status2function alauda_get_redu_datafunction alauda_find_unused_pbafunction alauda_read_mapfunction blocksfunction alauda_ensure_map_for_zonefunction alauda_erase_blockfunction alauda_read_block_rawfunction holdfunction alauda_write_blockfunction alauda_write_lbafunction alauda_read_datafunction alauda_write_datafunction alauda_info_destructorfunction init_alaudafunction alauda_transportfunction alauda_probe
Annotated Snippet
struct alauda_media_info {
unsigned long capacity; /* total media size in bytes */
unsigned int pagesize; /* page size in bytes */
unsigned int blocksize; /* number of pages per block */
unsigned int uzonesize; /* number of usable blocks per zone */
unsigned int zonesize; /* number of blocks per zone */
unsigned int blockmask; /* mask to get page from address */
unsigned char pageshift;
unsigned char blockshift;
unsigned char zoneshift;
u16 **lba_to_pba; /* logical to physical block map */
u16 **pba_to_lba; /* physical to logical block map */
};
struct alauda_info {
struct alauda_media_info port[2];
int wr_ep; /* endpoint to write data out of */
unsigned char sense_key;
unsigned long sense_asc; /* additional sense code */
unsigned long sense_ascq; /* additional sense code qualifier */
bool media_initialized;
};
#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) )
#define LSB_of(s) ((s)&0xFF)
#define MSB_of(s) ((s)>>8)
#define MEDIA_PORT(us) us->srb->device->lun
#define MEDIA_INFO(us) ((struct alauda_info *)us->extra)->port[MEDIA_PORT(us)]
#define PBA_LO(pba) ((pba & 0xF) << 5)
#define PBA_HI(pba) (pba >> 3)
#define PBA_ZONE(pba) (pba >> 11)
static int init_alauda(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 alauda_usb_ids[] = {
# include "unusual_alauda.h"
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, alauda_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 alauda_unusual_dev_list[] = {
# include "unusual_alauda.h"
{ } /* Terminating entry */
};
#undef UNUSUAL_DEV
/*
* Media handling
*/
struct alauda_card_info {
unsigned char id; /* id byte */
unsigned char chipshift; /* 1<<cs bytes total capacity */
unsigned char pageshift; /* 1<<ps bytes in a page */
unsigned char blockshift; /* 1<<bs pages per block */
unsigned char zoneshift; /* 1<<zs blocks per zone */
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `scsi/scsi.h`, `scsi/scsi_cmnd.h`, `scsi/scsi_device.h`, `usb.h`, `transport.h`, `protocol.h`.
- Detected declarations: `struct alauda_media_info`, `struct alauda_info`, `struct alauda_card_info`, `function nand_init_ecc`, `function nand_compute_ecc`, `function nand_compare_ecc`, `function nand_store_ecc`, `function alauda_free_maps`, `function alauda_get_media_status`, `function alauda_ack_media`.
- 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.