drivers/char/powernv-op-panel.c
Source file repositories/reference/linux-study-clean/drivers/char/powernv-op-panel.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/powernv-op-panel.c- Extension
.c- Size
- 5199 bytes
- Lines
- 225
- Domain
- Driver Families
- Bucket
- drivers/char
- 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.
- 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/fs.hlinux/device.hlinux/errno.hlinux/mutex.hlinux/of.hlinux/slab.hlinux/platform_device.hlinux/miscdevice.hasm/opal.h
Detected Declarations
function oppanel_llseekfunction oppanel_readfunction __op_panel_update_displayfunction oppanel_writefunction oppanel_openfunction oppanel_releasefunction oppanel_probefunction oppanel_remove
Annotated Snippet
static const struct file_operations oppanel_fops = {
.owner = THIS_MODULE,
.llseek = oppanel_llseek,
.read = oppanel_read,
.write = oppanel_write,
.open = oppanel_open,
.release = oppanel_release
};
static struct miscdevice oppanel_dev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "op_panel",
.fops = &oppanel_fops
};
static int oppanel_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
u32 line_len;
int rc, i;
rc = of_property_read_u32(np, "#length", &line_len);
if (rc) {
pr_err_ratelimited("Operator panel length property not found\n");
return rc;
}
rc = of_property_read_u32(np, "#lines", &num_lines);
if (rc) {
pr_err_ratelimited("Operator panel lines property not found\n");
return rc;
}
oppanel_size = line_len * num_lines;
pr_devel("Operator panel of size %u found with %u lines of length %u\n",
oppanel_size, num_lines, line_len);
oppanel_data = kcalloc(oppanel_size, sizeof(*oppanel_data), GFP_KERNEL);
if (!oppanel_data)
return -ENOMEM;
oppanel_lines = kzalloc_objs(oppanel_line_t, num_lines);
if (!oppanel_lines) {
rc = -ENOMEM;
goto free_oppanel_data;
}
memset(oppanel_data, ' ', oppanel_size);
for (i = 0; i < num_lines; i++) {
oppanel_lines[i].line_len = cpu_to_be64(line_len);
oppanel_lines[i].line = cpu_to_be64(__pa(&oppanel_data[i *
line_len]));
}
rc = misc_register(&oppanel_dev);
if (rc) {
pr_err_ratelimited("Failed to register as misc device\n");
goto free_oppanel;
}
return 0;
free_oppanel:
kfree(oppanel_lines);
free_oppanel_data:
kfree(oppanel_data);
return rc;
}
static void oppanel_remove(struct platform_device *pdev)
{
misc_deregister(&oppanel_dev);
kfree(oppanel_lines);
kfree(oppanel_data);
}
static const struct of_device_id oppanel_match[] = {
{ .compatible = "ibm,opal-oppanel" },
{ },
};
static struct platform_driver oppanel_driver = {
.driver = {
.name = "powernv-op-panel",
.of_match_table = oppanel_match,
},
.probe = oppanel_probe,
.remove = oppanel_remove,
};
module_platform_driver(oppanel_driver);
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/kernel.h`, `linux/fs.h`, `linux/device.h`, `linux/errno.h`, `linux/mutex.h`, `linux/of.h`.
- Detected declarations: `function oppanel_llseek`, `function oppanel_read`, `function __op_panel_update_display`, `function oppanel_write`, `function oppanel_open`, `function oppanel_release`, `function oppanel_probe`, `function oppanel_remove`.
- Atlas domain: Driver Families / drivers/char.
- Implementation status: pattern 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.