From: Laxman Dewangan <ldewangan@nvidia.com>
To: <broonie@kernel.org>, <gregkh@linuxfoundation.org>
Cc: <linux-kernel@vger.kernel.org>, <swarren@wwwdotorg.org>,
Laxman Dewangan <ldewangan@nvidia.com>
Subject: [PATCH 2/2] regmap: irq: add support to have callback pre/post irq handling
Date: Tue, 22 Dec 2015 18:25:27 +0530 [thread overview]
Message-ID: <1450788927-22116-2-git-send-email-ldewangan@nvidia.com> (raw)
In-Reply-To: <1450788927-22116-1-git-send-email-ldewangan@nvidia.com>
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 <ldewangan@nvidia.com>
---
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
next prev parent reply other threads:[~2015-12-22 13:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-22 12:55 [PATCH 1/2] regmap: irq: add support for configuration of trigger type Laxman Dewangan
2015-12-22 12:55 ` Laxman Dewangan [this message]
2016-01-05 17:43 ` [PATCH 2/2] regmap: irq: add support to have callback pre/post irq handling Mark Brown
2016-01-06 6:04 ` Laxman Dewangan
2016-01-05 17:41 ` [PATCH 1/2] regmap: irq: add support for configuration of trigger type Mark Brown
2016-01-06 5:48 ` Laxman Dewangan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1450788927-22116-2-git-send-email-ldewangan@nvidia.com \
--to=ldewangan@nvidia.com \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=swarren@wwwdotorg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®