From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754089AbbLVNGC (ORCPT ); Tue, 22 Dec 2015 08:06:02 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:9631 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753492AbbLVNFZ (ORCPT ); Tue, 22 Dec 2015 08:05:25 -0500 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Tue, 22 Dec 2015 05:01:42 -0800 From: Laxman Dewangan To: , CC: , , Laxman Dewangan Subject: [PATCH 2/2] regmap: irq: add support to have callback pre/post irq handling Date: Tue, 22 Dec 2015 18:25:27 +0530 Message-ID: <1450788927-22116-2-git-send-email-ldewangan@nvidia.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1450788927-22116-1-git-send-email-ldewangan@nvidia.com> References: <1450788927-22116-1-git-send-email-ldewangan@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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