public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] uio_pdrv: Unique IRQ Mode
@ 2008-06-04  6:08 Magnus Damm
  2008-06-04 10:11 ` Hans J. Koch
  0 siblings, 1 reply; 33+ messages in thread
From: Magnus Damm @ 2008-06-04  6:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Uwe.Kleine-Koenig, gregkh, akpm, hjk, lethal, Magnus Damm, tglx

From: Magnus Damm <damm@igel.co.jp>

This patch adds a "Unique IRQ Mode" to the uio_pdrv UIO platform driver.
In this mode the user space driver is responsible for acknowledging and
re-enabling the interrupt. Shared interrupts are not supported.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

Think of this as V2 of "[PATCH 00/03][RFC] Reusable UIO Platform Driver".
Needs "[PATCH 0/1] UIO: Add a write() function to enable/disable interrupts"

 drivers/uio/uio_pdrv.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

--- 0006/drivers/uio/uio_pdrv.c
+++ work/drivers/uio/uio_pdrv.c	2008-06-04 14:51:56.000000000 +0900
@@ -16,8 +16,34 @@
 
 struct uio_platdata {
 	struct uio_info *uioinfo;
+	unsigned long irq_disabled;
 };
 
+static irqreturn_t uio_pdrv_unique_handler(int irq, struct uio_info *dev_info)
+{
+	struct uio_platdata *priv = dev_info->priv;
+
+	/* In "Unique IRQ Mode", just disable the interrupt and remember
+	 * the state so we can enable it later.
+	 */
+	disable_irq(irq);
+	set_bit(0, &priv->irq_disabled);
+	return IRQ_HANDLED;
+}
+
+static int uio_pdrv_unique_irqcontrol(struct uio_info *dev_info, s32 irq_on)
+{
+	struct uio_platdata *priv = dev_info->priv;
+
+	/* "Unique IRQ Mode" allows re-enabling of the interrupt */
+	if (irq_on && test_and_clear_bit(0, &priv->irq_disabled)) {
+		enable_irq(dev_info->irq);
+		return 0;
+	}
+
+	return -ENOSYS;
+}
+
 static int uio_pdrv_probe(struct platform_device *pdev)
 {
 	struct uio_info *uioinfo = pdev->dev.platform_data;
@@ -68,6 +94,23 @@ static int uio_pdrv_probe(struct platfor
 
 	pdata->uioinfo->priv = pdata;
 
+	/* This driver supports a special "Unique IRQ Mode".
+	 *
+	 * In this mode, no hardware specific kernel code is required to
+	 * acknowledge interrupts. Instead, the interrupt is disabled by
+	 * the interrupt handler. User space is responsible for performing
+	 * hardware specific acknowledge and enabling of interrupts.
+	 *
+	 * Interrupt sharing is _not_ supported by the "Unique IRQ Mode".
+	 *
+	 * Enable this mode by passing IRQ number but omitting irq callbacks.
+	 */
+	if (!uioinfo->handler && !uioinfo->irqcontrol && uioinfo->irq >= 0) {
+		uioinfo->irq_flags = IRQF_DISABLED;
+		uioinfo->handler = uio_pdrv_unique_handler;
+		uioinfo->irqcontrol = uio_pdrv_unique_irqcontrol;
+	}
+
 	ret = uio_register_device(&pdev->dev, pdata->uioinfo);
 
 	if (ret) {

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2008-06-10 19:25 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-04  6:08 [PATCH] uio_pdrv: Unique IRQ Mode Magnus Damm
2008-06-04 10:11 ` Hans J. Koch
2008-06-05  1:25   ` Magnus Damm
2008-06-05  6:49     ` Uwe Kleine-König
2008-06-06  2:55       ` Magnus Damm
2008-06-06 10:04         ` Hans J. Koch
2008-06-08 10:03           ` Magnus Damm
2008-06-05  9:09     ` Hans J. Koch
2008-06-05  9:46       ` Magnus Damm
2008-06-05 11:27         ` Hans J. Koch
2008-06-08 10:19           ` Magnus Damm
2008-06-08 20:54             ` Hans J. Koch
2008-06-09  1:12               ` Magnus Damm
2008-06-09  8:44                 ` Hans J. Koch
2008-06-09  9:01                   ` Paul Mundt
2008-06-09 12:34                     ` Uwe Kleine-König
2008-06-10  3:12                       ` Greg KH
2008-06-10  4:40                       ` Magnus Damm
2008-06-10  7:10                         ` Uwe Kleine-König
2008-06-10  7:14                           ` [PATCH] UIO: minor style and comment fixes Uwe Kleine-König
2008-06-10  9:07                             ` Hans J. Koch
2008-06-10 13:50                           ` [PATCH] uio_pdrv: Unique IRQ Mode Magnus Damm
2008-06-10 17:32                           ` Paul Mundt
2008-06-10 19:24                             ` Uwe Kleine-König
2008-06-09  4:09               ` Paul Mundt
2008-06-09  7:57               ` Uwe Kleine-König
2008-06-09  8:00                 ` Paul Mundt
2008-06-09  9:54                 ` Hans J. Koch
2008-06-09 12:32                   ` Uwe Kleine-König
2008-06-09 14:20                     ` Hans J. Koch
2008-06-10  6:11                       ` Uwe Kleine-König
2008-06-10  9:01                         ` Hans J. Koch
2008-06-05 11:33         ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox