drivers/usb/storage/protocol.c
Source file repositories/reference/linux-study-clean/drivers/usb/storage/protocol.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/storage/protocol.c- Extension
.c- Size
- 5325 bytes
- Lines
- 181
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/highmem.hlinux/export.hscsi/scsi.hscsi/scsi_cmnd.husb.hprotocol.hdebug.hscsiglue.htransport.h
Detected Declarations
function usb_stor_pad12_commandfunction usb_stor_ufi_commandfunction usb_stor_transparent_scsi_commandfunction usb_stor_access_xfer_buffunction usb_stor_set_xfer_bufexport usb_stor_transparent_scsi_commandexport usb_stor_access_xfer_bufexport usb_stor_set_xfer_buf
Annotated Snippet
if (*offset + len < miter.piter.sg->length) {
*offset += len;
*sgptr = miter.piter.sg;
} else {
*offset = 0;
*sgptr = sg_next(miter.piter.sg);
}
cnt += len;
}
sg_miter_stop(&miter);
return cnt;
}
EXPORT_SYMBOL_GPL(usb_stor_access_xfer_buf);
/*
* Store the contents of buffer into srb's transfer buffer and set the
* SCSI residue.
*/
void usb_stor_set_xfer_buf(unsigned char *buffer,
unsigned int buflen, struct scsi_cmnd *srb)
{
unsigned int offset = 0;
struct scatterlist *sg = NULL;
buflen = min(buflen, scsi_bufflen(srb));
buflen = usb_stor_access_xfer_buf(buffer, buflen, srb, &sg, &offset,
TO_XFER_BUF);
if (buflen < scsi_bufflen(srb))
scsi_set_resid(srb, scsi_bufflen(srb) - buflen);
}
EXPORT_SYMBOL_GPL(usb_stor_set_xfer_buf);
Annotation
- Immediate include surface: `linux/highmem.h`, `linux/export.h`, `scsi/scsi.h`, `scsi/scsi_cmnd.h`, `usb.h`, `protocol.h`, `debug.h`, `scsiglue.h`.
- Detected declarations: `function usb_stor_pad12_command`, `function usb_stor_ufi_command`, `function usb_stor_transparent_scsi_command`, `function usb_stor_access_xfer_buf`, `function usb_stor_set_xfer_buf`, `export usb_stor_transparent_scsi_command`, `export usb_stor_access_xfer_buf`, `export usb_stor_set_xfer_buf`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: integration 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.