drivers/pcmcia/electra_cf.c
Source file repositories/reference/linux-study-clean/drivers/pcmcia/electra_cf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pcmcia/electra_cf.c- Extension
.c- Size
- 7829 bytes
- Lines
- 353
- Domain
- Driver Families
- Bucket
- drivers/pcmcia
- 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.
- 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/kernel.hlinux/sched.hlinux/platform_device.hlinux/errno.hlinux/init.hlinux/delay.hlinux/interrupt.hlinux/mm.hlinux/vmalloc.hlinux/of_address.hlinux/of_irq.hlinux/of_platform.hlinux/slab.hpcmcia/ss.h
Detected Declarations
struct electra_cf_socketfunction electra_cf_presentfunction electra_cf_ss_initfunction electra_cf_timerfunction electra_cf_irqfunction electra_cf_get_statusfunction electra_cf_set_socketfunction electra_cf_set_io_mapfunction electra_cf_set_mem_mapfunction electra_cf_probefunction electra_cf_remove
Annotated Snippet
struct electra_cf_socket {
struct pcmcia_socket socket;
struct timer_list timer;
unsigned present:1;
unsigned active:1;
struct platform_device *ofdev;
unsigned long mem_phys;
void __iomem *mem_base;
unsigned long mem_size;
void __iomem *io_virt;
unsigned int io_base;
unsigned int io_size;
u_int irq;
struct resource iomem;
void __iomem *gpio_base;
int gpio_detect;
int gpio_vsense;
int gpio_3v;
int gpio_5v;
};
#define POLL_INTERVAL (2 * HZ)
static int electra_cf_present(struct electra_cf_socket *cf)
{
unsigned int gpio;
gpio = in_le32(cf->gpio_base+0x40);
return !(gpio & (1 << cf->gpio_detect));
}
static int electra_cf_ss_init(struct pcmcia_socket *s)
{
return 0;
}
/* the timer is primarily to kick this socket's pccardd */
static void electra_cf_timer(struct timer_list *t)
{
struct electra_cf_socket *cf = timer_container_of(cf, t, timer);
int present = electra_cf_present(cf);
if (present != cf->present) {
cf->present = present;
pcmcia_parse_events(&cf->socket, SS_DETECT);
}
if (cf->active)
mod_timer(&cf->timer, jiffies + POLL_INTERVAL);
}
static irqreturn_t electra_cf_irq(int irq, void *_cf)
{
struct electra_cf_socket *cf = _cf;
electra_cf_timer(&cf->timer);
return IRQ_HANDLED;
}
static int electra_cf_get_status(struct pcmcia_socket *s, u_int *sp)
{
struct electra_cf_socket *cf;
if (!sp)
return -EINVAL;
cf = container_of(s, struct electra_cf_socket, socket);
/* NOTE CF is always 3VCARD */
if (electra_cf_present(cf)) {
*sp = SS_READY | SS_DETECT | SS_POWERON | SS_3VCARD;
s->pci_irq = cf->irq;
} else
*sp = 0;
return 0;
}
static int electra_cf_set_socket(struct pcmcia_socket *sock,
struct socket_state_t *s)
{
unsigned int gpio;
unsigned int vcc;
struct electra_cf_socket *cf;
cf = container_of(sock, struct electra_cf_socket, socket);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/sched.h`, `linux/platform_device.h`, `linux/errno.h`, `linux/init.h`, `linux/delay.h`, `linux/interrupt.h`.
- Detected declarations: `struct electra_cf_socket`, `function electra_cf_present`, `function electra_cf_ss_init`, `function electra_cf_timer`, `function electra_cf_irq`, `function electra_cf_get_status`, `function electra_cf_set_socket`, `function electra_cf_set_io_map`, `function electra_cf_set_mem_map`, `function electra_cf_probe`.
- Atlas domain: Driver Families / drivers/pcmcia.
- Implementation status: source 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.