drivers/input/misc/da9055_onkey.c
Source file repositories/reference/linux-study-clean/drivers/input/misc/da9055_onkey.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/misc/da9055_onkey.c- Extension
.c- Size
- 3721 bytes
- Lines
- 160
- 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/input.hlinux/module.hlinux/platform_device.hlinux/mfd/da9055/core.hlinux/mfd/da9055/reg.h
Detected Declarations
struct da9055_onkeyfunction da9055_onkey_queryfunction da9055_onkey_workfunction da9055_onkey_irqfunction da9055_onkey_probefunction da9055_onkey_remove
Annotated Snippet
struct da9055_onkey {
struct da9055 *da9055;
struct input_dev *input;
struct delayed_work work;
};
static void da9055_onkey_query(struct da9055_onkey *onkey)
{
int key_stat;
key_stat = da9055_reg_read(onkey->da9055, DA9055_REG_STATUS_A);
if (key_stat < 0) {
dev_err(onkey->da9055->dev,
"Failed to read onkey event %d\n", key_stat);
} else {
key_stat &= DA9055_NOKEY_STS;
/*
* Onkey status bit is cleared when onkey button is released.
*/
if (!key_stat) {
input_report_key(onkey->input, KEY_POWER, 0);
input_sync(onkey->input);
}
}
/*
* Interrupt is generated only when the ONKEY pin is asserted.
* Hence the deassertion of the pin is simulated through work queue.
*/
if (key_stat)
schedule_delayed_work(&onkey->work, msecs_to_jiffies(10));
}
static void da9055_onkey_work(struct work_struct *work)
{
struct da9055_onkey *onkey = container_of(work, struct da9055_onkey,
work.work);
da9055_onkey_query(onkey);
}
static irqreturn_t da9055_onkey_irq(int irq, void *data)
{
struct da9055_onkey *onkey = data;
input_report_key(onkey->input, KEY_POWER, 1);
input_sync(onkey->input);
da9055_onkey_query(onkey);
return IRQ_HANDLED;
}
static int da9055_onkey_probe(struct platform_device *pdev)
{
struct da9055 *da9055 = dev_get_drvdata(pdev->dev.parent);
struct da9055_onkey *onkey;
struct input_dev *input_dev;
int irq, err;
irq = platform_get_irq_byname(pdev, "ONKEY");
if (irq < 0)
return -EINVAL;
onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL);
if (!onkey) {
dev_err(&pdev->dev, "Failed to allocate memory\n");
return -ENOMEM;
}
input_dev = input_allocate_device();
if (!input_dev) {
dev_err(&pdev->dev, "Failed to allocate memory\n");
return -ENOMEM;
}
onkey->input = input_dev;
onkey->da9055 = da9055;
input_dev->name = "da9055-onkey";
input_dev->phys = "da9055-onkey/input0";
input_dev->dev.parent = &pdev->dev;
input_dev->evbit[0] = BIT_MASK(EV_KEY);
__set_bit(KEY_POWER, input_dev->keybit);
INIT_DELAYED_WORK(&onkey->work, da9055_onkey_work);
err = request_threaded_irq(irq, NULL, da9055_onkey_irq,
IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
Annotation
- Immediate include surface: `linux/input.h`, `linux/module.h`, `linux/platform_device.h`, `linux/mfd/da9055/core.h`, `linux/mfd/da9055/reg.h`.
- Detected declarations: `struct da9055_onkey`, `function da9055_onkey_query`, `function da9055_onkey_work`, `function da9055_onkey_irq`, `function da9055_onkey_probe`, `function da9055_onkey_remove`.
- 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.