drivers/firewire/core-device.c
Source file repositories/reference/linux-study-clean/drivers/firewire/core-device.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firewire/core-device.c- Extension
.c- Size
- 38993 bytes
- Lines
- 1446
- Domain
- Driver Families
- Bucket
- drivers/firewire
- 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/bug.hlinux/ctype.hlinux/delay.hlinux/device.hlinux/errno.hlinux/firewire.hlinux/firewire-constants.hlinux/jiffies.hlinux/kobject.hlinux/list.hlinux/mod_devicetable.hlinux/module.hlinux/mutex.hlinux/random.hlinux/rwsem.hlinux/slab.hlinux/spinlock.hlinux/string.hlinux/workqueue.hlinux/atomic.hasm/byteorder.hcore.hdevice-attribute-test.c
Detected Declarations
struct config_rom_attributestruct entry_matchfunction Copyrightfunction fw_csr_iterator_nextfunction textual_leaf_to_stringfunction fw_csr_stringfunction get_idsfunction get_modalias_idsfunction match_idsfunction fw_unit_matchfunction fw_unit_probefunction fw_unit_removefunction get_modaliasfunction fw_unit_ueventfunction fw_device_enable_phys_dmafunction show_immediatefunction show_text_leaffunction init_fw_attribute_groupfunction modalias_showfunction rom_index_showfunction config_rom_showfunction guid_showfunction is_local_showfunction units_sprintffunction units_showfunction detect_quirks_by_bus_information_blockfunction detect_quirks_by_root_directoryfunction read_romfunction read_config_romfunction entryfunction scoped_guardfunction fw_unit_releasefunction is_fw_unitfunction create_unitsfunction shutdown_unitfunction fw_schedule_device_workfunction fw_device_shutdownfunction fw_device_releasefunction is_fw_devicefunction update_unitfunction fw_device_updatefunction set_broadcast_channelfunction fw_device_set_broadcast_channelfunction compare_configuration_romfunction fw_device_initfunction fw_node_eventfunction reread_config_romfunction fw_device_refresh
Annotated Snippet
const struct device_driver *drv)
{
const struct ieee1394_device_id *id_table =
container_of_const(drv, struct fw_driver, driver)->id_table;
int id[] = {0, 0, 0, 0};
get_modalias_ids(fw_unit(dev), id);
for (; id_table->match_flags != 0; id_table++)
if (match_ids(id_table, id))
return id_table;
return NULL;
}
static bool is_fw_unit(const struct device *dev);
static int fw_unit_match(struct device *dev, const struct device_driver *drv)
{
/* We only allow binding to fw_units. */
return is_fw_unit(dev) && unit_match(dev, drv) != NULL;
}
static int fw_unit_probe(struct device *dev)
{
struct fw_driver *driver =
container_of(dev->driver, struct fw_driver, driver);
return driver->probe(fw_unit(dev), unit_match(dev, dev->driver));
}
static void fw_unit_remove(struct device *dev)
{
struct fw_driver *driver =
container_of(dev->driver, struct fw_driver, driver);
driver->remove(fw_unit(dev));
}
static int get_modalias(const struct fw_unit *unit, char *buffer, size_t buffer_size)
{
int id[] = {0, 0, 0, 0};
get_modalias_ids(unit, id);
return snprintf(buffer, buffer_size,
"ieee1394:ven%08Xmo%08Xsp%08Xver%08X",
id[0], id[1], id[2], id[3]);
}
static int fw_unit_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const struct fw_unit *unit = fw_unit(dev);
char modalias[64];
get_modalias(unit, modalias, sizeof(modalias));
if (add_uevent_var(env, "MODALIAS=%s", modalias))
return -ENOMEM;
return 0;
}
const struct bus_type fw_bus_type = {
.name = "firewire",
.match = fw_unit_match,
.probe = fw_unit_probe,
.remove = fw_unit_remove,
};
EXPORT_SYMBOL(fw_bus_type);
int fw_device_enable_phys_dma(struct fw_device *device)
{
int generation = device->generation;
/* device->node_id, accessed below, must not be older than generation */
smp_rmb();
return device->card->driver->enable_phys_dma(device->card,
device->node_id,
generation);
}
EXPORT_SYMBOL(fw_device_enable_phys_dma);
struct config_rom_attribute {
struct device_attribute attr;
u32 key;
};
static ssize_t show_immediate(struct device *dev,
Annotation
- Immediate include surface: `linux/bug.h`, `linux/ctype.h`, `linux/delay.h`, `linux/device.h`, `linux/errno.h`, `linux/firewire.h`, `linux/firewire-constants.h`, `linux/jiffies.h`.
- Detected declarations: `struct config_rom_attribute`, `struct entry_match`, `function Copyright`, `function fw_csr_iterator_next`, `function textual_leaf_to_string`, `function fw_csr_string`, `function get_ids`, `function get_modalias_ids`, `function match_ids`, `function fw_unit_match`.
- Atlas domain: Driver Families / drivers/firewire.
- 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.