drivers/input/rmi4/rmi_f1a.c
Source file repositories/reference/linux-study-clean/drivers/input/rmi4/rmi_f1a.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/rmi4/rmi_f1a.c- Extension
.c- Size
- 3149 bytes
- Lines
- 144
- 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/property.hrmi_driver.h
Detected Declarations
struct f1a_datafunction rmi_f1a_parse_device_propertiesfunction rmi_f1a_attentionfunction rmi_f1a_configfunction rmi_f1a_initializefunction rmi_f1a_probe
Annotated Snippet
struct f1a_data {
struct input_dev *input;
u32 *keymap;
unsigned int num_keys;
};
static int rmi_f1a_parse_device_properties(struct rmi_function *fn, struct f1a_data *f1a)
{
static const char buttons_property[] = "linux,keycodes";
struct device *dev = &fn->dev;
u32 *buttonmap;
int n_keys;
int error;
if (!device_property_present(dev, buttons_property))
return 0;
n_keys = device_property_count_u32(dev, buttons_property);
if (n_keys <= 0) {
error = n_keys < 0 ? n_keys : -EINVAL;
dev_err(dev, "Invalid/malformed '%s' property: %d\n",
buttons_property, error);
return error;
}
buttonmap = devm_kmalloc_array(dev, n_keys, sizeof(*buttonmap),
GFP_KERNEL);
if (!buttonmap)
return -ENOMEM;
error = device_property_read_u32_array(dev, buttons_property,
buttonmap, n_keys);
if (error) {
dev_err(dev, "Failed to parse '%s' property: %d\n",
buttons_property, error);
return error;
}
f1a->keymap = buttonmap;
f1a->num_keys = n_keys;
return 0;
}
static irqreturn_t rmi_f1a_attention(int irq, void *ctx)
{
struct rmi_function *fn = ctx;
struct f1a_data *f1a = dev_get_drvdata(&fn->dev);
char button_bitmask;
int key;
int error;
error = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr,
&button_bitmask, sizeof(button_bitmask));
if (error) {
dev_err(&fn->dev, "Failed to read object data. Code: %d.\n",
error);
return IRQ_RETVAL(error);
}
for (key = 0; key < f1a->num_keys; key++)
input_report_key(f1a->input, f1a->keymap[key],
button_bitmask & BIT(key));
return IRQ_HANDLED;
}
static int rmi_f1a_config(struct rmi_function *fn)
{
struct f1a_data *f1a = dev_get_drvdata(&fn->dev);
struct rmi_driver *drv = fn->rmi_dev->driver;
if (f1a->num_keys)
drv->set_irq_bits(fn->rmi_dev, fn->irq_mask);
return 0;
}
static int rmi_f1a_initialize(struct rmi_function *fn, struct f1a_data *f1a)
{
int error;
int i;
error = rmi_f1a_parse_device_properties(fn, f1a);
if (error)
return error;
for (i = 0; i < f1a->num_keys; i++)
input_set_capability(f1a->input, EV_KEY, f1a->keymap[i]);
Annotation
- Immediate include surface: `linux/input.h`, `linux/property.h`, `rmi_driver.h`.
- Detected declarations: `struct f1a_data`, `function rmi_f1a_parse_device_properties`, `function rmi_f1a_attention`, `function rmi_f1a_config`, `function rmi_f1a_initialize`, `function rmi_f1a_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.