mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] set_irq_wake: fix return code and wake status tracking
@ 2008-07-23 12:42 Uwe Kleine-König
  2008-07-23 16:00 ` David Brownell
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2008-07-23 12:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Brownell, Ingo Molnar, Thomas Gleixner, Russell King,
	Andrew Morton, Linus Torvalds

Since 15a647eba94c3da27ccc666bea72e7cca06b2d19 set_irq_wake returned -ENXIO
if another device had it already enabled.  Zero is the right value to
return in this case.  Moreover the change to desc->status was not reverted
if desc->chip->set_wake returned an error.

Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Andrew Morton <akpm@osdl.org>
Cc: Linus Torvalds <torvalds@osdl.org>
---
 kernel/irq/manage.c |   39 +++++++++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index e01ad8e..227cd49 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -194,6 +194,17 @@ void enable_irq(unsigned int irq)
 }
 EXPORT_SYMBOL(enable_irq);
 
+int set_irq_wake_real(unsigned int irq, unsigned int on)
+{
+	struct irq_desc *desc = irq_desc + irq;
+	int ret = -ENXIO;
+
+	if (desc->chip->set_wake)
+		ret = desc->chip->set_wake(irq, on);
+
+	return ret;
+}
+
 /**
  *	set_irq_wake - control irq power management wakeup
  *	@irq:	interrupt to control
@@ -210,30 +221,34 @@ int set_irq_wake(unsigned int irq, unsigned int on)
 {
 	struct irq_desc *desc = irq_desc + irq;
 	unsigned long flags;
-	int ret = -ENXIO;
-	int (*set_wake)(unsigned, unsigned) = desc->chip->set_wake;
+	int ret = 0;
 
 	/* wakeup-capable irqs can be shared between drivers that
 	 * don't need to have the same sleep mode behaviors.
 	 */
 	spin_lock_irqsave(&desc->lock, flags);
 	if (on) {
-		if (desc->wake_depth++ == 0)
-			desc->status |= IRQ_WAKEUP;
-		else
-			set_wake = NULL;
+		if (desc->wake_depth++ == 0) {
+			ret = set_irq_wake_real(irq, on);
+			if (ret)
+				desc->wake_depth = 0;
+			else
+				desc->status |= IRQ_WAKEUP;
+		}
 	} else {
 		if (desc->wake_depth == 0) {
 			printk(KERN_WARNING "Unbalanced IRQ %d "
 					"wake disable\n", irq);
 			WARN_ON(1);
-		} else if (--desc->wake_depth == 0)
-			desc->status &= ~IRQ_WAKEUP;
-		else
-			set_wake = NULL;
+		} else if (--desc->wake_depth == 0) {
+			ret = set_irq_wake_real(irq, on);
+			if (ret)
+				desc->wake_depth = 1;
+			else
+				desc->status &= ~IRQ_WAKEUP;
+		}
 	}
-	if (set_wake)
-		ret = desc->chip->set_wake(irq, on);
+
 	spin_unlock_irqrestore(&desc->lock, flags);
 	return ret;
 }
-- 
1.5.6.3


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

* Re: [PATCH] set_irq_wake: fix return code and wake status tracking
  2008-07-23 12:42 [PATCH] set_irq_wake: fix return code and wake status tracking Uwe Kleine-König
@ 2008-07-23 16:00 ` David Brownell
  2008-07-23 18:44 ` Ingo Oeser
  2008-07-24  5:51 ` [PATCH] make set_irq_wake_real static Uwe Kleine-König
  2 siblings, 0 replies; 5+ messages in thread
From: David Brownell @ 2008-07-23 16:00 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: linux-kernel, David Brownell, Ingo Molnar, Thomas Gleixner,
	Russell King, Andrew Morton, Linus Torvalds

On Wednesday 23 July 2008, Uwe Kleine-König wrote:
> Since 15a647eba94c3da27ccc666bea72e7cca06b2d19 set_irq_wake returned -ENXIO
> if another device had it already enabled.  Zero is the right value to
> return in this case.  Moreover the change to desc->status was not reverted
> if desc->chip->set_wake returned an error.
> 
> Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
> Cc: David Brownell <dbrownell@users.sourceforge.net>

Acked-by: David Brownell <dbrownell@users.sourceforge.net>


> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Russell King <rmk@arm.linux.org.uk>
> Cc: Andrew Morton <akpm@osdl.org>
> Cc: Linus Torvalds <torvalds@osdl.org>
> ---
>  kernel/irq/manage.c |   39 +++++++++++++++++++++++++++------------
>  1 files changed, 27 insertions(+), 12 deletions(-)
> 
> diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
> index e01ad8e..227cd49 100644
> --- a/kernel/irq/manage.c
> +++ b/kernel/irq/manage.c
> @@ -194,6 +194,17 @@ void enable_irq(unsigned int irq)
>  }
>  EXPORT_SYMBOL(enable_irq);
>  
> +int set_irq_wake_real(unsigned int irq, unsigned int on)
> +{
> +	struct irq_desc *desc = irq_desc + irq;
> +	int ret = -ENXIO;
> +
> +	if (desc->chip->set_wake)
> +		ret = desc->chip->set_wake(irq, on);
> +
> +	return ret;
> +}
> +
>  /**
>   *	set_irq_wake - control irq power management wakeup
>   *	@irq:	interrupt to control
> @@ -210,30 +221,34 @@ int set_irq_wake(unsigned int irq, unsigned int on)
>  {
>  	struct irq_desc *desc = irq_desc + irq;
>  	unsigned long flags;
> -	int ret = -ENXIO;
> -	int (*set_wake)(unsigned, unsigned) = desc->chip->set_wake;
> +	int ret = 0;
>  
>  	/* wakeup-capable irqs can be shared between drivers that
>  	 * don't need to have the same sleep mode behaviors.
>  	 */
>  	spin_lock_irqsave(&desc->lock, flags);
>  	if (on) {
> -		if (desc->wake_depth++ == 0)
> -			desc->status |= IRQ_WAKEUP;
> -		else
> -			set_wake = NULL;
> +		if (desc->wake_depth++ == 0) {
> +			ret = set_irq_wake_real(irq, on);
> +			if (ret)
> +				desc->wake_depth = 0;
> +			else
> +				desc->status |= IRQ_WAKEUP;
> +		}
>  	} else {
>  		if (desc->wake_depth == 0) {
>  			printk(KERN_WARNING "Unbalanced IRQ %d "
>  					"wake disable\n", irq);
>  			WARN_ON(1);
> -		} else if (--desc->wake_depth == 0)
> -			desc->status &= ~IRQ_WAKEUP;
> -		else
> -			set_wake = NULL;
> +		} else if (--desc->wake_depth == 0) {
> +			ret = set_irq_wake_real(irq, on);
> +			if (ret)
> +				desc->wake_depth = 1;
> +			else
> +				desc->status &= ~IRQ_WAKEUP;
> +		}
>  	}
> -	if (set_wake)
> -		ret = desc->chip->set_wake(irq, on);
> +
>  	spin_unlock_irqrestore(&desc->lock, flags);
>  	return ret;
>  }
> -- 
> 1.5.6.3
> 



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

* Re: [PATCH] set_irq_wake: fix return code and wake status tracking
  2008-07-23 12:42 [PATCH] set_irq_wake: fix return code and wake status tracking Uwe Kleine-König
  2008-07-23 16:00 ` David Brownell
@ 2008-07-23 18:44 ` Ingo Oeser
  2008-07-24  5:42   ` Uwe Kleine-König
  2008-07-24  5:51 ` [PATCH] make set_irq_wake_real static Uwe Kleine-König
  2 siblings, 1 reply; 5+ messages in thread
From: Ingo Oeser @ 2008-07-23 18:44 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: linux-kernel

Hi Uwe,

you can mark the new function static.

[trimmed CC list, since this is just a minor issue]

On Wednesday 23 July 2008, Uwe Kleine-König wrote:
> diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
> index e01ad8e..227cd49 100644
> --- a/kernel/irq/manage.c
> +++ b/kernel/irq/manage.c
> @@ -194,6 +194,17 @@ void enable_irq(unsigned int irq)
>  }
>  EXPORT_SYMBOL(enable_irq);
>  
> +int set_irq_wake_real(unsigned int irq, unsigned int on)
static int set_irq_wake_real(unsigned int irq, unsigned int on)

> +{
> +	struct irq_desc *desc = irq_desc + irq;
> +	int ret = -ENXIO;
> +
> +	if (desc->chip->set_wake)
> +		ret = desc->chip->set_wake(irq, on);
> +
> +	return ret;
> +}
> +

Best Regards

Ingo Oeser

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

* Re: [PATCH] set_irq_wake: fix return code and wake status tracking
  2008-07-23 18:44 ` Ingo Oeser
@ 2008-07-24  5:42   ` Uwe Kleine-König
  0 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2008-07-24  5:42 UTC (permalink / raw)
  To: Ingo Oeser; +Cc: linux-kernel

Hello Ingo,

Ingo Oeser wrote:
> you can mark the new function static.
Right, good catch.  As this patch already hit mainline I will send a
followup.

Thanks,
Uwe

-- 
Uwe Kleine-König, Software Engineer
Digi International GmbH Branch Breisach, Küferstrasse 8, 79206 Breisach, Germany
Tax: 315/5781/0242 / VAT: DE153662976 / Reg. Amtsgericht Dortmund HRB 13962

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

* [PATCH] make set_irq_wake_real static
  2008-07-23 12:42 [PATCH] set_irq_wake: fix return code and wake status tracking Uwe Kleine-König
  2008-07-23 16:00 ` David Brownell
  2008-07-23 18:44 ` Ingo Oeser
@ 2008-07-24  5:51 ` Uwe Kleine-König
  2 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2008-07-24  5:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Oeser

set_irq_wake_real was introduced in 2db873211ba47ef704c301f9ecf4a33413a0b649
and its only user is set_irq_wake.

Noticed-by: Ingo Oeser <ioe-lkml@rameria.de>
Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
---
 kernel/irq/manage.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 3cfc0fe..4476cd0 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -217,7 +217,7 @@ void enable_irq(unsigned int irq)
 }
 EXPORT_SYMBOL(enable_irq);
 
-int set_irq_wake_real(unsigned int irq, unsigned int on)
+static int set_irq_wake_real(unsigned int irq, unsigned int on)
 {
 	struct irq_desc *desc = irq_desc + irq;
 	int ret = -ENXIO;
-- 
1.5.6.3


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

end of thread, other threads:[~2008-07-24  5:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-23 12:42 [PATCH] set_irq_wake: fix return code and wake status tracking Uwe Kleine-König
2008-07-23 16:00 ` David Brownell
2008-07-23 18:44 ` Ingo Oeser
2008-07-24  5:42   ` Uwe Kleine-König
2008-07-24  5:51 ` [PATCH] make set_irq_wake_real static 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

all inboxes | Powered by JetHome®