drivers/net/can/m_can/m_can_platform.c
Source file repositories/reference/linux-study-clean/drivers/net/can/m_can/m_can_platform.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/m_can/m_can_platform.c- Extension
.c- Size
- 5787 bytes
- Lines
- 243
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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 or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/hrtimer.hlinux/phy/phy.hlinux/platform_device.hm_can.h
Detected Declarations
struct m_can_plat_privfunction iomap_read_regfunction iomap_read_fifofunction iomap_write_regfunction iomap_write_fifofunction m_can_plat_probefunction m_can_suspendfunction m_can_resumefunction m_can_plat_removefunction m_can_runtime_suspendfunction m_can_runtime_resume
Annotated Snippet
struct m_can_plat_priv {
struct m_can_classdev cdev;
void __iomem *base;
void __iomem *mram_base;
};
static inline struct m_can_plat_priv *cdev_to_priv(struct m_can_classdev *cdev)
{
return container_of(cdev, struct m_can_plat_priv, cdev);
}
static u32 iomap_read_reg(struct m_can_classdev *cdev, int reg)
{
struct m_can_plat_priv *priv = cdev_to_priv(cdev);
return readl(priv->base + reg);
}
static int iomap_read_fifo(struct m_can_classdev *cdev, int offset, void *val, size_t val_count)
{
struct m_can_plat_priv *priv = cdev_to_priv(cdev);
void __iomem *src = priv->mram_base + offset;
while (val_count--) {
*(unsigned int *)val = ioread32(src);
val += 4;
src += 4;
}
return 0;
}
static int iomap_write_reg(struct m_can_classdev *cdev, int reg, int val)
{
struct m_can_plat_priv *priv = cdev_to_priv(cdev);
writel(val, priv->base + reg);
return 0;
}
static int iomap_write_fifo(struct m_can_classdev *cdev, int offset,
const void *val, size_t val_count)
{
struct m_can_plat_priv *priv = cdev_to_priv(cdev);
void __iomem *dst = priv->mram_base + offset;
while (val_count--) {
iowrite32(*(unsigned int *)val, dst);
val += 4;
dst += 4;
}
return 0;
}
static const struct m_can_ops m_can_plat_ops = {
.read_reg = iomap_read_reg,
.write_reg = iomap_write_reg,
.write_fifo = iomap_write_fifo,
.read_fifo = iomap_read_fifo,
};
static int m_can_plat_probe(struct platform_device *pdev)
{
struct m_can_classdev *mcan_class;
struct m_can_plat_priv *priv;
struct resource *res;
void __iomem *addr;
void __iomem *mram_addr;
struct phy *transceiver;
int irq = 0, ret = 0;
mcan_class = m_can_class_allocate_dev(&pdev->dev,
sizeof(struct m_can_plat_priv));
if (IS_ERR(mcan_class))
return PTR_ERR(mcan_class);
priv = cdev_to_priv(mcan_class);
ret = m_can_class_get_clocks(mcan_class);
if (ret)
goto probe_fail;
addr = devm_platform_ioremap_resource_byname(pdev, "m_can");
if (IS_ERR(addr)) {
ret = PTR_ERR(addr);
goto probe_fail;
}
Annotation
- Immediate include surface: `linux/hrtimer.h`, `linux/phy/phy.h`, `linux/platform_device.h`, `m_can.h`.
- Detected declarations: `struct m_can_plat_priv`, `function iomap_read_reg`, `function iomap_read_fifo`, `function iomap_write_reg`, `function iomap_write_fifo`, `function m_can_plat_probe`, `function m_can_suspend`, `function m_can_resume`, `function m_can_plat_remove`, `function m_can_runtime_suspend`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.