Thread (7 messages) 7 messages, 3 authors, 2011-10-09

Re: [PATCH] input/imx_keypad: add pm suspend and resume functions

From: Hui Wang <hidden>
Date: 2011-10-09 09:50:13

Dmitry Torokhov wrote:
On Fri, Sep 30, 2011 at 04:59:53PM +0800, Hui Wang wrote:
  
quoted
Wanlong Gao wrote:
    
quoted
On 09/30/2011 03:54 PM, Hui Wang wrote:
      
quoted
+
+static int imx_kbd_resume(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct imx_keypad *kbd = platform_get_drvdata(pdev);
+	struct input_dev *input_dev = kbd->input_dev;
+
+	mutex_lock(&input_dev->mutex);
+
+	if (device_may_wakeup(&pdev->dev))
+		disable_irq_wake(kbd->irq);
+
+	if (input_dev->users)
+		clk_enable(kbd->clk);
+
+	mutex_unlock(&input_dev->mutex);
+
+	return 0;
+}
        
	struct input_dev *input_dev = kbd->input_dev;
	if (device_may_wakeup(dev)) {
		disable_irq_wake(kdb->irq);
	} else {
		mutex_lock(&input_dev->mutex);

		if (input_dev->users)
			clk_enable(kbd->clk);

		mutex_unlock(&input_dev->mutex);
	}

      
So, if we unconditionally disable kpp clock in the suspend, we don't
need above logic as well in the resume.
    
We should not unconditionally disable clock in suspend, you need to check
if there are any users (or drop check in resume), otherwise you'll get
unbalanced count in clk (suspend - decrement, resume - not enabling clk
if device is not being used).

Also locking is needed in suspend.

  
Got it, will fix them in the V2.

Thanks,
Hui.
Thanks.

  
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help