drivers/input/rmi4/rmi_bus.c
Source file repositories/reference/linux-study-clean/drivers/input/rmi4/rmi_bus.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/rmi4/rmi_bus.c- Extension
.c- Size
- 11012 bytes
- Lines
- 486
- Domain
- Driver Families
- Bucket
- drivers/input
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/export.hlinux/kernel.hlinux/device.hlinux/irq.hlinux/irqdomain.hlinux/list.hlinux/pm.hlinux/rmi.hlinux/slab.hlinux/types.hlinux/of.hrmi_bus.hrmi_driver.h
Detected Declarations
function rmi_dbgfunction rmi_release_devicefunction rmi_is_physical_devicefunction busfunction rmi_unregister_transport_devicefunction rmi_release_functionfunction rmi_is_function_devicefunction rmi_function_matchfunction rmi_function_of_probefunction rmi_function_of_probefunction rmi_create_function_irqfunction rmi_function_probefunction rmi_function_removefunction rmi_register_functionfunction rmi_unregister_functionfunction __rmi_register_function_handlerfunction rmi_unregister_function_handlerfunction rmi_bus_matchfunction __rmi_unregister_function_handlersfunction rmi_unregister_function_handlersfunction rmi_register_function_handlersfunction rmi_of_property_read_u32function rmi_bus_initfunction rmi_bus_exitmodule init rmi_bus_initexport rmi_dbgexport rmi_register_transport_deviceexport rmi_unregister_transport_deviceexport __rmi_register_function_handlerexport rmi_unregister_function_handlerexport rmi_of_property_read_u32
Annotated Snippet
static int rmi_function_match(struct device *dev, const struct device_driver *drv)
{
const struct rmi_function_handler *handler = to_rmi_function_handler(drv);
struct rmi_function *fn = to_rmi_function(dev);
return fn->fd.function_number == handler->func;
}
#ifdef CONFIG_OF
static void rmi_function_of_probe(struct rmi_function *fn)
{
char of_name[9];
struct device_node *node = fn->rmi_dev->xport->dev->of_node;
snprintf(of_name, sizeof(of_name), "rmi4-f%02x",
fn->fd.function_number);
fn->dev.of_node = of_get_child_by_name(node, of_name);
}
#else
static inline void rmi_function_of_probe(struct rmi_function *fn)
{}
#endif
static struct irq_chip rmi_irq_chip = {
.name = "rmi4",
};
static int rmi_create_function_irq(struct rmi_function *fn,
struct rmi_function_handler *handler)
{
struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev);
int i, error;
for (i = 0; i < fn->num_of_irqs; i++) {
set_bit(fn->irq_pos + i, fn->irq_mask);
fn->irq[i] = irq_create_mapping(drvdata->irqdomain,
fn->irq_pos + i);
irq_set_chip_data(fn->irq[i], fn);
irq_set_chip_and_handler(fn->irq[i], &rmi_irq_chip,
handle_simple_irq);
irq_set_nested_thread(fn->irq[i], 1);
error = devm_request_threaded_irq(&fn->dev, fn->irq[i], NULL,
handler->attention, IRQF_ONESHOT,
dev_name(&fn->dev), fn);
if (error) {
dev_err(&fn->dev, "Error %d registering IRQ\n", error);
return error;
}
}
return 0;
}
static int rmi_function_probe(struct device *dev)
{
struct rmi_function *fn = to_rmi_function(dev);
struct rmi_function_handler *handler =
to_rmi_function_handler(dev->driver);
int error;
rmi_function_of_probe(fn);
if (handler->probe) {
error = handler->probe(fn);
if (error)
return error;
}
if (fn->num_of_irqs && handler->attention) {
error = rmi_create_function_irq(fn, handler);
if (error)
return error;
}
return 0;
}
static int rmi_function_remove(struct device *dev)
{
struct rmi_function *fn = to_rmi_function(dev);
struct rmi_function_handler *handler =
to_rmi_function_handler(dev->driver);
if (handler->remove)
handler->remove(fn);
return 0;
Annotation
- Immediate include surface: `linux/export.h`, `linux/kernel.h`, `linux/device.h`, `linux/irq.h`, `linux/irqdomain.h`, `linux/list.h`, `linux/pm.h`, `linux/rmi.h`.
- Detected declarations: `function rmi_dbg`, `function rmi_release_device`, `function rmi_is_physical_device`, `function bus`, `function rmi_unregister_transport_device`, `function rmi_release_function`, `function rmi_is_function_device`, `function rmi_function_match`, `function rmi_function_of_probe`, `function rmi_function_of_probe`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.