drivers/scsi/sr_vendor.c
Source file repositories/reference/linux-study-clean/drivers/scsi/sr_vendor.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/sr_vendor.c- Extension
.c- Size
- 9010 bytes
- Lines
- 341
- Domain
- Driver Families
- Bucket
- drivers/scsi
- 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/cdrom.hlinux/errno.hlinux/string.hlinux/bcd.hlinux/blkdev.hlinux/slab.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_host.hscsi/scsi_ioctl.hsr.h
Detected Declarations
function featuresfunction sr_read_sectorfunction sr_cd_check
Annotated Snippet
if ((buffer[0] << 8) + buffer[1] < 0x0a) {
sr_printk(KERN_INFO, cd, "Hmm, seems the drive "
"doesn't support multisession CD's\n");
no_multi = 1;
break;
}
sector = buffer[11] + (buffer[10] << 8) +
(buffer[9] << 16) + (buffer[8] << 24);
if (buffer[6] <= 1) {
/* ignore sector offsets from first track */
sector = 0;
}
break;
case VENDOR_NEC:{
unsigned long min, sec, frame;
cgc.cmd[0] = 0xde;
cgc.cmd[1] = 0x03;
cgc.cmd[2] = 0xb0;
cgc.buffer = buffer;
cgc.buflen = 0x16;
cgc.quiet = 1;
cgc.data_direction = DMA_FROM_DEVICE;
cgc.timeout = VENDOR_TIMEOUT;
rc = sr_do_ioctl(cd, &cgc);
if (rc != 0)
break;
if (buffer[14] != 0 && buffer[14] != 0xb0) {
sr_printk(KERN_INFO, cd, "Hmm, seems the cdrom "
"doesn't support multisession CD's\n");
no_multi = 1;
break;
}
min = bcd2bin(buffer[15]);
sec = bcd2bin(buffer[16]);
frame = bcd2bin(buffer[17]);
sector = min * CD_SECS * CD_FRAMES + sec * CD_FRAMES + frame;
break;
}
case VENDOR_TOSHIBA:{
unsigned long min, sec, frame;
/* we request some disc information (is it a XA-CD ?,
* where starts the last session ?) */
cgc.cmd[0] = 0xc7;
cgc.cmd[1] = 0x03;
cgc.buffer = buffer;
cgc.buflen = 4;
cgc.quiet = 1;
cgc.data_direction = DMA_FROM_DEVICE;
cgc.timeout = VENDOR_TIMEOUT;
rc = sr_do_ioctl(cd, &cgc);
if (rc == -EINVAL) {
sr_printk(KERN_INFO, cd, "Hmm, seems the drive "
"doesn't support multisession CD's\n");
no_multi = 1;
break;
}
if (rc != 0)
break;
min = bcd2bin(buffer[1]);
sec = bcd2bin(buffer[2]);
frame = bcd2bin(buffer[3]);
sector = min * CD_SECS * CD_FRAMES + sec * CD_FRAMES + frame;
if (sector)
sector -= CD_MSF_OFFSET;
sr_set_blocklength(cd, 2048);
break;
}
case VENDOR_WRITER:
cgc.cmd[0] = READ_TOC;
cgc.cmd[8] = 0x04;
cgc.cmd[9] = 0x40;
cgc.buffer = buffer;
cgc.buflen = 0x04;
cgc.quiet = 1;
cgc.data_direction = DMA_FROM_DEVICE;
cgc.timeout = VENDOR_TIMEOUT;
rc = sr_do_ioctl(cd, &cgc);
if (rc != 0) {
break;
}
if ((rc = buffer[2]) == 0) {
sr_printk(KERN_WARNING, cd,
"No finished session\n");
break;
}
Annotation
- Immediate include surface: `linux/cdrom.h`, `linux/errno.h`, `linux/string.h`, `linux/bcd.h`, `linux/blkdev.h`, `linux/slab.h`, `scsi/scsi.h`, `scsi/scsi_cmnd.h`.
- Detected declarations: `function features`, `function sr_read_sector`, `function sr_cd_check`.
- Atlas domain: Driver Families / drivers/scsi.
- 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.