drivers/pnp/resource.c
Source file repositories/reference/linux-study-clean/drivers/pnp/resource.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pnp/resource.c- Extension
.c- Size
- 17098 bytes
- Lines
- 756
- Domain
- Driver Families
- Bucket
- drivers/pnp
- 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.
- 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/slab.hlinux/errno.hlinux/interrupt.hlinux/kernel.hasm/io.hasm/dma.hasm/irq.hlinux/pci.hlinux/libata.hlinux/ioport.hlinux/init.hlinux/pnp.hbase.h
Detected Declarations
function pnp_register_irq_resourcefunction pnp_register_dma_resourcefunction pnp_register_port_resourcefunction pnp_register_mem_resourcefunction pnp_free_optionsfunction list_for_each_entry_safefunction pnp_check_portfunction pnp_check_memfunction pnp_test_handlerfunction pci_dev_uses_irqfunction pci_uses_irqfunction for_each_pci_devfunction pnp_check_irqfunction pnp_check_dmafunction pnp_resource_typefunction list_for_each_entryfunction pnp_possible_configfunction list_for_each_entryfunction pnp_range_reservedfunction pnp_for_each_devfunction pnp_setup_reserve_irqfunction pnp_setup_reserve_dmafunction pnp_setup_reserve_iofunction pnp_setup_reserve_memexport pnp_get_resourceexport pnp_possible_configexport pnp_range_reserved
Annotated Snippet
if (tres != res && tres->flags & IORESOURCE_IO) {
tport = &tres->start;
tend = &tres->end;
if (ranged_conflict(port, end, tport, tend))
return 0;
}
}
/* check for conflicts with other pnp devices */
pnp_for_each_dev(tdev) {
if (tdev == dev)
continue;
for (i = 0;
(tres = pnp_get_resource(tdev, IORESOURCE_IO, i));
i++) {
if (tres->flags & IORESOURCE_IO) {
if (cannot_compare(tres->flags))
continue;
if (tres->flags & IORESOURCE_WINDOW)
continue;
tport = &tres->start;
tend = &tres->end;
if (ranged_conflict(port, end, tport, tend))
return 0;
}
}
}
return 1;
}
int pnp_check_mem(struct pnp_dev *dev, struct resource *res)
{
int i;
struct pnp_dev *tdev;
struct resource *tres;
resource_size_t *addr, *end, *taddr, *tend;
addr = &res->start;
end = &res->end;
/* if the resource doesn't exist, don't complain about it */
if (cannot_compare(res->flags))
return 1;
/* check if the resource is already in use, skip if the
* device is active because it itself may be in use */
if (!dev->active) {
if (!request_mem_region(*addr, length(addr, end), "pnp"))
return 0;
release_mem_region(*addr, length(addr, end));
}
/* check if the resource is reserved */
for (i = 0; i < 8; i++) {
int raddr = pnp_reserve_mem[i << 1];
int rend = pnp_reserve_mem[(i << 1) + 1] + raddr - 1;
if (ranged_conflict(addr, end, &raddr, &rend))
return 0;
}
/* check for internal conflicts */
for (i = 0; (tres = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
if (tres != res && tres->flags & IORESOURCE_MEM) {
taddr = &tres->start;
tend = &tres->end;
if (ranged_conflict(addr, end, taddr, tend))
return 0;
}
}
/* check for conflicts with other pnp devices */
pnp_for_each_dev(tdev) {
if (tdev == dev)
continue;
for (i = 0;
(tres = pnp_get_resource(tdev, IORESOURCE_MEM, i));
i++) {
if (tres->flags & IORESOURCE_MEM) {
if (cannot_compare(tres->flags))
continue;
if (tres->flags & IORESOURCE_WINDOW)
continue;
taddr = &tres->start;
tend = &tres->end;
if (ranged_conflict(addr, end, taddr, tend))
return 0;
}
}
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/errno.h`, `linux/interrupt.h`, `linux/kernel.h`, `asm/io.h`, `asm/dma.h`, `asm/irq.h`.
- Detected declarations: `function pnp_register_irq_resource`, `function pnp_register_dma_resource`, `function pnp_register_port_resource`, `function pnp_register_mem_resource`, `function pnp_free_options`, `function list_for_each_entry_safe`, `function pnp_check_port`, `function pnp_check_mem`, `function pnp_test_handler`, `function pci_dev_uses_irq`.
- Atlas domain: Driver Families / drivers/pnp.
- Implementation status: integration implementation candidate.
- 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.