drivers/sbus/char/flash.c
Source file repositories/reference/linux-study-clean/drivers/sbus/char/flash.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/sbus/char/flash.c- Extension
.c- Size
- 4862 bytes
- Lines
- 216
- Domain
- Driver Families
- Bucket
- drivers/sbus
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/module.hlinux/types.hlinux/errno.hlinux/miscdevice.hlinux/fcntl.hlinux/poll.hlinux/mutex.hlinux/spinlock.hlinux/mm.hlinux/of.hlinux/platform_device.hlinux/uaccess.hasm/io.hasm/upa.h
Detected Declarations
function flash_mmapfunction flash_llseekfunction flash_readfunction flash_openfunction flash_releasefunction flash_probefunction flash_remove
Annotated Snippet
static const struct file_operations flash_fops = {
/* no write to the Flash, use mmap
* and play flash dependent tricks.
*/
.owner = THIS_MODULE,
.llseek = flash_llseek,
.read = flash_read,
.mmap = flash_mmap,
.open = flash_open,
.release = flash_release,
};
static struct miscdevice flash_dev = { SBUS_FLASH_MINOR, "flash", &flash_fops };
static int flash_probe(struct platform_device *op)
{
struct device_node *dp = op->dev.of_node;
struct device_node *parent;
parent = dp->parent;
if (!of_node_name_eq(parent, "sbus") &&
!of_node_name_eq(parent, "sbi") &&
!of_node_name_eq(parent, "ebus"))
return -ENODEV;
flash.read_base = op->resource[0].start;
flash.read_size = resource_size(&op->resource[0]);
if (op->resource[1].flags) {
flash.write_base = op->resource[1].start;
flash.write_size = resource_size(&op->resource[1]);
} else {
flash.write_base = op->resource[0].start;
flash.write_size = resource_size(&op->resource[0]);
}
flash.busy = 0;
printk(KERN_INFO "%pOF: OBP Flash, RD %lx[%lx] WR %lx[%lx]\n",
op->dev.of_node,
flash.read_base, flash.read_size,
flash.write_base, flash.write_size);
return misc_register(&flash_dev);
}
static void flash_remove(struct platform_device *op)
{
misc_deregister(&flash_dev);
}
static const struct of_device_id flash_match[] = {
{
.name = "flashprom",
},
{},
};
MODULE_DEVICE_TABLE(of, flash_match);
static struct platform_driver flash_driver = {
.driver = {
.name = "flash",
.of_match_table = flash_match,
},
.probe = flash_probe,
.remove = flash_remove,
};
module_platform_driver(flash_driver);
MODULE_DESCRIPTION("OBP Flash Device driver");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/errno.h`, `linux/miscdevice.h`, `linux/fcntl.h`, `linux/poll.h`, `linux/mutex.h`, `linux/spinlock.h`.
- Detected declarations: `function flash_mmap`, `function flash_llseek`, `function flash_read`, `function flash_open`, `function flash_release`, `function flash_probe`, `function flash_remove`.
- Atlas domain: Driver Families / drivers/sbus.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.