drivers/of/base.c
Source file repositories/reference/linux-study-clean/drivers/of/base.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/of/base.c- Extension
.c- Size
- 63441 bytes
- Lines
- 2372
- Domain
- Driver Families
- Bucket
- drivers/of
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cleanup.hlinux/console.hlinux/ctype.hlinux/cpu.hlinux/module.hlinux/of.hlinux/of_device.hlinux/of_graph.hlinux/spinlock.hlinux/slab.hlinux/string.hlinux/proc_fs.hof_private.h
Detected Declarations
function of_node_name_eqfunction of_node_name_prefixfunction __of_node_is_typefunction of_bus_n_addr_cellsfunction of_n_addr_cellsfunction of_bus_n_size_cellsfunction of_n_size_cellsfunction of_node_to_nidfunction of_phandle_cache_hashfunction __of_phandle_cache_inv_entryfunction of_core_initfunction of_node_putfunction __of_device_is_compatiblefunction of_device_is_compatiblefunction of_device_compatible_matchfunction of_machine_compatible_matchfunction of_machine_read_compatiblefunction of_machine_read_modelfunction __of_device_is_statusfunction __of_device_is_availablefunction __of_device_is_reservedfunction of_device_is_availablefunction __of_device_is_failfunction of_device_is_big_endianfunction of_node_putfunction of_get_parentfunction of_get_next_childfunction boolfunction of_get_next_childfunction of_get_next_childfunction CPUsfunction for_each_child_of_nodefunction of_node_putfunction of_node_putfunction __for_each_child_of_nodefunction nodefunction for_each_property_of_nodefunction of_node_putfunction of_node_putfunction of_node_putfunction of_node_putfunction of_node_putfunction prefixfunction of_node_putfunction of_print_phandle_argsfunction of_phandle_iterator_initfunction of_phandle_iterator_nextfunction of_phandle_iterator_args
Annotated Snippet
if (of_prop_cmp(pp->name, name) == 0) {
if (lenp)
*lenp = pp->length;
break;
}
}
return pp;
}
struct property *of_find_property(const struct device_node *np,
const char *name,
int *lenp)
{
struct property *pp;
unsigned long flags;
raw_spin_lock_irqsave(&devtree_lock, flags);
pp = __of_find_property(np, name, lenp);
raw_spin_unlock_irqrestore(&devtree_lock, flags);
return pp;
}
EXPORT_SYMBOL(of_find_property);
struct device_node *__of_find_all_nodes(struct device_node *prev)
{
struct device_node *np;
if (!prev) {
np = of_root;
} else if (prev->child) {
np = prev->child;
} else {
/* Walk back up looking for a sibling, or the end of the structure */
np = prev;
while (np->parent && !np->sibling)
np = np->parent;
np = np->sibling; /* Might be null at the end of the tree */
}
return np;
}
/**
* of_find_all_nodes - Get next node in global list
* @prev: Previous node or NULL to start iteration
* of_node_put() will be called on it
*
* Return: A node pointer with refcount incremented, use
* of_node_put() on it when done.
*/
struct device_node *of_find_all_nodes(struct device_node *prev)
{
struct device_node *np;
unsigned long flags;
raw_spin_lock_irqsave(&devtree_lock, flags);
np = __of_find_all_nodes(prev);
of_node_get(np);
of_node_put(prev);
raw_spin_unlock_irqrestore(&devtree_lock, flags);
return np;
}
EXPORT_SYMBOL(of_find_all_nodes);
/*
* Find a property with a given name for a given node
* and return the value.
*/
const void *__of_get_property(const struct device_node *np,
const char *name, int *lenp)
{
const struct property *pp = __of_find_property(np, name, lenp);
return pp ? pp->value : NULL;
}
/*
* Find a property with a given name for a given node
* and return the value.
*/
const void *of_get_property(const struct device_node *np, const char *name,
int *lenp)
{
const struct property *pp = of_find_property(np, name, lenp);
return pp ? pp->value : NULL;
}
EXPORT_SYMBOL(of_get_property);
/**
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/console.h`, `linux/ctype.h`, `linux/cpu.h`, `linux/module.h`, `linux/of.h`, `linux/of_device.h`, `linux/of_graph.h`.
- Detected declarations: `function of_node_name_eq`, `function of_node_name_prefix`, `function __of_node_is_type`, `function of_bus_n_addr_cells`, `function of_n_addr_cells`, `function of_bus_n_size_cells`, `function of_n_size_cells`, `function of_node_to_nid`, `function of_phandle_cache_hash`, `function __of_phandle_cache_inv_entry`.
- Atlas domain: Driver Families / drivers/of.
- Implementation status: integration 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.