drivers/misc/tps6594-pfsm.c
Source file repositories/reference/linux-study-clean/drivers/misc/tps6594-pfsm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/tps6594-pfsm.c- Extension
.c- Size
- 8978 bytes
- Lines
- 340
- Domain
- Driver Families
- Bucket
- drivers/misc
- 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.
- 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/errno.hlinux/fs.hlinux/interrupt.hlinux/ioctl.hlinux/miscdevice.hlinux/module.hlinux/platform_device.hlinux/regmap.hlinux/mfd/tps6594.hlinux/tps6594_pfsm.h
Detected Declarations
struct tps6594_pfsmfunction tps6594_pfsm_readfunction tps6594_pfsm_writefunction tps6594_pfsm_configure_ret_trigfunction tps6594_pfsm_ioctlfunction tps6594_pfsm_isrfunction tps6594_pfsm_probefunction tps6594_pfsm_remove
Annotated Snippet
static const struct file_operations tps6594_pfsm_fops = {
.owner = THIS_MODULE,
.llseek = generic_file_llseek,
.read = tps6594_pfsm_read,
.write = tps6594_pfsm_write,
.unlocked_ioctl = tps6594_pfsm_ioctl,
.compat_ioctl = compat_ptr_ioctl,
};
static irqreturn_t tps6594_pfsm_isr(int irq, void *dev_id)
{
struct platform_device *pdev = dev_id;
int i;
for (i = 0 ; i < pdev->num_resources ; i++) {
if (irq == platform_get_irq_byname(pdev, pdev->resource[i].name)) {
dev_err(pdev->dev.parent, "%s event detected\n", pdev->resource[i].name);
return IRQ_HANDLED;
}
}
return IRQ_NONE;
}
static int tps6594_pfsm_probe(struct platform_device *pdev)
{
struct tps6594_pfsm *pfsm;
struct tps6594 *tps = dev_get_drvdata(pdev->dev.parent);
struct device *dev = &pdev->dev;
int irq;
int ret;
int i;
pfsm = devm_kzalloc(dev, sizeof(struct tps6594_pfsm), GFP_KERNEL);
if (!pfsm)
return -ENOMEM;
pfsm->regmap = tps->regmap;
pfsm->miscdev.minor = MISC_DYNAMIC_MINOR;
pfsm->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "pfsm-%ld-0x%02x",
tps->chip_id, tps->reg);
if (!pfsm->miscdev.name)
return -ENOMEM;
pfsm->miscdev.fops = &tps6594_pfsm_fops;
pfsm->miscdev.parent = dev->parent;
pfsm->chip_id = tps->chip_id;
for (i = 0 ; i < pdev->num_resources ; i++) {
irq = platform_get_irq_byname(pdev, pdev->resource[i].name);
if (irq < 0)
return irq;
ret = devm_request_threaded_irq(dev, irq, NULL,
tps6594_pfsm_isr, IRQF_ONESHOT,
pdev->resource[i].name, pdev);
if (ret)
return dev_err_probe(dev, ret, "Failed to request irq\n");
}
platform_set_drvdata(pdev, pfsm);
return misc_register(&pfsm->miscdev);
}
static void tps6594_pfsm_remove(struct platform_device *pdev)
{
struct tps6594_pfsm *pfsm = platform_get_drvdata(pdev);
misc_deregister(&pfsm->miscdev);
}
static struct platform_driver tps6594_pfsm_driver = {
.driver = {
.name = "tps6594-pfsm",
},
.probe = tps6594_pfsm_probe,
.remove = tps6594_pfsm_remove,
};
module_platform_driver(tps6594_pfsm_driver);
MODULE_ALIAS("platform:tps6594-pfsm");
MODULE_AUTHOR("Julien Panis <jpanis@baylibre.com>");
MODULE_DESCRIPTION("TPS6594 Pre-configurable Finite State Machine Driver");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/errno.h`, `linux/fs.h`, `linux/interrupt.h`, `linux/ioctl.h`, `linux/miscdevice.h`, `linux/module.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct tps6594_pfsm`, `function tps6594_pfsm_read`, `function tps6594_pfsm_write`, `function tps6594_pfsm_configure_ret_trig`, `function tps6594_pfsm_ioctl`, `function tps6594_pfsm_isr`, `function tps6594_pfsm_probe`, `function tps6594_pfsm_remove`.
- Atlas domain: Driver Families / drivers/misc.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.