drivers/scsi/imm.c
Source file repositories/reference/linux-study-clean/drivers/scsi/imm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/imm.c- Extension
.c- Size
- 30481 bytes
- Lines
- 1283
- 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.
- 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/init.hlinux/kernel.hlinux/module.hlinux/blkdev.hlinux/parport.hlinux/workqueue.hlinux/delay.hlinux/slab.hasm/io.hscsi/scsi.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_host.himm.h
Detected Declarations
function got_itfunction imm_wakeupfunction imm_pb_claimfunction imm_pb_dismissfunction imm_pb_releasefunction timingsfunction imm_show_infofunction imm_fail_funcfunction imm_waitfunction imm_negotiatefunction epp_resetfunction fifofunction imm_byte_outfunction imm_nibble_infunction imm_byte_infunction imm_outfunction imm_infunction imm_cppfunction imm_connectfunction imm_disconnectfunction imm_selectfunction imm_initfunction imm_send_commandfunction imm_completionfunction imm_interruptfunction imm_enginefunction imm_queuecommand_lckfunction DEF_SCSI_QCMDfunction imm_abortfunction imm_reset_pulsefunction imm_resetfunction device_checkfunction list_for_each_entryfunction __imm_attachfunction imm_attachfunction imm_detach
Annotated Snippet
if (parport_claim(dev->dev) == 0) {
got_it(dev);
dev->wanted = 0;
}
}
spin_unlock_irqrestore(&arbitration_lock, flags);
}
static int imm_pb_claim(imm_struct *dev)
{
unsigned long flags;
int res = 1;
spin_lock_irqsave(&arbitration_lock, flags);
if (parport_claim(dev->dev) == 0) {
got_it(dev);
res = 0;
}
dev->wanted = res;
spin_unlock_irqrestore(&arbitration_lock, flags);
return res;
}
static void imm_pb_dismiss(imm_struct *dev)
{
unsigned long flags;
int wanted;
spin_lock_irqsave(&arbitration_lock, flags);
wanted = dev->wanted;
dev->wanted = 0;
spin_unlock_irqrestore(&arbitration_lock, flags);
if (!wanted)
parport_release(dev->dev);
}
static inline void imm_pb_release(imm_struct *dev)
{
parport_release(dev->dev);
}
/* This is to give the imm driver a way to modify the timings (and other
* parameters) by writing to the /proc/scsi/imm/0 file.
* Very simple method really... (Too simple, no error checking :( )
* Reason: Kernel hackers HATE having to unload and reload modules for
* testing...
* Also gives a method to use a script to obtain optimum timings (TODO)
*/
static int imm_write_info(struct Scsi_Host *host, char *buffer, int length)
{
imm_struct *dev = imm_dev(host);
if ((length > 5) && (strncmp(buffer, "mode=", 5) == 0)) {
dev->mode = simple_strtoul(buffer + 5, NULL, 0);
return length;
}
printk("imm /proc: invalid variable\n");
return -EINVAL;
}
static int imm_show_info(struct seq_file *m, struct Scsi_Host *host)
{
imm_struct *dev = imm_dev(host);
seq_printf(m, "Version : %s\n", IMM_VERSION);
seq_printf(m, "Parport : %s\n", dev->dev->port->name);
seq_printf(m, "Mode : %s\n", IMM_MODE_STRING[dev->mode]);
return 0;
}
#if IMM_DEBUG > 0
#define imm_fail(x,y) printk("imm: imm_fail(%i) from %s at line %d\n",\
y, __func__, __LINE__); imm_fail_func(x,y);
static inline void
imm_fail_func(imm_struct *dev, int error_code)
#else
static inline void
imm_fail(imm_struct *dev, int error_code)
#endif
{
/* If we fail a device then we trash status / message bytes */
if (dev->cur_cmd) {
dev->cur_cmd->result = error_code << 16;
dev->failed = 1;
}
}
/*
* Wait for the high bit to be set.
*
* In principle, this could be tied to an interrupt, but the adapter
* doesn't appear to be designed to support interrupts. We spin on
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/blkdev.h`, `linux/parport.h`, `linux/workqueue.h`, `linux/delay.h`, `linux/slab.h`.
- Detected declarations: `function got_it`, `function imm_wakeup`, `function imm_pb_claim`, `function imm_pb_dismiss`, `function imm_pb_release`, `function timings`, `function imm_show_info`, `function imm_fail_func`, `function imm_wait`, `function imm_negotiate`.
- 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.
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.