drivers/input/keyboard/ipaq-micro-keys.c
Source file repositories/reference/linux-study-clean/drivers/input/keyboard/ipaq-micro-keys.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/keyboard/ipaq-micro-keys.c- Extension
.c- Size
- 3959 bytes
- Lines
- 166
- 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.
- 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/module.hlinux/init.hlinux/fs.hlinux/interrupt.hlinux/sched.hlinux/pm.hlinux/sysctl.hlinux/proc_fs.hlinux/delay.hlinux/device.hlinux/input.hlinux/platform_device.hlinux/mfd/ipaq-micro.h
Detected Declarations
struct ipaq_micro_keysfunction micro_key_receivefunction micro_key_startfunction micro_key_stopfunction micro_key_openfunction micro_key_closefunction micro_key_probefunction micro_key_suspendfunction micro_key_resume
Annotated Snippet
struct ipaq_micro_keys {
struct ipaq_micro *micro;
struct input_dev *input;
u16 *codes;
};
static const u16 micro_keycodes[] = {
KEY_RECORD, /* 1: Record button */
KEY_CALENDAR, /* 2: Calendar */
KEY_ADDRESSBOOK, /* 3: Contacts (looks like Outlook) */
KEY_MAIL, /* 4: Envelope (Q on older iPAQs) */
KEY_HOMEPAGE, /* 5: Start (looks like swoopy arrow) */
KEY_UP, /* 6: Up */
KEY_RIGHT, /* 7: Right */
KEY_LEFT, /* 8: Left */
KEY_DOWN, /* 9: Down */
};
static void micro_key_receive(void *data, int len, unsigned char *msg)
{
struct ipaq_micro_keys *keys = data;
int key, down;
down = 0x80 & msg[0];
key = 0x7f & msg[0];
if (key < ARRAY_SIZE(micro_keycodes)) {
input_report_key(keys->input, keys->codes[key], down);
input_sync(keys->input);
}
}
static void micro_key_start(struct ipaq_micro_keys *keys)
{
guard(spinlock)(&keys->micro->lock);
keys->micro->key = micro_key_receive;
keys->micro->key_data = keys;
}
static void micro_key_stop(struct ipaq_micro_keys *keys)
{
guard(spinlock)(&keys->micro->lock);
keys->micro->key = NULL;
keys->micro->key_data = NULL;
}
static int micro_key_open(struct input_dev *input)
{
struct ipaq_micro_keys *keys = input_get_drvdata(input);
micro_key_start(keys);
return 0;
}
static void micro_key_close(struct input_dev *input)
{
struct ipaq_micro_keys *keys = input_get_drvdata(input);
micro_key_stop(keys);
}
static int micro_key_probe(struct platform_device *pdev)
{
struct ipaq_micro_keys *keys;
int error;
int i;
keys = devm_kzalloc(&pdev->dev, sizeof(*keys), GFP_KERNEL);
if (!keys)
return -ENOMEM;
keys->micro = dev_get_drvdata(pdev->dev.parent);
keys->input = devm_input_allocate_device(&pdev->dev);
if (!keys->input)
return -ENOMEM;
keys->input->keycodesize = sizeof(micro_keycodes[0]);
keys->input->keycodemax = ARRAY_SIZE(micro_keycodes);
keys->codes = devm_kmemdup_array(&pdev->dev, micro_keycodes, keys->input->keycodemax,
keys->input->keycodesize, GFP_KERNEL);
if (!keys->codes)
return -ENOMEM;
keys->input->keycode = keys->codes;
__set_bit(EV_KEY, keys->input->evbit);
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/fs.h`, `linux/interrupt.h`, `linux/sched.h`, `linux/pm.h`, `linux/sysctl.h`, `linux/proc_fs.h`.
- Detected declarations: `struct ipaq_micro_keys`, `function micro_key_receive`, `function micro_key_start`, `function micro_key_stop`, `function micro_key_open`, `function micro_key_close`, `function micro_key_probe`, `function micro_key_suspend`, `function micro_key_resume`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source 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.