All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: Convert WM8350 to use request_threaded_irq()
@ 2009-09-16 17:44 Mark Brown
  2009-09-16 18:06 ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2009-09-16 17:44 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel, Mark Brown

Instead of hand rolling our own variant.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/mfd/wm8350-core.c       |   22 +++++-----------------
 include/linux/mfd/wm8350/core.h |    1 -
 2 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index 9d662a5..7ca0f94 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -353,15 +353,15 @@ static void wm8350_irq_call_handler(struct wm8350 *wm8350, int irq)
 }
 
 /*
- * wm8350_irq_worker actually handles the interrupts.  Since all
+ * This is a threaded IRQ handler so can access I2C/SPI.  Since all
  * interrupts are clear on read the IRQ line will be reasserted and
  * the physical IRQ will be handled again if another interrupt is
  * asserted while we run - in the normal course of events this is a
  * rare occurrence so we save I2C/SPI reads.
  */
-static void wm8350_irq_worker(struct work_struct *work)
+static irqreturn_t wm8350_irq(int irq, void *data)
 {
-	struct wm8350 *wm8350 = container_of(work, struct wm8350, irq_work);
+	struct wm8350 *wm8350 = data;
 	u16 level_one, status1, status2, comp;
 
 	/* TODO: Use block reads to improve performance? */
@@ -552,16 +552,6 @@ static void wm8350_irq_worker(struct work_struct *work)
 		}
 	}
 
-	enable_irq(wm8350->chip_irq);
-}
-
-static irqreturn_t wm8350_irq(int irq, void *data)
-{
-	struct wm8350 *wm8350 = data;
-
-	disable_irq_nosync(irq);
-	schedule_work(&wm8350->irq_work);
-
 	return IRQ_HANDLED;
 }
 
@@ -1428,7 +1418,6 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
 
 	mutex_init(&wm8350->auxadc_mutex);
 	mutex_init(&wm8350->irq_mutex);
-	INIT_WORK(&wm8350->irq_work, wm8350_irq_worker);
 	if (irq) {
 		int flags = 0;
 
@@ -1444,8 +1433,8 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
 					  WM8350_IRQ_POL);
 		}
 
-		ret = request_irq(irq, wm8350_irq, flags,
-				  "wm8350", wm8350);
+		ret = request_threaded_irq(irq, NULL, wm8350_irq, flags,
+					   "wm8350", wm8350);
 		if (ret != 0) {
 			dev_err(wm8350->dev, "Failed to request IRQ: %d\n",
 				ret);
@@ -1505,7 +1494,6 @@ void wm8350_device_exit(struct wm8350 *wm8350)
 	platform_device_unregister(wm8350->codec.pdev);
 
 	free_irq(wm8350->chip_irq, wm8350);
-	flush_work(&wm8350->irq_work);
 	kfree(wm8350->reg_cache);
 }
 EXPORT_SYMBOL_GPL(wm8350_device_exit);
