diff mbox

[2/6] input/spear_keyboard: fix clock handling during suspend/resume

Message ID 1341211814-15173-2-git-send-email-shiraz.hashim@st.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shiraz HASHIM July 2, 2012, 6:50 a.m. UTC
SPEAr keyboard should normally disable clock during suspend and enable it
during resume.

For cases where it is expected to act as a wakeup source the clock can
remain in the same state i.e. kept enabled if it is being used.

Signed-off-by: Shiraz Hashim <shiraz.hashim@st.com>
---
 drivers/input/keyboard/spear-keyboard.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Dmitry Torokhov July 8, 2012, 1:11 a.m. UTC | #1
Hi Shiraz,

On Mon, Jul 02, 2012 at 12:20:10PM +0530, Shiraz Hashim wrote:
> SPEAr keyboard should normally disable clock during suspend and enable it
> during resume.
> 
> For cases where it is expected to act as a wakeup source the clock can
> remain in the same state i.e. kept enabled if it is being used.
> 
> Signed-off-by: Shiraz Hashim <shiraz.hashim@st.com>
> ---
>  drivers/input/keyboard/spear-keyboard.c |   12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
> index 67d9afb..ef147f3 100644
> --- a/drivers/input/keyboard/spear-keyboard.c
> +++ b/drivers/input/keyboard/spear-keyboard.c
> @@ -318,12 +318,12 @@ static int spear_kbd_suspend(struct device *dev)
>  
>  	mutex_lock(&input_dev->mutex);
>  
> -	if (input_dev->users)
> -		clk_enable(kbd->clk);
> -
>  	if (device_may_wakeup(&pdev->dev)) {
>  		if (!enable_irq_wake(kbd->irq))
>  			kbd->irq_wake = 1;
> +	} else {
> +		if (input_dev->users)
> +			clk_disable(kbd->clk);
>  	}

This patch does not apply to mainline version of the driver because the
change introducing handling for enable_irq_wake() failures was rejected
from mainline. I also have not appplied the 6th patch in the series
because it depends on this one.

Also, don't you need to enable clock if device is marked as wakeup
source but happens to have no active users?

Thanks.
Shiraz HASHIM July 9, 2012, 4:03 a.m. UTC | #2
Hi Dmitry,

On Sat, Jul 07, 2012 at 06:11:55PM -0700, Dmitry Torokhov wrote:
> Hi Shiraz,
> 
> On Mon, Jul 02, 2012 at 12:20:10PM +0530, Shiraz Hashim wrote:
> > SPEAr keyboard should normally disable clock during suspend and enable it
> > during resume.
> > 
> > For cases where it is expected to act as a wakeup source the clock can
> > remain in the same state i.e. kept enabled if it is being used.
> > 
> > Signed-off-by: Shiraz Hashim <shiraz.hashim@st.com>
> > ---
> >  drivers/input/keyboard/spear-keyboard.c |   12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
> > index 67d9afb..ef147f3 100644
> > --- a/drivers/input/keyboard/spear-keyboard.c
> > +++ b/drivers/input/keyboard/spear-keyboard.c
> > @@ -318,12 +318,12 @@ static int spear_kbd_suspend(struct device *dev)
> >  
> >  	mutex_lock(&input_dev->mutex);
> >  
> > -	if (input_dev->users)
> > -		clk_enable(kbd->clk);
> > -
> >  	if (device_may_wakeup(&pdev->dev)) {
> >  		if (!enable_irq_wake(kbd->irq))
> >  			kbd->irq_wake = 1;
> > +	} else {
> > +		if (input_dev->users)
> > +			clk_disable(kbd->clk);
> >  	}
> 
> This patch does not apply to mainline version of the driver because the
> change introducing handling for enable_irq_wake() failures was rejected
> from mainline. I also have not appplied the 6th patch in the series
> because it depends on this one.

Oh. Sorry, I should have been careful. I would clean up and send V2
for this.

> Also, don't you need to enable clock if device is marked as wakeup
> source but happens to have no active users?

The keyboard is initialized and programmed in open and disabled in
close, so I thought even if I just enable the clock in suspend
(without open being called) it would not be able to generate the
wakeup interrupt.

--
regards
Shiraz
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
index 67d9afb..ef147f3 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -318,12 +318,12 @@  static int spear_kbd_suspend(struct device *dev)
 
 	mutex_lock(&input_dev->mutex);
 
-	if (input_dev->users)
-		clk_enable(kbd->clk);
-
 	if (device_may_wakeup(&pdev->dev)) {
 		if (!enable_irq_wake(kbd->irq))
 			kbd->irq_wake = 1;
+	} else {
+		if (input_dev->users)
+			clk_disable(kbd->clk);
 	}
 
 	mutex_unlock(&input_dev->mutex);
@@ -344,11 +344,11 @@  static int spear_kbd_resume(struct device *dev)
 			kbd->irq_wake = 0;
 			disable_irq_wake(kbd->irq);
 		}
+	} else {
+		if (input_dev->users)
+			clk_enable(kbd->clk);
 	}
 
-	if (input_dev->users)
-		clk_enable(kbd->clk);
-
 	mutex_unlock(&input_dev->mutex);
 
 	return 0;