drivers/pcmcia/ds.c
Source file repositories/reference/linux-study-clean/drivers/pcmcia/ds.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pcmcia/ds.c- Extension
.c- Size
- 35583 bytes
- Lines
- 1453
- Domain
- Driver Families
- Bucket
- drivers/pcmcia
- 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.
- 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/kernel.hlinux/module.hlinux/init.hlinux/errno.hlinux/list.hlinux/delay.hlinux/workqueue.hlinux/crc32.hlinux/firmware.hlinux/kref.hlinux/dma-mapping.hlinux/slab.hpcmcia/cistpl.hpcmcia/ds.hpcmcia/ss.hcs_internal.h
Detected Declarations
struct pcmcia_dynidfunction pcmcia_check_driverfunction new_id_storefunction pcmcia_free_dynidsfunction pcmcia_create_newid_filefunction pcmcia_remove_newid_filefunction pcmcia_register_driverfunction pcmcia_unregister_driverfunction pcmcia_put_devfunction pcmcia_release_functionfunction pcmcia_release_devfunction pcmcia_device_probefunction pcmcia_card_removefunction pcmcia_device_removefunction pcmcia_device_queryfunction pcmcia_card_addfunction pcmcia_requery_callbackfunction pcmcia_requeryfunction pcmcia_load_firmwarefunction pcmcia_load_firmwarefunction pcmcia_devmatchfunction pcmcia_bus_matchfunction pcmcia_bus_ueventfunction runtime_suspendfunction runtime_resumefunction function_showfunction resources_showfunction pm_state_showfunction pm_state_storefunction modalias_showfunction allow_func_id_match_storefunction pcmcia_dev_suspendfunction pcmcia_dev_resumefunction pcmcia_bus_suspend_callbackfunction pcmcia_bus_resume_callbackfunction pcmcia_bus_resumefunction pcmcia_bus_suspendfunction pcmcia_bus_removefunction pcmcia_bus_addfunction pcmcia_bus_early_resumefunction pcmcia_bus_add_socketfunction pcmcia_bus_remove_socketfunction init_pcmcia_busfunction exit_pcmcia_busmodule init init_pcmcia_busexport pcmcia_register_driverexport pcmcia_unregister_driverexport pcmcia_dev_present
Annotated Snippet
new_id_store(struct device_driver *driver, const char *buf, size_t count)
{
struct pcmcia_dynid *dynid;
struct pcmcia_driver *pdrv = to_pcmcia_drv(driver);
__u16 match_flags, manf_id, card_id;
__u8 func_id, function, device_no;
__u32 prod_id_hash[4] = {0, 0, 0, 0};
int fields = 0;
int retval = 0;
fields = sscanf(buf, "%hx %hx %hx %hhx %hhx %hhx %x %x %x %x",
&match_flags, &manf_id, &card_id, &func_id, &function, &device_no,
&prod_id_hash[0], &prod_id_hash[1], &prod_id_hash[2], &prod_id_hash[3]);
if (fields < 6)
return -EINVAL;
dynid = kzalloc_obj(struct pcmcia_dynid);
if (!dynid)
return -ENOMEM;
dynid->id.match_flags = match_flags;
dynid->id.manf_id = manf_id;
dynid->id.card_id = card_id;
dynid->id.func_id = func_id;
dynid->id.function = function;
dynid->id.device_no = device_no;
memcpy(dynid->id.prod_id_hash, prod_id_hash, sizeof(__u32) * 4);
mutex_lock(&pdrv->dynids.lock);
list_add_tail(&dynid->node, &pdrv->dynids.list);
mutex_unlock(&pdrv->dynids.lock);
retval = driver_attach(&pdrv->drv);
if (retval)
return retval;
return count;
}
static DRIVER_ATTR_WO(new_id);
static void
pcmcia_free_dynids(struct pcmcia_driver *drv)
{
struct pcmcia_dynid *dynid, *n;
mutex_lock(&drv->dynids.lock);
list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
list_del(&dynid->node);
kfree(dynid);
}
mutex_unlock(&drv->dynids.lock);
}
static int
pcmcia_create_newid_file(struct pcmcia_driver *drv)
{
int error = 0;
if (drv->probe != NULL)
error = driver_create_file(&drv->drv, &driver_attr_new_id);
return error;
}
static void
pcmcia_remove_newid_file(struct pcmcia_driver *drv)
{
driver_remove_file(&drv->drv, &driver_attr_new_id);
}
/**
* pcmcia_register_driver - register a PCMCIA driver with the bus core
* @driver: the &driver being registered
*
* Registers a PCMCIA driver with the PCMCIA bus core.
*/
int pcmcia_register_driver(struct pcmcia_driver *driver)
{
int error;
if (!driver)
return -EINVAL;
pcmcia_check_driver(driver);
/* initialize common fields */
driver->drv.bus = &pcmcia_bus_type;
driver->drv.owner = driver->owner;
driver->drv.name = driver->name;
mutex_init(&driver->dynids.lock);
INIT_LIST_HEAD(&driver->dynids.list);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/errno.h`, `linux/list.h`, `linux/delay.h`, `linux/workqueue.h`, `linux/crc32.h`.
- Detected declarations: `struct pcmcia_dynid`, `function pcmcia_check_driver`, `function new_id_store`, `function pcmcia_free_dynids`, `function pcmcia_create_newid_file`, `function pcmcia_remove_newid_file`, `function pcmcia_register_driver`, `function pcmcia_unregister_driver`, `function pcmcia_put_dev`, `function pcmcia_release_function`.
- Atlas domain: Driver Families / drivers/pcmcia.
- Implementation status: pattern 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.