drivers/power/reset/nvmem-reboot-mode.c
Source file repositories/reference/linux-study-clean/drivers/power/reset/nvmem-reboot-mode.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/reset/nvmem-reboot-mode.c- Extension
.c- Size
- 2181 bytes
- Lines
- 88
- Domain
- Driver Families
- Bucket
- drivers/power
- 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.
- 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/init.hlinux/module.hlinux/kernel.hlinux/of.hlinux/nvmem-consumer.hlinux/platform_device.hlinux/reboot-mode.hlinux/slab.h
Detected Declarations
struct nvmem_reboot_modefunction nvmem_reboot_mode_writefunction nvmem_reboot_mode_probe
Annotated Snippet
struct nvmem_reboot_mode {
struct reboot_mode_driver reboot;
struct nvmem_cell *cell;
};
static int nvmem_reboot_mode_write(struct reboot_mode_driver *reboot,
unsigned int magic)
{
struct nvmem_reboot_mode *nvmem_rbm;
size_t buf_len;
void *buf;
int ret;
nvmem_rbm = container_of(reboot, struct nvmem_reboot_mode, reboot);
buf = nvmem_cell_read(nvmem_rbm->cell, &buf_len);
if (IS_ERR(buf))
return PTR_ERR(buf);
kfree(buf);
if (buf_len > sizeof(magic))
return -EINVAL;
ret = nvmem_cell_write(nvmem_rbm->cell, &magic, buf_len);
if (ret < 0)
dev_err(reboot->dev, "update reboot mode bits failed\n");
return ret;
}
static int nvmem_reboot_mode_probe(struct platform_device *pdev)
{
int ret;
struct nvmem_reboot_mode *nvmem_rbm;
nvmem_rbm = devm_kzalloc(&pdev->dev, sizeof(*nvmem_rbm), GFP_KERNEL);
if (!nvmem_rbm)
return -ENOMEM;
nvmem_rbm->reboot.dev = &pdev->dev;
nvmem_rbm->reboot.write = nvmem_reboot_mode_write;
nvmem_rbm->cell = devm_nvmem_cell_get(&pdev->dev, "reboot-mode");
if (IS_ERR(nvmem_rbm->cell)) {
return dev_err_probe(&pdev->dev, PTR_ERR(nvmem_rbm->cell),
"failed to get the nvmem cell reboot-mode\n");
}
ret = devm_reboot_mode_register(&pdev->dev, &nvmem_rbm->reboot);
if (ret)
dev_err(&pdev->dev, "can't register reboot mode\n");
return ret;
}
static const struct of_device_id nvmem_reboot_mode_of_match[] = {
{ .compatible = "nvmem-reboot-mode" },
{}
};
MODULE_DEVICE_TABLE(of, nvmem_reboot_mode_of_match);
static struct platform_driver nvmem_reboot_mode_driver = {
.probe = nvmem_reboot_mode_probe,
.driver = {
.name = "nvmem-reboot-mode",
.of_match_table = nvmem_reboot_mode_of_match,
},
};
module_platform_driver(nvmem_reboot_mode_driver);
MODULE_AUTHOR("Nandor Han <nandor.han@vaisala.com>");
MODULE_DESCRIPTION("NVMEM reboot mode driver");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/kernel.h`, `linux/of.h`, `linux/nvmem-consumer.h`, `linux/platform_device.h`, `linux/reboot-mode.h`, `linux/slab.h`.
- Detected declarations: `struct nvmem_reboot_mode`, `function nvmem_reboot_mode_write`, `function nvmem_reboot_mode_probe`.
- Atlas domain: Driver Families / drivers/power.
- 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.