drivers/input/keyboard/iqs62x-keys.c
Source file repositories/reference/linux-study-clean/drivers/input/keyboard/iqs62x-keys.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/keyboard/iqs62x-keys.c- Extension
.c- Size
- 8842 bytes
- Lines
- 334
- 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/device.hlinux/input.hlinux/kernel.hlinux/mfd/iqs62x.hlinux/module.hlinux/notifier.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/slab.h
Detected Declarations
struct iqs62x_switch_descstruct iqs62x_keys_privatefunction iqs62x_keys_parse_propfunction iqs62x_keys_initfunction iqs62x_keys_notifierfunction eventfunction iqs62x_keys_probefunction iqs62x_keys_remove
Annotated Snippet
struct iqs62x_switch_desc {
enum iqs62x_event_flag flag;
unsigned int code;
bool enabled;
};
struct iqs62x_keys_private {
struct iqs62x_core *iqs62x;
struct input_dev *input;
struct notifier_block notifier;
struct iqs62x_switch_desc switches[ARRAY_SIZE(iqs62x_switch_names)];
unsigned int keycode[IQS62X_NUM_KEYS];
unsigned int keycodemax;
u8 interval;
};
static int iqs62x_keys_parse_prop(struct platform_device *pdev,
struct iqs62x_keys_private *iqs62x_keys)
{
unsigned int val;
int ret, i;
ret = device_property_count_u32(&pdev->dev, "linux,keycodes");
if (ret > IQS62X_NUM_KEYS) {
dev_err(&pdev->dev, "Too many keycodes present\n");
return -EINVAL;
} else if (ret < 0) {
dev_err(&pdev->dev, "Failed to count keycodes: %d\n", ret);
return ret;
}
iqs62x_keys->keycodemax = ret;
ret = device_property_read_u32_array(&pdev->dev, "linux,keycodes",
iqs62x_keys->keycode,
iqs62x_keys->keycodemax);
if (ret) {
dev_err(&pdev->dev, "Failed to read keycodes: %d\n", ret);
return ret;
}
for (i = 0; i < ARRAY_SIZE(iqs62x_keys->switches); i++) {
struct fwnode_handle *child __free(fwnode_handle) =
device_get_named_child_node(&pdev->dev,
iqs62x_switch_names[i]);
if (!child)
continue;
ret = fwnode_property_read_u32(child, "linux,code", &val);
if (ret) {
dev_err(&pdev->dev, "Failed to read switch code: %d\n",
ret);
return ret;
}
iqs62x_keys->switches[i].code = val;
iqs62x_keys->switches[i].enabled = true;
if (fwnode_property_present(child, "azoteq,use-prox"))
iqs62x_keys->switches[i].flag = (i == IQS62X_SW_HALL_N ?
IQS62X_EVENT_HALL_N_P :
IQS62X_EVENT_HALL_S_P);
else
iqs62x_keys->switches[i].flag = (i == IQS62X_SW_HALL_N ?
IQS62X_EVENT_HALL_N_T :
IQS62X_EVENT_HALL_S_T);
}
return 0;
}
static int iqs62x_keys_init(struct iqs62x_keys_private *iqs62x_keys)
{
struct iqs62x_core *iqs62x = iqs62x_keys->iqs62x;
enum iqs62x_event_flag flag;
unsigned int event_reg, val;
unsigned int event_mask = 0;
int ret, i;
switch (iqs62x->dev_desc->prod_num) {
case IQS620_PROD_NUM:
case IQS621_PROD_NUM:
case IQS622_PROD_NUM:
event_reg = IQS620_GLBL_EVENT_MASK;
/*
* Discreet button, hysteresis and SAR UI flags represent keys
* and are unmasked if mapped to a valid keycode.
*/
for (i = 0; i < iqs62x_keys->keycodemax; i++) {
if (iqs62x_keys->keycode[i] == KEY_RESERVED)
continue;
Annotation
- Immediate include surface: `linux/device.h`, `linux/input.h`, `linux/kernel.h`, `linux/mfd/iqs62x.h`, `linux/module.h`, `linux/notifier.h`, `linux/platform_device.h`, `linux/property.h`.
- Detected declarations: `struct iqs62x_switch_desc`, `struct iqs62x_keys_private`, `function iqs62x_keys_parse_prop`, `function iqs62x_keys_init`, `function iqs62x_keys_notifier`, `function event`, `function iqs62x_keys_probe`, `function iqs62x_keys_remove`.
- 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.