drivers/usb/storage/scsiglue.c
Source file repositories/reference/linux-study-clean/drivers/usb/storage/scsiglue.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/storage/scsiglue.c- Extension
.c- Size
- 20690 bytes
- Lines
- 700
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/blkdev.hlinux/dma-mapping.hlinux/module.hlinux/mutex.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_devinfo.hscsi/scsi_device.hscsi/scsi_eh.husb.hscsiglue.hdebug.htransport.hprotocol.h
Detected Declarations
function host_infofunction sdev_initfunction sdev_configurefunction target_allocfunction queuecommand_lckfunction DEF_SCSI_QCMDfunction command_abortfunction device_resetfunction bus_resetfunction usb_stor_report_device_resetfunction usb_stor_report_bus_resetfunction write_infofunction show_infofunction max_sectors_showfunction max_sectors_storefunction usb_stor_host_template_initexport usb_stor_host_template_initexport usb_stor_sense_invalidCDB
Annotated Snippet
switch (le16_to_cpu(us->pusb_dev->descriptor.idVendor)) {
case VENDOR_ID_NOKIA:
case VENDOR_ID_NIKON:
case VENDOR_ID_PENTAX:
case VENDOR_ID_MOTOROLA:
if (!(us->fflags & (US_FL_FIX_CAPACITY |
US_FL_CAPACITY_OK)))
us->fflags |= US_FL_CAPACITY_HEURISTICS;
break;
}
/*
* Disk-type devices use MODE SENSE(6) if the protocol
* (SubClass) is Transparent SCSI, otherwise they use
* MODE SENSE(10).
*/
if (us->subclass != USB_SC_SCSI && us->subclass != USB_SC_CYP_ATACB)
sdev->use_10_for_ms = 1;
/*
*Many disks only accept MODE SENSE transfer lengths of
* 192 bytes (that's what Windows uses).
*/
sdev->use_192_bytes_for_3f = 1;
/*
* Some devices report generic values until the media has been
* accessed. Force a READ(10) prior to querying device
* characteristics.
*/
sdev->read_before_ms = 1;
/*
* Some devices don't like MODE SENSE with page=0x3f,
* which is the command used for checking if a device
* is write-protected. Now that we tell the sd driver
* to do a 192-byte transfer with this command the
* majority of devices work fine, but a few still can't
* handle it. The sd driver will simply assume those
* devices are write-enabled.
*/
if (us->fflags & US_FL_NO_WP_DETECT)
sdev->skip_ms_page_3f = 1;
/*
* A number of devices have problems with MODE SENSE for
* page x08, so we will skip it.
*/
sdev->skip_ms_page_8 = 1;
/*
* Some devices don't handle VPD pages correctly, so skip vpd
* pages if not forced by SCSI layer.
*/
sdev->skip_vpd_pages = !sdev->try_vpd_pages;
/* Do not attempt to use REPORT SUPPORTED OPERATION CODES */
sdev->no_report_opcodes = 1;
/* Do not attempt to use WRITE SAME */
sdev->no_write_same = 1;
/*
* Some disks return the total number of blocks in response
* to READ CAPACITY rather than the highest block number.
* If this device makes that mistake, tell the sd driver.
*/
if (us->fflags & US_FL_FIX_CAPACITY)
sdev->fix_capacity = 1;
/*
* A few disks have two indistinguishable version, one of
* which reports the correct capacity and the other does not.
* The sd driver has to guess which is the case.
*/
if (us->fflags & US_FL_CAPACITY_HEURISTICS)
sdev->guess_capacity = 1;
/* Some devices cannot handle READ_CAPACITY_16 */
if (us->fflags & US_FL_NO_READ_CAPACITY_16)
sdev->no_read_capacity_16 = 1;
/*
* Many devices do not respond properly to READ_CAPACITY_16.
* Tell the SCSI layer to try READ_CAPACITY_10 first.
* However some USB 3.0 drive enclosures return capacity
* modulo 2TB. Those must use READ_CAPACITY_16
*/
if (!(us->fflags & US_FL_NEEDS_CAP16))
sdev->try_rc_10_first = 1;
Annotation
- Immediate include surface: `linux/blkdev.h`, `linux/dma-mapping.h`, `linux/module.h`, `linux/mutex.h`, `scsi/scsi.h`, `scsi/scsi_cmnd.h`, `scsi/scsi_devinfo.h`, `scsi/scsi_device.h`.
- Detected declarations: `function host_info`, `function sdev_init`, `function sdev_configure`, `function target_alloc`, `function queuecommand_lck`, `function DEF_SCSI_QCMD`, `function command_abort`, `function device_reset`, `function bus_reset`, `function usb_stor_report_device_reset`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.