diff --git a/include/linux/mfd/wm8350/core.h b/include/linux/mfd/wm8350/core.h
index 969b0b5..1d595de 100644
--- a/include/linux/mfd/wm8350/core.h
+++ b/include/linux/mfd/wm8350/core.h
@@ -626,7 +626,6 @@ struct wm8350 {
 	struct mutex auxadc_mutex;
 
 	/* Interrupt handling */
-	struct work_struct irq_work;
 	struct mutex irq_mutex; /* IRQ table mutex */
 	struct wm8350_irq irq[WM8350_NUM_IRQ];
 	int chip_irq;
-- 
1.6.3.3


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

* Re: [PATCH] mfd: Convert WM8350 to use request_threaded_irq()
  2009-09-16 17:44 [PATCH] mfd: Convert WM8350 to use request_threaded_irq() Mark Brown
@ 2009-09-16 18:06 ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2009-09-16 18:06 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel

On Wed, Sep 16, 2009 at 06:44:52PM +0100, Mark Brown wrote:
> Instead of hand rolling our own variant.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Sorry, git format-patch doesn't do what I want when there's an old
version of the patch present - I'll resend the version I meant to send
in a minute.

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

* Re: [PATCH] mfd: Convert WM8350 to use request_threaded_irq()
  2009-09-17  9:01 ` Samuel Ortiz
@ 2009-09-17  9:33   ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2009-09-17  9:33 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel

On Thu, Sep 17, 2009 at 11:01:56AM +0200, Samuel Ortiz wrote:
> On Wed, Sep 16, 2009 at 07:07:32PM +0100, Mark Brown wrote:

> > Instead of hand rolling our own variant.

> Very nice. I expect many other mfd drivers will eventually go the same way.
> I'll look at the ones I have HW for.

I've got a patch sitting waiting to convert wm831x completely to genirq,
including changing to use threaded IRQ handlers.  It'll probably be
after the merge window before I finish up testing and post it.

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

* Re: [PATCH] mfd: Convert WM8350 to use request_threaded_irq()
  2009-09-16 18:07 Mark Brown
@ 2009-09-17  9:01 ` Samuel Ortiz
  2009-09-17  9:33   ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Samuel Ortiz @ 2009-09-17  9:01 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel

Hi Mark,

On Wed, Sep 16, 2009 at 07:07:32PM +0100, Mark Brown wrote:
> Instead of hand rolling our own variant.
Very nice. I expect many other mfd drivers will eventually go the same way.
I'll look at the ones I have HW for.

Applied, thanks.

Cheers,
Samuel.


> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/wm8350-core.c       |   24 ++++++------------------
>  include/linux/mfd/wm8350/core.h |    1 -
>  2 files changed, 6 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
> index 9d662a5..ba27c9d 100644
> --- a/drivers/mfd/wm8350-core.c
> +++ b/drivers/mfd/wm8350-core.c
> @@ -353,15 +353,15 @@ static void wm8350_irq_call_handler(struct wm8350 *wm8350, int irq)
>  }
>  
>  /*
> - * wm8350_irq_worker actually handles the interrupts.  Since all
> + * This is a threaded IRQ handler so can access I2C/SPI.  Since all
>   * interrupts are clear on read the IRQ line will be reasserted and
>   * the physical IRQ will be handled again if another interrupt is
>   * asserted while we run - in the normal course of events this is a
>   * rare occurrence so we save I2C/SPI reads.
>   */
> -static void wm8350_irq_worker(struct work_struct *work)
> +static irqreturn_t wm8350_irq(int irq, void *data)
>  {
> -	struct wm8350 *wm8350 = container_of(work, struct wm8350, irq_work);
> +	struct wm8350 *wm8350 = data;
>  	u16 level_one, status1, status2, comp;
>  
>  	/* TODO: Use block reads to improve performance? */
> @@ -552,16 +552,6 @@ static void wm8350_irq_worker(struct work_struct *work)
>  		}
>  	}
>  
> -	enable_irq(wm8350->chip_irq);
> -}
> -
> -static irqreturn_t wm8350_irq(int irq, void *data)
> -{
> -	struct wm8350 *wm8350 = data;
> -
> -	disable_irq_nosync(irq);
> -	schedule_work(&wm8350->irq_work);
> -
>  	return IRQ_HANDLED;
>  }
>  
> @@ -1428,9 +1418,8 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
>  
>  	mutex_init(&wm8350->auxadc_mutex);
>  	mutex_init(&wm8350->irq_mutex);
> -	INIT_WORK(&wm8350->irq_work, wm8350_irq_worker);
>  	if (irq) {
> -		int flags = 0;
> +		int flags = IRQF_ONESHOT;
>  
>  		if (pdata && pdata->irq_high) {
>  			flags |= IRQF_TRIGGER_HIGH;
> @@ -1444,8 +1433,8 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
>  					  WM8350_IRQ_POL);
>  		}
>  
> -		ret = request_irq(irq, wm8350_irq, flags,
> -				  "wm8350", wm8350);
> +		ret = request_threaded_irq(irq, NULL, wm8350_irq, flags,
> +					   "wm8350", wm8350);
>  		if (ret != 0) {
>  			dev_err(wm8350->dev, "Failed to request IRQ: %d\n",
>  				ret);
> @@ -1505,7 +1494,6 @@ void wm8350_device_exit(struct wm8350 *wm8350)
>  	platform_device_unregister(wm8350->codec.pdev);
>  
>  	free_irq(wm8350->chip_irq, wm8350);
> -	flush_work(&wm8350->irq_work);
>  	kfree(wm8350->reg_cache);
>  }
>  EXPORT_SYMBOL_GPL(wm8350_device_exit);
> diff --git a/include/linux/mfd/wm8350/core.h b/include/linux/mfd/wm8350/core.h
> index 969b0b5..1d595de 100644
> --- a/include/linux/mfd/wm8350/core.h
> +++ b/include/linux/mfd/wm8350/core.h
> @@ -626,7 +626,6 @@ struct wm8350 {
>  	struct mutex auxadc_mutex;
>  
>  	/* Interrupt handling */
> -	struct work_struct irq_work;
>  	struct mutex irq_mutex; /* IRQ table mutex */
>  	struct wm8350_irq irq[WM8350_NUM_IRQ];
>  	int chip_irq;
> -- 
> 1.6.3.3
> 

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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

* [PATCH] mfd: Convert WM8350 to use request_threaded_irq()
@ 2009-09-16 18:07 Mark Brown
  2009-09-17  9:01 ` Samuel Ortiz
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2009-09-16 18:07 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-kernel, Mark Brown

Instead of hand rolling our own variant.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/mfd/wm8350-core.c       |   24 ++++++------------------
 include/linux/mfd/wm8350/core.h |    1 -
 2 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index 9d662a5..ba27c9d 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -353,15 +353,15 @@ static void wm8350_irq_call_handler(struct wm8350 *wm8350, int irq)
 }
 
 /*
- * wm8350_irq_worker actually handles the interrupts.  Since all
+ * This is a threaded IRQ handler so can access I2C/SPI.  Since all
  * interrupts are clear on read the IRQ line will be reasserted and
  * the physical IRQ will be handled again if another interrupt is
  * asserted while we run - in the normal course of events this is a
  * rare occurrence so we save I2C/SPI reads.
  */
-static void wm8350_irq_worker(struct work_struct *work)
+static irqreturn_t wm8350_irq(int irq, void *data)
 {
-	struct wm8350 *wm8350 = container_of(work, struct wm8350, irq_work);
+	struct wm8350 *wm8350 = data;
 	u16 level_one, status1, status2, comp;
 
 	/* TODO: Use block reads to improve performance? */
@@ -552,16 +552,6 @@ static void wm8350_irq_worker(struct work_struct *work)
 		}
 	}
 
-	enable_irq(wm8350->chip_irq);
-}
-
-static irqreturn_t wm8350_irq(int irq, void *data)
-{
-	struct wm8350 *wm8350 = data;
-
-	disable_irq_nosync(irq);
-	schedule_work(&wm8350->irq_work);
-
 	return IRQ_HANDLED;
 }
 
@@ -1428,9 +1418,8 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
 
 	mutex_init(&wm8350->auxadc_mutex);
 	mutex_init(&wm8350->irq_mutex);
-	INIT_WORK(&wm8350->irq_work, wm8350_irq_worker);
 	if (irq) {
-		int flags = 0;
+		int flags = IRQF_ONESHOT;
 
 		if (pdata && pdata->irq_high) {
 			flags |= IRQF_TRIGGER_HIGH;
@@ -1444,8 +1433,8 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
 					  WM8350_IRQ_POL);
 		}
 
-		ret = request_irq(irq, wm8350_irq, flags,
-				  "wm8350", wm8350);
+		ret = request_threaded_irq(irq, NULL, wm8350_irq, flags,
+					   "wm8350", wm8350);
 		if (ret != 0) {
 			dev_err(wm8350->dev, "Failed to request IRQ: %d\n",
 				ret);
@@ -1505,7 +1494,6 @@ void wm8350_device_exit(struct wm8350 *wm8350)
 	platform_device_unregister(wm8350->codec.pdev);
 
 	free_irq(wm8350->chip_irq, wm8350);
-	flush_work(&wm8350->irq_work);
 	kfree(wm8350->reg_cache);
 }
 EXPORT_SYMBOL_GPL(wm8350_device_exit);
diff --git a/include/linux/mfd/wm8350/core.h b/include/linux/mfd/wm8350/core.h
index 969b0b5..1d595de 100644
--- a/include/linux/mfd/wm8350/core.h
+++ b/include/linux/mfd/wm8350/core.h
@@ -626,7 +626,6 @@ struct wm8350 {
 	struct mutex auxadc_mutex;
 
 	/* Interrupt handling */
-	struct work_struct irq_work;
 	struct mutex irq_mutex; /* IRQ table mutex */
 	struct wm8350_irq irq[WM8350_NUM_IRQ];
 	int chip_irq;
-- 
1.6.3.3


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

end of thread, other threads:[~2009-09-17  9:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-16 17:44 [PATCH] mfd: Convert WM8350 to use request_threaded_irq() Mark Brown
2009-09-16 18:06 ` Mark Brown
2009-09-16 18:07 Mark Brown
2009-09-17  9:01 ` Samuel Ortiz
2009-09-17  9:33   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.