drivers/input/misc/tps6594-pwrbutton.c
Source file repositories/reference/linux-study-clean/drivers/input/misc/tps6594-pwrbutton.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/misc/tps6594-pwrbutton.c- Extension
.c- Size
- 2823 bytes
- Lines
- 127
- Domain
- Driver Families
- Bucket
- drivers/input
- 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.
- 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/init.hlinux/input.hlinux/interrupt.hlinux/kernel.hlinux/mfd/tps6594.hlinux/module.hlinux/platform_device.hlinux/regmap.hlinux/slab.h
Detected Declarations
struct tps6594_pwrbuttonfunction tps6594_pb_push_irqfunction tps6594_pb_release_irqfunction tps6594_pb_probe
Annotated Snippet
struct tps6594_pwrbutton {
struct device *dev;
struct input_dev *idev;
char phys[32];
};
static irqreturn_t tps6594_pb_push_irq(int irq, void *_pwr)
{
struct tps6594_pwrbutton *pwr = _pwr;
input_report_key(pwr->idev, KEY_POWER, 1);
pm_wakeup_event(pwr->dev, 0);
input_sync(pwr->idev);
return IRQ_HANDLED;
}
static irqreturn_t tps6594_pb_release_irq(int irq, void *_pwr)
{
struct tps6594_pwrbutton *pwr = _pwr;
input_report_key(pwr->idev, KEY_POWER, 0);
input_sync(pwr->idev);
return IRQ_HANDLED;
}
static int tps6594_pb_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct tps6594_pwrbutton *pwr;
struct input_dev *idev;
int error;
int push_irq;
int release_irq;
pwr = devm_kzalloc(dev, sizeof(*pwr), GFP_KERNEL);
if (!pwr)
return -ENOMEM;
idev = devm_input_allocate_device(dev);
if (!idev)
return -ENOMEM;
idev->name = pdev->name;
snprintf(pwr->phys, sizeof(pwr->phys), "%s/input0",
pdev->name);
idev->phys = pwr->phys;
idev->id.bustype = BUS_I2C;
input_set_capability(idev, EV_KEY, KEY_POWER);
pwr->dev = dev;
pwr->idev = idev;
device_init_wakeup(dev, true);
push_irq = platform_get_irq(pdev, 0);
if (push_irq < 0)
return -EINVAL;
release_irq = platform_get_irq(pdev, 1);
if (release_irq < 0)
return -EINVAL;
error = devm_request_threaded_irq(dev, push_irq, NULL,
tps6594_pb_push_irq,
IRQF_ONESHOT,
pdev->resource[0].name, pwr);
if (error) {
dev_err(dev, "failed to request push IRQ #%d: %d\n", push_irq,
error);
return error;
}
error = devm_request_threaded_irq(dev, release_irq, NULL,
tps6594_pb_release_irq,
IRQF_ONESHOT,
pdev->resource[1].name, pwr);
if (error) {
dev_err(dev, "failed to request release IRQ #%d: %d\n",
release_irq, error);
return error;
}
error = input_register_device(idev);
if (error) {
dev_err(dev, "Can't register power button: %d\n", error);
return error;
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/input.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mfd/tps6594.h`, `linux/module.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct tps6594_pwrbutton`, `function tps6594_pb_push_irq`, `function tps6594_pb_release_irq`, `function tps6594_pb_probe`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
- 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.