drivers/bcma/main.c
Source file repositories/reference/linux-study-clean/drivers/bcma/main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bcma/main.c- Extension
.c- Size
- 16594 bytes
- Lines
- 706
- Domain
- Driver Families
- Bucket
- drivers/bcma
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
bcma_private.hlinux/module.hlinux/mmc/sdio_func.hlinux/platform_device.hlinux/pci.hlinux/bcma/bcma.hlinux/slab.hlinux/of_address.hlinux/of_irq.hlinux/of_device.hlinux/of_platform.h
Detected Declarations
function manuf_showfunction id_showfunction rev_showfunction class_showfunction bcma_cc_core_idfunction list_for_each_entryfunction bcma_wait_valuefunction bcma_release_core_devfunction bcma_is_core_needed_earlyfunction for_each_child_of_nodefunction bcma_of_irq_parsefunction bcma_of_get_irqfunction bcma_of_fill_devicefunction bcma_core_irqfunction bcma_prepare_corefunction bcma_init_busfunction bcma_register_corefunction bcma_register_devicesfunction list_for_each_entryfunction bcma_unregister_coresfunction list_for_each_entry_safefunction bcma_bus_registerfunction bcma_bus_unregisterfunction bcma_bus_early_registerfunction bcma_bus_suspendfunction list_for_each_entryfunction bcma_bus_resumefunction list_for_each_entryfunction __bcma_driver_registerfunction bcma_driver_unregisterfunction bcma_bus_matchfunction bcma_device_probefunction bcma_device_removefunction bcma_device_ueventfunction bcma_init_bus_registerfunction bcma_modinitfunction bcma_modexitmodule init bcma_init_bus_registermodule init bcma_modinitexport bcma_find_core_unitexport bcma_core_irqexport __bcma_driver_registerexport bcma_driver_unregister
Annotated Snippet
static int bcma_bus_match(struct device *dev, const struct device_driver *drv);
static int bcma_device_probe(struct device *dev);
static void bcma_device_remove(struct device *dev);
static int bcma_device_uevent(const struct device *dev, struct kobj_uevent_env *env);
static ssize_t manuf_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
return sprintf(buf, "0x%03X\n", core->id.manuf);
}
static DEVICE_ATTR_RO(manuf);
static ssize_t id_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
return sprintf(buf, "0x%03X\n", core->id.id);
}
static DEVICE_ATTR_RO(id);
static ssize_t rev_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
return sprintf(buf, "0x%02X\n", core->id.rev);
}
static DEVICE_ATTR_RO(rev);
static ssize_t class_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct bcma_device *core = container_of(dev, struct bcma_device, dev);
return sprintf(buf, "0x%X\n", core->id.class);
}
static DEVICE_ATTR_RO(class);
static struct attribute *bcma_device_attrs[] = {
&dev_attr_manuf.attr,
&dev_attr_id.attr,
&dev_attr_rev.attr,
&dev_attr_class.attr,
NULL,
};
ATTRIBUTE_GROUPS(bcma_device);
static const struct bus_type bcma_bus_type = {
.name = "bcma",
.match = bcma_bus_match,
.probe = bcma_device_probe,
.remove = bcma_device_remove,
.uevent = bcma_device_uevent,
.dev_groups = bcma_device_groups,
};
static u16 bcma_cc_core_id(struct bcma_bus *bus)
{
if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
return BCMA_CORE_4706_CHIPCOMMON;
return BCMA_CORE_CHIPCOMMON;
}
struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
u8 unit)
{
struct bcma_device *core;
list_for_each_entry(core, &bus->cores, list) {
if (core->id.id == coreid && core->core_unit == unit)
return core;
}
return NULL;
}
EXPORT_SYMBOL_GPL(bcma_find_core_unit);
bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
int timeout)
{
unsigned long deadline = jiffies + timeout;
u32 val;
do {
val = bcma_read32(core, reg);
if ((val & mask) == value)
return true;
cpu_relax();
udelay(10);
} while (!time_after_eq(jiffies, deadline));
bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
return false;
}
Annotation
- Immediate include surface: `bcma_private.h`, `linux/module.h`, `linux/mmc/sdio_func.h`, `linux/platform_device.h`, `linux/pci.h`, `linux/bcma/bcma.h`, `linux/slab.h`, `linux/of_address.h`.
- Detected declarations: `function manuf_show`, `function id_show`, `function rev_show`, `function class_show`, `function bcma_cc_core_id`, `function list_for_each_entry`, `function bcma_wait_value`, `function bcma_release_core_dev`, `function bcma_is_core_needed_early`, `function for_each_child_of_node`.
- Atlas domain: Driver Families / drivers/bcma.
- 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.