drivers/base/regmap/regmap-irq.c
Source file repositories/reference/linux-study-clean/drivers/base/regmap/regmap-irq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/regmap/regmap-irq.c- Extension
.c- Size
- 32451 bytes
- Lines
- 1211
- Domain
- Driver Families
- Bucket
- drivers/base
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/array_size.hlinux/device.hlinux/export.hlinux/interrupt.hlinux/irq.hlinux/irqdomain.hlinux/overflow.hlinux/pm_runtime.hlinux/regmap.hlinux/slab.hinternal.h
Detected Declarations
struct regmap_irq_chip_datafunction regmap_irq_can_bulk_read_statusfunction regmap_irq_lockfunction regmap_irq_sync_unlockfunction regmap_irq_enablefunction regmap_irq_disablefunction regmap_irq_set_typefunction regmap_irq_set_wakefunction read_sub_irq_datafunction read_irq_datafunction for_each_set_bitfunction regmap_irq_threadfunction regmap_irq_mapfunction regmap_irq_get_irq_reg_linearfunction regmap_irq_set_type_config_simplefunction regmap_irq_create_domainfunction regmap_add_irq_chip_fwnodefunction regmap_add_irq_chipfunction regmap_del_irq_chipfunction devm_regmap_irq_chip_releasefunction devm_regmap_irq_chip_matchfunction devm_regmap_add_irq_chip_fwnodefunction devm_regmap_add_irq_chipfunction devm_regmap_del_irq_chipfunction regmap_irq_chip_get_basefunction regmap_irq_get_virqfunction regmap_irq_get_domainexport regmap_irq_get_irq_reg_linearexport regmap_irq_set_type_config_simpleexport regmap_add_irq_chip_fwnodeexport regmap_add_irq_chipexport regmap_del_irq_chipexport devm_regmap_add_irq_chip_fwnodeexport devm_regmap_add_irq_chipexport devm_regmap_del_irq_chipexport regmap_irq_chip_get_baseexport regmap_irq_get_virqexport regmap_irq_get_domain
Annotated Snippet
struct regmap_irq_chip_data {
struct mutex lock;
struct lock_class_key lock_key;
struct irq_chip irq_chip;
struct regmap *map;
const struct regmap_irq_chip *chip;
int irq_base;
struct irq_domain *domain;
int irq;
int wake_count;
void *status_reg_buf;
unsigned int *main_status_buf;
unsigned int *status_buf;
unsigned int *prev_status_buf;
unsigned int *mask_buf;
unsigned int *mask_buf_def;
unsigned int *wake_buf;
unsigned int *type_buf;
unsigned int *type_buf_def;
unsigned int **config_buf;
unsigned int irq_reg_stride;
unsigned int (*get_irq_reg)(struct regmap_irq_chip_data *data,
unsigned int base, int index);
unsigned int clear_status:1;
};
static inline const
struct regmap_irq *irq_to_regmap_irq(struct regmap_irq_chip_data *data,
int irq)
{
return &data->chip->irqs[irq];
}
static bool regmap_irq_can_bulk_read_status(struct regmap_irq_chip_data *data)
{
struct regmap *map = data->map;
/*
* While possible that a user-defined ->get_irq_reg() callback might
* be linear enough to support bulk reads, most of the time it won't.
* Therefore only allow them if the default callback is being used.
*/
return data->irq_reg_stride == 1 && map->reg_stride == 1 &&
data->get_irq_reg == regmap_irq_get_irq_reg_linear &&
!map->use_single_read;
}
static void regmap_irq_lock(struct irq_data *data)
{
struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data);
mutex_lock(&d->lock);
}
static void regmap_irq_sync_unlock(struct irq_data *data)
{
struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data);
struct regmap *map = d->map;
int i, j, ret;
u32 reg;
u32 val;
if (d->chip->runtime_pm) {
ret = pm_runtime_get_sync(map->dev);
if (ret < 0)
dev_err(map->dev, "IRQ sync failed to resume: %d\n",
ret);
}
if (d->clear_status) {
for (i = 0; i < d->chip->num_regs; i++) {
reg = d->get_irq_reg(d, d->chip->status_base, i);
ret = regmap_read(map, reg, &val);
if (ret)
dev_err(d->map->dev,
"Failed to clear the interrupt status bits\n");
}
d->clear_status = false;
}
/*
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/device.h`, `linux/export.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/irqdomain.h`, `linux/overflow.h`, `linux/pm_runtime.h`.
- Detected declarations: `struct regmap_irq_chip_data`, `function regmap_irq_can_bulk_read_status`, `function regmap_irq_lock`, `function regmap_irq_sync_unlock`, `function regmap_irq_enable`, `function regmap_irq_disable`, `function regmap_irq_set_type`, `function regmap_irq_set_wake`, `function read_sub_irq_data`, `function read_irq_data`.
- Atlas domain: Driver Families / drivers/base.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.