arch/sparc/kernel/of_device_common.c
Source file repositories/reference/linux-study-clean/arch/sparc/kernel/of_device_common.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/kernel/of_device_common.c- Extension
.c- Size
- 4056 bytes
- Lines
- 181
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/string.hlinux/kernel.hlinux/export.hlinux/mod_devicetable.hlinux/errno.hlinux/irq.hlinux/of.hlinux/of_platform.hlinux/of_address.hlinux/of_irq.hlinux/platform_device.hof_device_common.h
Detected Declarations
function irq_of_parse_and_mapfunction of_address_to_resourcefunction of_propagate_archdatafunction get_cellsfunction translatorfunction of_out_of_rangefunction of_bus_default_mapfunction of_bus_default_get_flagsfunction of_bus_sbus_matchfunction of_bus_sbus_count_cellsexport irq_of_parse_and_mapexport of_address_to_resourceexport of_iomap
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/export.h>
#include <linux/mod_devicetable.h>
#include <linux/errno.h>
#include <linux/irq.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/platform_device.h>
#include "of_device_common.h"
unsigned int irq_of_parse_and_map(struct device_node *node, int index)
{
struct platform_device *op = of_find_device_by_node(node);
if (!op || index >= op->archdata.num_irqs)
return 0;
return op->archdata.irqs[index];
}
EXPORT_SYMBOL(irq_of_parse_and_map);
int of_address_to_resource(struct device_node *node, int index,
struct resource *r)
{
struct platform_device *op = of_find_device_by_node(node);
if (!op || index >= op->num_resources)
return -EINVAL;
memcpy(r, &op->archdata.resource[index], sizeof(*r));
return 0;
}
EXPORT_SYMBOL_GPL(of_address_to_resource);
void __iomem *of_iomap(struct device_node *node, int index)
{
struct platform_device *op = of_find_device_by_node(node);
struct resource *r;
if (!op || index >= op->num_resources)
return NULL;
r = &op->archdata.resource[index];
return of_ioremap(r, 0, resource_size(r), (char *) r->name);
}
EXPORT_SYMBOL(of_iomap);
/* Take the archdata values for IOMMU, STC, and HOSTDATA found in
* BUS and propagate to all child platform_device objects.
*/
void of_propagate_archdata(struct platform_device *bus)
{
struct dev_archdata *bus_sd = &bus->dev.archdata;
struct device_node *bus_dp = bus->dev.of_node;
struct device_node *dp;
for (dp = bus_dp->child; dp; dp = dp->sibling) {
struct platform_device *op = of_find_device_by_node(dp);
op->dev.archdata.iommu = bus_sd->iommu;
op->dev.archdata.stc = bus_sd->stc;
op->dev.archdata.host_controller = bus_sd->host_controller;
op->dev.archdata.numa_node = bus_sd->numa_node;
op->dev.dma_ops = bus->dev.dma_ops;
if (dp->child)
of_propagate_archdata(op);
}
}
static void get_cells(struct device_node *dp, int *addrc, int *sizec)
{
if (addrc)
*addrc = of_n_addr_cells(dp);
if (sizec)
*sizec = of_n_size_cells(dp);
}
/*
* Default translator (generic bus)
*/
void of_bus_default_count_cells(struct device_node *dev, int *addrc, int *sizec)
{
Annotation
- Immediate include surface: `linux/string.h`, `linux/kernel.h`, `linux/export.h`, `linux/mod_devicetable.h`, `linux/errno.h`, `linux/irq.h`, `linux/of.h`, `linux/of_platform.h`.
- Detected declarations: `function irq_of_parse_and_map`, `function of_address_to_resource`, `function of_propagate_archdata`, `function get_cells`, `function translator`, `function of_out_of_range`, `function of_bus_default_map`, `function of_bus_default_get_flags`, `function of_bus_sbus_match`, `function of_bus_sbus_count_cells`.
- Atlas domain: Architecture Layer / arch/sparc.
- Implementation status: integration implementation candidate.
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.