drivers/pnp/manager.c
Source file repositories/reference/linux-study-clean/drivers/pnp/manager.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pnp/manager.c- Extension
.c- Size
- 10057 bytes
- Lines
- 430
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/module.hlinux/init.hlinux/kernel.hlinux/pnp.hlinux/bitmap.hlinux/mutex.hbase.h
Detected Declarations
function pnp_assign_portfunction pnp_assign_memfunction pnp_assign_irqfunction pnp_assign_dmafunction pnp_init_resourcesfunction pnp_clean_resource_tablefunction list_for_each_entry_safefunction pnp_assign_resourcesfunction list_for_each_entryfunction pnp_auto_config_devfunction pnp_start_devfunction pnp_stop_devfunction pnp_activate_devfunction pnp_disable_devexport pnp_start_devexport pnp_stop_devexport pnp_activate_devexport pnp_disable_dev
Annotated Snippet
if (res->start > rule->max || !rule->align) {
pnp_dbg(&dev->dev, " couldn't assign io %d "
"(min %#llx max %#llx)\n", idx,
(unsigned long long) rule->min,
(unsigned long long) rule->max);
return -EBUSY;
}
}
__add:
pnp_add_io_resource(dev, res->start, res->end, res->flags);
return 0;
}
static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
{
struct resource *res, local_res;
res = pnp_find_resource(dev, rule->flags, IORESOURCE_MEM, idx);
if (res) {
pnp_dbg(&dev->dev, " mem %d already set to %#llx-%#llx "
"flags %#lx\n", idx, (unsigned long long) res->start,
(unsigned long long) res->end, res->flags);
return 0;
}
res = &local_res;
res->flags = rule->flags | IORESOURCE_AUTO;
res->start = 0;
res->end = 0;
/* ??? rule->flags restricted to 8 bits, all tests bogus ??? */
if (!(rule->flags & IORESOURCE_MEM_WRITEABLE))
res->flags |= IORESOURCE_READONLY;
if (rule->flags & IORESOURCE_MEM_RANGELENGTH)
res->flags |= IORESOURCE_RANGELENGTH;
if (rule->flags & IORESOURCE_MEM_SHADOWABLE)
res->flags |= IORESOURCE_SHADOWABLE;
if (!rule->size) {
res->flags |= IORESOURCE_DISABLED;
pnp_dbg(&dev->dev, " mem %d disabled\n", idx);
goto __add;
}
res->start = rule->min;
res->end = res->start + rule->size - 1;
while (!pnp_check_mem(dev, res)) {
res->start += rule->align;
res->end = res->start + rule->size - 1;
if (res->start > rule->max || !rule->align) {
pnp_dbg(&dev->dev, " couldn't assign mem %d "
"(min %#llx max %#llx)\n", idx,
(unsigned long long) rule->min,
(unsigned long long) rule->max);
return -EBUSY;
}
}
__add:
pnp_add_mem_resource(dev, res->start, res->end, res->flags);
return 0;
}
static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx)
{
struct resource *res, local_res;
int i;
/* IRQ priority: this table is good for i386 */
static unsigned short xtab[16] = {
5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2
};
res = pnp_find_resource(dev, rule->flags, IORESOURCE_IRQ, idx);
if (res) {
pnp_dbg(&dev->dev, " irq %d already set to %d flags %#lx\n",
idx, (int) res->start, res->flags);
return 0;
}
res = &local_res;
res->flags = rule->flags | IORESOURCE_AUTO;
res->start = -1;
res->end = -1;
if (bitmap_empty(rule->map.bits, PNP_IRQ_NR)) {
res->flags |= IORESOURCE_DISABLED;
pnp_dbg(&dev->dev, " irq %d disabled\n", idx);
Annotation
- Immediate include surface: `linux/errno.h`, `linux/module.h`, `linux/init.h`, `linux/kernel.h`, `linux/pnp.h`, `linux/bitmap.h`, `linux/mutex.h`, `base.h`.
- Detected declarations: `function pnp_assign_port`, `function pnp_assign_mem`, `function pnp_assign_irq`, `function pnp_assign_dma`, `function pnp_init_resources`, `function pnp_clean_resource_table`, `function list_for_each_entry_safe`, `function pnp_assign_resources`, `function list_for_each_entry`, `function pnp_auto_config_dev`.
- Atlas domain: Driver Families / drivers/pnp.
- Implementation status: integration 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.