drivers/parport/parport_pc.c
Source file repositories/reference/linux-study-clean/drivers/parport/parport_pc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/parport/parport_pc.c- Extension
.c- Size
- 90063 bytes
- Lines
- 3409
- Domain
- Driver Families
- Bucket
- drivers/parport
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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.
- 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/module.hlinux/init.hlinux/sched/signal.hlinux/delay.hlinux/errno.hlinux/interrupt.hlinux/ioport.hlinux/kernel.hlinux/slab.hlinux/dma-mapping.hlinux/pci.hlinux/pnp.hlinux/platform_device.hlinux/sysctl.hlinux/io.hlinux/uaccess.hasm/dma.hlinux/parport.hlinux/parport_pc.hlinux/via.hasm/parport.h
Detected Declarations
struct pci_parport_dataenum parport_pc_sio_typesenum parport_pc_pci_cardsfunction frob_econtrolfunction frob_set_modefunction change_modefunction clear_epp_timeoutfunction parport_pc_init_statefunction parport_pc_save_statefunction parport_pc_restore_statefunction parport_pc_epp_read_datafunction parport_pc_epp_write_datafunction parport_pc_epp_read_addrfunction parport_pc_epp_write_addrfunction parport_pc_ecpepp_read_datafunction parport_pc_ecpepp_write_datafunction parport_pc_ecpepp_read_addrfunction parport_pc_ecpepp_write_addrfunction parport_pc_fifo_write_block_piofunction parport_pc_fifo_write_block_dmafunction parport_pc_fifo_write_blockfunction parport_pc_compat_write_block_piofunction parport_pc_ecp_write_block_piofunction show_parconfig_smsc37c669function show_parconfig_winbondfunction decode_winbondfunction decode_smscfunction winbond_checkfunction winbond_check2function smsc_checkfunction detect_and_report_winbondfunction detect_and_report_smscfunction detect_and_report_it87function get_superio_dmafunction get_superio_irqfunction parport_SPP_supportedfunction parport_ECR_presentfunction parport_PS2_supportedfunction parport_ECP_supportedfunction intel_bug_present_check_eppfunction intel_bug_presentfunction intel_bug_presentfunction parport_ECPPS2_supportedfunction parport_EPP_supportedfunction parport_ECPEPP_supportedfunction parport_PS2_supportedfunction parport_ECP_supportedfunction parport_EPP_supported
Annotated Snippet
static struct pci_driver parport_pc_pci_driver = {
.name = "parport_pc",
.id_table = parport_pc_pci_tbl,
.probe = parport_pc_pci_probe,
.remove = parport_pc_pci_remove,
};
static int __init parport_pc_init_superio(int autoirq, int autodma)
{
const struct pci_device_id *id;
struct pci_dev *pdev = NULL;
int ret = 0;
for_each_pci_dev(pdev) {
id = pci_match_id(parport_pc_pci_tbl, pdev);
if (id == NULL || id->driver_data >= last_sio)
continue;
if (parport_pc_superio_info[id->driver_data].probe(
pdev, autoirq, autodma,
parport_pc_superio_info[id->driver_data].via)) {
ret++;
}
}
return ret; /* number of devices found */
}
#else
static struct pci_driver parport_pc_pci_driver;
static int __init parport_pc_init_superio(int autoirq, int autodma)
{
return 0;
}
#endif /* CONFIG_PCI */
#ifdef CONFIG_PNP
static const struct pnp_device_id parport_pc_pnp_tbl[] = {
/* Standard LPT Printer Port */
{.id = "PNP0400", .driver_data = 0},
/* ECP Printer Port */
{.id = "PNP0401", .driver_data = 0},
{ }
};
MODULE_DEVICE_TABLE(pnp, parport_pc_pnp_tbl);
static int parport_pc_pnp_probe(struct pnp_dev *dev,
const struct pnp_device_id *id)
{
struct parport *pdata;
unsigned long io_lo, io_hi;
int dma, irq;
if (pnp_port_valid(dev, 0) &&
!(pnp_port_flags(dev, 0) & IORESOURCE_DISABLED)) {
io_lo = pnp_port_start(dev, 0);
} else
return -EINVAL;
if (pnp_port_valid(dev, 1) &&
!(pnp_port_flags(dev, 1) & IORESOURCE_DISABLED)) {
io_hi = pnp_port_start(dev, 1);
} else
io_hi = 0;
if (pnp_irq_valid(dev, 0) &&
!(pnp_irq_flags(dev, 0) & IORESOURCE_DISABLED)) {
irq = pnp_irq(dev, 0);
} else
irq = PARPORT_IRQ_NONE;
if (pnp_dma_valid(dev, 0) &&
!(pnp_dma_flags(dev, 0) & IORESOURCE_DISABLED)) {
dma = pnp_dma(dev, 0);
} else
dma = PARPORT_DMA_NONE;
dev_info(&dev->dev, "reported by %s\n", dev->protocol->name);
pdata = parport_pc_probe_port(io_lo, io_hi, irq, dma, &dev->dev, 0);
if (pdata == NULL)
return -ENODEV;
pnp_set_drvdata(dev, pdata);
return 0;
}
static void parport_pc_pnp_remove(struct pnp_dev *dev)
{
struct parport *pdata = (struct parport *)pnp_get_drvdata(dev);
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/sched/signal.h`, `linux/delay.h`, `linux/errno.h`, `linux/interrupt.h`, `linux/ioport.h`, `linux/kernel.h`.
- Detected declarations: `struct pci_parport_data`, `enum parport_pc_sio_types`, `enum parport_pc_pci_cards`, `function frob_econtrol`, `function frob_set_mode`, `function change_mode`, `function clear_epp_timeout`, `function parport_pc_init_state`, `function parport_pc_save_state`, `function parport_pc_restore_state`.
- Atlas domain: Driver Families / drivers/parport.
- Implementation status: pattern 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.