drivers/pcmcia/pcmcia_resource.c
Source file repositories/reference/linux-study-clean/drivers/pcmcia/pcmcia_resource.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pcmcia/pcmcia_resource.c- Extension
.c- Size
- 24668 bytes
- Lines
- 956
- Domain
- Driver Families
- Bucket
- drivers/pcmcia
- 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.
- 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
linux/module.hlinux/kernel.hlinux/interrupt.hlinux/delay.hlinux/pci.hlinux/device.hlinux/netdevice.hlinux/slab.hasm/irq.hpcmcia/ss.hpcmcia/cistpl.hpcmcia/cisreg.hpcmcia/ds.hcs_internal.h
Detected Declarations
function pcmcia_validate_memfunction release_io_spacefunction alloc_io_spacefunction pcmcia_access_configfunction pcmcia_read_config_bytefunction pcmcia_write_config_bytefunction pcmcia_map_mem_pagefunction pcmcia_fixup_iowidthfunction pcmcia_fixup_vppfunction pcmcia_release_configurationfunction pcmcia_release_iofunction pcmcia_release_windowfunction pcmcia_enable_devicefunction pcmcia_request_iofunction pcmcia_request_irqfunction test_actionfunction pcmcia_setup_isa_irqfunction pcmcia_cleanup_irqfunction pcmcia_setup_isa_irqfunction pcmcia_cleanup_irqfunction pcmcia_setup_irqfunction pcmcia_request_windowfunction pcmcia_disable_deviceexport pcmcia_read_config_byteexport pcmcia_write_config_byteexport pcmcia_map_mem_pageexport pcmcia_fixup_iowidthexport pcmcia_fixup_vppexport pcmcia_release_windowexport pcmcia_enable_deviceexport pcmcia_request_ioexport pcmcia_request_irqexport pcmcia_request_windowexport pcmcia_disable_device
Annotated Snippet
if (s->io[i].InUse == 0) {
release_resource(s->io[i].res);
kfree(s->io[i].res);
s->io[i].res = NULL;
}
}
}
}
/**
* alloc_io_space() - allocate IO ports for use by a PCMCIA device
* @s: pcmcia socket
* @res: resource to allocate (begin: begin, end: size)
* @lines: number of IO lines decoded by the PCMCIA card
*
* Special stuff for managing IO windows, because they are scarce
*/
static int alloc_io_space(struct pcmcia_socket *s, struct resource *res,
unsigned int lines)
{
unsigned int align;
unsigned int base = res->start;
unsigned int num = res->end;
int ret;
res->flags |= IORESOURCE_IO;
dev_dbg(&s->dev, "alloc_io_space request for %pR, %d lines\n",
res, lines);
align = base ? (lines ? 1<<lines : 0) : 1;
if (align && (align < num)) {
if (base) {
dev_dbg(&s->dev, "odd IO request\n");
align = 0;
} else
while (align && (align < num))
align <<= 1;
}
if (base & ~(align-1)) {
dev_dbg(&s->dev, "odd IO request\n");
align = 0;
}
ret = s->resource_ops->find_io(s, res->flags, &base, num, align,
&res->parent);
if (ret) {
dev_dbg(&s->dev, "alloc_io_space request failed (%d)\n", ret);
return -EINVAL;
}
res->start = base;
res->end = res->start + num - 1;
if (res->parent) {
ret = request_resource(res->parent, res);
if (ret) {
dev_warn(&s->dev,
"request_resource %pR failed: %d\n", res, ret);
res->parent = NULL;
release_io_space(s, res);
}
}
dev_dbg(&s->dev, "alloc_io_space request result %d: %pR\n", ret, res);
return ret;
}
/*
* pcmcia_access_config() - read or write card configuration registers
*
* pcmcia_access_config() reads and writes configuration registers in
* attribute memory. Memory window 0 is reserved for this and the tuple
* reading services. Drivers must use pcmcia_read_config_byte() or
* pcmcia_write_config_byte().
*/
static int pcmcia_access_config(struct pcmcia_device *p_dev,
off_t where, u8 *val,
int (*accessf) (struct pcmcia_socket *s,
int attr, unsigned int addr,
unsigned int len, void *ptr))
{
struct pcmcia_socket *s;
config_t *c;
int addr;
int ret = 0;
s = p_dev->socket;
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/pci.h`, `linux/device.h`, `linux/netdevice.h`, `linux/slab.h`.
- Detected declarations: `function pcmcia_validate_mem`, `function release_io_space`, `function alloc_io_space`, `function pcmcia_access_config`, `function pcmcia_read_config_byte`, `function pcmcia_write_config_byte`, `function pcmcia_map_mem_page`, `function pcmcia_fixup_iowidth`, `function pcmcia_fixup_vpp`, `function pcmcia_release_configuration`.
- Atlas domain: Driver Families / drivers/pcmcia.
- Implementation status: integration 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.