lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 22 Dec 2015 18:25:27 +0530
From:	Laxman Dewangan <ldewangan@...dia.com>
To:	<broonie@...nel.org>, <gregkh@...uxfoundation.org>
CC:	<linux-kernel@...r.kernel.org>, <swarren@...dotorg.org>,
	Laxman Dewangan <ldewangan@...dia.com>
Subject: [PATCH 2/2] regmap: irq: add support to have callback pre/post irq handling

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@...dia.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