drivers/bus/sunxi-rsb.c
Source file repositories/reference/linux-study-clean/drivers/bus/sunxi-rsb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bus/sunxi-rsb.c- Extension
.c- Size
- 21409 bytes
- Lines
- 874
- Domain
- Driver Families
- Bucket
- drivers/bus
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/clk.hlinux/clk/clk-conf.hlinux/device.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/module.hlinux/of.hlinux/of_irq.hlinux/of_device.hlinux/platform_device.hlinux/pm.hlinux/pm_runtime.hlinux/regmap.hlinux/reset.hlinux/slab.hlinux/sunxi-rsb.hlinux/types.h
Detected Declarations
struct sunxi_rsb_addr_mapstruct sunxi_rsbstruct sunxi_rsb_ctxfunction sunxi_rsb_device_matchfunction sunxi_rsb_device_probefunction sunxi_rsb_device_removefunction sunxi_rsb_device_modaliasfunction sunxi_rsb_dev_releasefunction sunxi_rsb_device_createfunction sunxi_rsb_device_unregisterfunction sunxi_rsb_remove_devicesfunction sunxi_rsb_driver_registerfunction _sunxi_rsb_run_xferfunction sunxi_rsb_readfunction sunxi_rsb_writefunction regmap_sunxi_rsb_reg_readfunction regmap_sunxi_rsb_reg_writefunction regmap_sunxi_rsb_free_ctxfunction sunxi_rsb_irqfunction sunxi_rsb_init_device_modefunction sunxi_rsb_get_rtaddrfunction of_rsb_register_devicesfunction sunxi_rsb_hw_initfunction sunxi_rsb_hw_exitfunction sunxi_rsb_runtime_suspendfunction sunxi_rsb_runtime_resumefunction sunxi_rsb_suspendfunction sunxi_rsb_resumefunction sunxi_rsb_probefunction sunxi_rsb_removefunction sunxi_rsb_initfunction sunxi_rsb_exitmodule init sunxi_rsb_initexport sunxi_rsb_driver_registerexport __devm_regmap_init_sunxi_rsb
Annotated Snippet
static const struct bus_type sunxi_rsb_bus;
static int sunxi_rsb_device_match(struct device *dev, const struct device_driver *drv)
{
return of_driver_match_device(dev, drv);
}
static int sunxi_rsb_device_probe(struct device *dev)
{
const struct sunxi_rsb_driver *drv = to_sunxi_rsb_driver(dev->driver);
struct sunxi_rsb_device *rdev = to_sunxi_rsb_device(dev);
int ret;
if (!drv->probe)
return -ENODEV;
if (!rdev->irq) {
int irq = -ENOENT;
if (dev->of_node)
irq = of_irq_get(dev->of_node, 0);
if (irq == -EPROBE_DEFER)
return irq;
if (irq < 0)
irq = 0;
rdev->irq = irq;
}
ret = of_clk_set_defaults(dev->of_node, false);
if (ret < 0)
return ret;
return drv->probe(rdev);
}
static void sunxi_rsb_device_remove(struct device *dev)
{
const struct sunxi_rsb_driver *drv = to_sunxi_rsb_driver(dev->driver);
drv->remove(to_sunxi_rsb_device(dev));
}
static int sunxi_rsb_device_modalias(const struct device *dev, struct kobj_uevent_env *env)
{
return of_device_uevent_modalias(dev, env);
}
static const struct bus_type sunxi_rsb_bus = {
.name = RSB_CTRL_NAME,
.match = sunxi_rsb_device_match,
.probe = sunxi_rsb_device_probe,
.remove = sunxi_rsb_device_remove,
.uevent = sunxi_rsb_device_modalias,
};
static void sunxi_rsb_dev_release(struct device *dev)
{
struct sunxi_rsb_device *rdev = to_sunxi_rsb_device(dev);
kfree(rdev);
}
/**
* sunxi_rsb_device_create() - allocate and add an RSB device
* @rsb: RSB controller
* @node: RSB slave device node
* @hwaddr: RSB slave hardware address
* @rtaddr: RSB slave runtime address
*/
static struct sunxi_rsb_device *sunxi_rsb_device_create(struct sunxi_rsb *rsb,
struct device_node *node, u16 hwaddr, u8 rtaddr)
{
int err;
struct sunxi_rsb_device *rdev;
rdev = kzalloc_obj(*rdev);
if (!rdev)
return ERR_PTR(-ENOMEM);
rdev->rsb = rsb;
rdev->hwaddr = hwaddr;
rdev->rtaddr = rtaddr;
rdev->dev.bus = &sunxi_rsb_bus;
rdev->dev.parent = rsb->dev;
rdev->dev.of_node = node;
rdev->dev.release = sunxi_rsb_dev_release;
dev_set_name(&rdev->dev, "%s-%x", RSB_CTRL_NAME, hwaddr);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clk/clk-conf.h`, `linux/device.h`, `linux/interrupt.h`, `linux/io.h`, `linux/iopoll.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct sunxi_rsb_addr_map`, `struct sunxi_rsb`, `struct sunxi_rsb_ctx`, `function sunxi_rsb_device_match`, `function sunxi_rsb_device_probe`, `function sunxi_rsb_device_remove`, `function sunxi_rsb_device_modalias`, `function sunxi_rsb_dev_release`, `function sunxi_rsb_device_create`, `function sunxi_rsb_device_unregister`.
- Atlas domain: Driver Families / drivers/bus.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.