drivers/input/misc/max77650-onkey.c
Source file repositories/reference/linux-study-clean/drivers/input/misc/max77650-onkey.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/misc/max77650-onkey.c- Extension
.c- Size
- 3171 bytes
- Lines
- 130
- 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/i2c.hlinux/input.hlinux/interrupt.hlinux/mfd/max77650.hlinux/module.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
struct max77650_onkeyfunction max77650_onkey_fallingfunction max77650_onkey_risingfunction max77650_onkey_probe
Annotated Snippet
struct max77650_onkey {
struct input_dev *input;
unsigned int code;
};
static irqreturn_t max77650_onkey_falling(int irq, void *data)
{
struct max77650_onkey *onkey = data;
input_report_key(onkey->input, onkey->code, 0);
input_sync(onkey->input);
return IRQ_HANDLED;
}
static irqreturn_t max77650_onkey_rising(int irq, void *data)
{
struct max77650_onkey *onkey = data;
input_report_key(onkey->input, onkey->code, 1);
input_sync(onkey->input);
return IRQ_HANDLED;
}
static int max77650_onkey_probe(struct platform_device *pdev)
{
int irq_r, irq_f, error, mode;
struct max77650_onkey *onkey;
struct device *dev, *parent;
struct regmap *map;
unsigned int type;
dev = &pdev->dev;
parent = dev->parent;
map = dev_get_regmap(parent, NULL);
if (!map)
return -ENODEV;
onkey = devm_kzalloc(dev, sizeof(*onkey), GFP_KERNEL);
if (!onkey)
return -ENOMEM;
error = device_property_read_u32(dev, "linux,code", &onkey->code);
if (error)
onkey->code = KEY_POWER;
if (device_property_read_bool(dev, "maxim,onkey-slide")) {
mode = MAX77650_ONKEY_MODE_SLIDE;
type = EV_SW;
} else {
mode = MAX77650_ONKEY_MODE_PUSH;
type = EV_KEY;
}
error = regmap_update_bits(map, MAX77650_REG_CNFG_GLBL,
MAX77650_ONKEY_MODE_MASK, mode);
if (error)
return error;
irq_f = platform_get_irq_byname(pdev, "nEN_F");
if (irq_f < 0)
return irq_f;
irq_r = platform_get_irq_byname(pdev, "nEN_R");
if (irq_r < 0)
return irq_r;
onkey->input = devm_input_allocate_device(dev);
if (!onkey->input)
return -ENOMEM;
onkey->input->name = "max77650_onkey";
onkey->input->phys = "max77650_onkey/input0";
onkey->input->id.bustype = BUS_I2C;
input_set_capability(onkey->input, type, onkey->code);
error = devm_request_any_context_irq(dev, irq_f, max77650_onkey_falling,
IRQF_ONESHOT, "onkey-down", onkey);
if (error < 0)
return error;
error = devm_request_any_context_irq(dev, irq_r, max77650_onkey_rising,
IRQF_ONESHOT, "onkey-up", onkey);
if (error < 0)
return error;
return input_register_device(onkey->input);
}
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/input.h`, `linux/interrupt.h`, `linux/mfd/max77650.h`, `linux/module.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct max77650_onkey`, `function max77650_onkey_falling`, `function max77650_onkey_rising`, `function max77650_onkey_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.