Some of devices like MAXIM MAX77620 required to have the chip specific configuration before processing interrupt and after interrupt handling is done.
For such devices to use the generic regmap-irq, add callback APIs for pre/post irq callback which gets called from interrupt handler of regmap irq thread to have device specific configurations. Signed-off-by: Laxman Dewangan <[email protected]> --- drivers/base/regmap/regmap-irq.c | 15 +++++++++++---- include/linux/regmap.h | 11 +++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index 8aa1e2a..00dc6e9 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -268,13 +268,16 @@ static irqreturn_t regmap_irq_thread(int irq, void *d) bool handled = false; u32 reg; + if (chip->pre_irq) + chip->pre_irq(chip->pre_post_irq_data); + if (chip->runtime_pm) { ret = pm_runtime_get_sync(map->dev); if (ret < 0) { dev_err(map->dev, "IRQ thread failed to resume: %d\n", ret); pm_runtime_put(map->dev); - return IRQ_NONE; + goto exit; } } @@ -296,7 +299,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d) if (ret != 0) { dev_err(map->dev, "Failed to read IRQ status: %d\n", ret); - return IRQ_NONE; + goto exit; } for (i = 0; i < data->chip->num_regs; i++) { @@ -312,7 +315,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d) break; default: BUG(); - return IRQ_NONE; + goto exit; } } @@ -329,7 +332,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d) ret); if (chip->runtime_pm) pm_runtime_put(map->dev); - return IRQ_NONE; + goto exit; } } } @@ -365,6 +368,10 @@ static irqreturn_t regmap_irq_thread(int irq, void *d) if (chip->runtime_pm) pm_runtime_put(map->dev); +exit: + if (chip->post_irq) + chip->post_irq(chip->pre_post_irq_data); + if (handled) return IRQ_HANDLED; else diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 1839434..ba2d30b 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -834,6 +834,13 @@ struct regmap_irq { * @num_type_reg: Number of type registers. * @type_reg_stride: Stride to use for chips where type registers are not * contiguous. + * @pre_irq: The callback that is to be executed initially, before the main + * handling in regmap irq handler when an interrupt occurs. + * @post_irq: The callback that is to be executed after the main handling in + * the regmap irq handler when an interrupt occurs. + * @pre_post_irq_data: The driver specific data that is the parameter for the + * pre_irq and post_irq callbacks. + * */ struct regmap_irq_chip { const char *name; @@ -860,6 +867,10 @@ struct regmap_irq_chip { int num_type_reg; unsigned int type_reg_stride; + + int (*pre_irq)(void *irq_data); + int (*post_irq)(void *irq_data); + void *pre_post_irq_data; }; struct regmap_irq_chip_data; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

