drivers/scsi/NCR5380.c
Source file repositories/reference/linux-study-clean/drivers/scsi/NCR5380.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/NCR5380.c- Extension
.c- Size
- 71560 bytes
- Lines
- 2411
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function initialize_SCpfunction advance_sg_bufferfunction set_resid_from_SCpfunction eventfunction NCR5380_printfunction NCR5380_print_phasefunction infofunction NCR5380_initfunction NCR5380_maybe_reset_busfunction queuedfunction complete_cmdfunction NCR5380_queue_commandfunction maybe_release_dma_irqfunction list_emptyfunction requeue_cmdfunction NCR5380_queue_commandfunction occursfunction lostfunction failedfunction NCR5380_transfer_piofunction do_resetfunction do_abortfunction NCR5380_transfer_dmafunction disconnectionfunction NCR5380_information_transferfunction NCR5380_reselectfunction list_find_cmdfunction list_del_cmdfunction commandfunction bus_reset_cleanupfunction list_for_each_entryfunction list_for_each_entryfunction NCR5380_host_resetfunction list_for_each_entry
Annotated Snippet
while (!sg_is_last(s)) {
s = sg_next(s);
resid += s->length;
}
scsi_set_resid(cmd, resid);
}
/**
* NCR5380_poll_politely2 - wait for two chip register values
* @hostdata: host private data
* @reg1: 5380 register to poll
* @bit1: Bitmask to check
* @val1: Expected value
* @reg2: Second 5380 register to poll
* @bit2: Second bitmask to check
* @val2: Second expected value
* @wait: Time-out in jiffies, 0 if sleeping is not allowed
*
* Polls the chip in a reasonably efficient manner waiting for an
* event to occur. After a short quick poll we begin to yield the CPU
* (if possible). In irq contexts the time-out is arbitrarily limited.
*
* Returns 0 if either or both event(s) occurred otherwise -ETIMEDOUT.
*/
static int NCR5380_poll_politely2(struct NCR5380_hostdata *hostdata,
unsigned int reg1, u8 bit1, u8 val1,
unsigned int reg2, u8 bit2, u8 val2,
unsigned long wait)
{
unsigned long n = hostdata->poll_loops;
unsigned long deadline = jiffies + wait;
do {
if ((NCR5380_read(reg1) & bit1) == val1)
return 0;
if ((NCR5380_read(reg2) & bit2) == val2)
return 0;
cpu_relax();
} while (n--);
if (!wait)
return -ETIMEDOUT;
/* Repeatedly sleep for 1 ms until deadline */
while (time_is_after_jiffies(deadline)) {
schedule_timeout_uninterruptible(1);
if ((NCR5380_read(reg1) & bit1) == val1)
return 0;
if ((NCR5380_read(reg2) & bit2) == val2)
return 0;
}
return -ETIMEDOUT;
}
#if NDEBUG
static struct {
unsigned char mask;
const char *name;
} signals[] = {
{SR_DBP, "PARITY"},
{SR_RST, "RST"},
{SR_BSY, "BSY"},
{SR_REQ, "REQ"},
{SR_MSG, "MSG"},
{SR_CD, "CD"},
{SR_IO, "IO"},
{SR_SEL, "SEL"},
{0, NULL}
},
basrs[] = {
{BASR_END_DMA_TRANSFER, "END OF DMA"},
{BASR_DRQ, "DRQ"},
{BASR_PARITY_ERROR, "PARITY ERROR"},
{BASR_IRQ, "IRQ"},
{BASR_PHASE_MATCH, "PHASE MATCH"},
{BASR_BUSY_ERROR, "BUSY ERROR"},
{BASR_ATN, "ATN"},
{BASR_ACK, "ACK"},
{0, NULL}
},
icrs[] = {
{ICR_ASSERT_RST, "ASSERT RST"},
{ICR_ARBITRATION_PROGRESS, "ARB. IN PROGRESS"},
{ICR_ARBITRATION_LOST, "LOST ARB."},
{ICR_ASSERT_ACK, "ASSERT ACK"},
{ICR_ASSERT_BSY, "ASSERT BSY"},
{ICR_ASSERT_SEL, "ASSERT SEL"},
{ICR_ASSERT_ATN, "ASSERT ATN"},
Annotation
- Detected declarations: `function initialize_SCp`, `function advance_sg_buffer`, `function set_resid_from_SCp`, `function event`, `function NCR5380_print`, `function NCR5380_print_phase`, `function info`, `function NCR5380_init`, `function NCR5380_maybe_reset_bus`, `function queued`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.