Patchwork [1/3] rtc-spear: Fix for balancing the enable_irq_wake in Power Mgmt

login
register
mail settings
Submitter Viresh KUMAR
Date Jan. 5, 2012, 9 a.m.
Message ID <037e62c0af58b1ad861145c1b78c2781a0b0b3e5.1325753573.git.viresh.kumar@st.com>
Download mbox | patch
Permalink /patch/134441/
State New
Headers show

Comments

Viresh KUMAR - Jan. 5, 2012, 9 a.m.
From: Deepak Sikri <deepak.sikri@st.com>

This patch handles the fix for unbalanced irq for the cases when
enable_irq_wake fails, and a warning related to same is displayed
on the console. The workaround is handled at the driver level.

Signed-off-by: Deepak Sikri <deepak.sikri@st.com>
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 drivers/rtc/rtc-spear.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
rajeev - Jan. 5, 2012, 9:36 a.m.
On 1/5/2012 2:38 PM, Viresh KUMAR wrote:
> From: Deepak Sikri<deepak.sikri@st.com>
>
> This patch handles the fix for unbalanced irq for the cases when
> enable_irq_wake fails, and a warning related to same is displayed
> on the console. The workaround is handled at the driver level.
>
> Signed-off-by: Deepak Sikri<deepak.sikri@st.com>
> Signed-off-by: Viresh Kumar<viresh.kumar@st.com>
> ---
>   drivers/rtc/rtc-spear.c |   17 +++++++++++------
>   1 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
> index 893bac2..7895712 100644
> --- a/drivers/rtc/rtc-spear.c
> +++ b/drivers/rtc/rtc-spear.c
> @@ -80,6 +80,7 @@ struct spear_rtc_config {
>   	struct clk *clk;
>   	spinlock_t lock;
>   	void __iomem *ioaddr;
> +	unsigned int irq_wake;
>   };
>
>   static inline void spear_rtc_clear_interrupt(struct spear_rtc_config *config)
> @@ -463,9 +464,10 @@ static int spear_rtc_suspend(struct platform_device *pdev, pm_message_t state)
>   	int irq;
>
>   	irq = platform_get_irq(pdev, 0);
> -	if (device_may_wakeup(&pdev->dev))
> -		enable_irq_wake(irq);
> -	else {
> +	if (device_may_wakeup(&pdev->dev)) {
> +		if (!enable_irq_wake(irq))
> +			config->irq_wake = 1;
> +	} else {
>   		spear_rtc_disable_interrupt(config);
>   		clk_disable(config->clk);
>   	}
> @@ -481,9 +483,12 @@ static int spear_rtc_resume(struct platform_device *pdev)
>
>   	irq = platform_get_irq(pdev, 0);
>
> -	if (device_may_wakeup(&pdev->dev))
> -		disable_irq_wake(irq);
> -	else {
> +	if (device_may_wakeup(&pdev->dev)) {
> +		if (config->irq_wake) {
> +			disable_irq_wake(irq);
> +			config->irq_wake = 0;
> +		}
> +	} else {
>   		clk_enable(config->clk);
>   		spear_rtc_enable_interrupt(config);
>   	}

Acked-by: Rajeev Kumar <rajeev-dlh.kumar@st.com>

Patch

diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
index 893bac2..7895712 100644
--- a/drivers/rtc/rtc-spear.c
+++ b/drivers/rtc/rtc-spear.c
@@ -80,6 +80,7 @@  struct spear_rtc_config {
 	struct clk *clk;
 	spinlock_t lock;
 	void __iomem *ioaddr;
+	unsigned int irq_wake;
 };
 
 static inline void spear_rtc_clear_interrupt(struct spear_rtc_config *config)
@@ -463,9 +464,10 @@  static int spear_rtc_suspend(struct platform_device *pdev, pm_message_t state)
 	int irq;
 
 	irq = platform_get_irq(pdev, 0);
-	if (device_may_wakeup(&pdev->dev))
-		enable_irq_wake(irq);
-	else {
+	if (device_may_wakeup(&pdev->dev)) {
+		if (!enable_irq_wake(irq))
+			config->irq_wake = 1;
+	} else {
 		spear_rtc_disable_interrupt(config);
 		clk_disable(config->clk);
 	}
@@ -481,9 +483,12 @@  static int spear_rtc_resume(struct platform_device *pdev)
 
 	irq = platform_get_irq(pdev, 0);
 
-	if (device_may_wakeup(&pdev->dev))
-		disable_irq_wake(irq);
-	else {
+	if (device_may_wakeup(&pdev->dev)) {
+		if (config->irq_wake) {
+			disable_irq_wake(irq);
+			config->irq_wake = 0;
+		}
+	} else {
 		clk_enable(config->clk);
 		spear_rtc_enable_interrupt(config);
 	}