From patchwork Thu Apr 21 13:35:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 724891 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3LDSW6v019949 for ; Thu, 21 Apr 2011 13:28:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752176Ab1DUN2b (ORCPT ); Thu, 21 Apr 2011 09:28:31 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:38524 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751984Ab1DUN2a (ORCPT ); Thu, 21 Apr 2011 09:28:30 -0400 Received: by pvg12 with SMTP id 12so862188pvg.19 for ; Thu, 21 Apr 2011 06:28:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:date:message-id:subject; bh=v13bLncBqfNrdzuCKSJXLiJKbvvOhXmIGOcZoDJYFqk=; b=OetEXSk7Z8AjM9J0gkNrQ+yk/SLnQjgXsL/knMT2517mFdjevvtbeOVSlpOfrFSwuj OzXnvmVYouVo7e1ECh1RY6u3mdz0GPGiRBRfZcZ/zU46TqpndV1Isoff6XIfORJjFzqR rNqNDBf4X7CuzQnijezFdnImrr+EW0EzgSCE4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:subject; b=Y1l7PJzOdYBdosFfNXSEpAM1lN3JLKy7smMNuPb72bZ0HFk9242tnBWuNizmtMbseO tJyWkjGx9aLEijynaJZGOeA4a7D7T66lHMOxfFGXEmlhAdeQ6yeG14/mhmSW76ev5NPN Dm6qkI62VfFyuz1YLdh2Nii0rliOsWNI7eliU= Received: by 10.68.23.106 with SMTP id l10mr907942pbf.65.1303392510398; Thu, 21 Apr 2011 06:28:30 -0700 (PDT) Received: from [127.0.0.1] (49.14.32.202.bf.2iij.net [202.32.14.49]) by mx.google.com with ESMTPS id t4sm1317983pbl.45.2011.04.21.06.28.28 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 21 Apr 2011 06:28:29 -0700 (PDT) From: Magnus Damm To: linux-input@vger.kernel.org Cc: linux-sh@vger.kernel.org, dmitry.torokhov@gmail.com, rjw@sisk.pl, lethal@linux-sh.org, simon@horms.net, Magnus Damm Date: Thu, 21 Apr 2011 22:35:14 +0900 Message-Id: <20110421133514.8688.44489.sendpatchset@t400s> Subject: [PATCH] input: sh_keysc: Runtime PM support Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 21 Apr 2011 13:28:32 +0000 (UTC) From: Magnus Damm Convert the KEYSC driver from MSTP bit control through a magic clock string to making use of Runtime PM. Also, update the system suspend/resume callbacks to drop the Runtime PM reference in the case of wakeup disabled. Signed-off-by: Magnus Damm --- drivers/input/keyboard/sh_keysc.c | 40 +++++++++++++------------------------ 1 file changed, 15 insertions(+), 25 deletions(-) -- 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 --- 0001/drivers/input/keyboard/sh_keysc.c +++ work/drivers/input/keyboard/sh_keysc.c 2011-04-21 22:26:54.000000000 +0900 @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include @@ -37,7 +37,6 @@ static const struct { struct sh_keysc_priv { void __iomem *iomem_base; - struct clk *clk; DECLARE_BITMAP(last_keys, SH_KEYSC_MAXKEYS); struct input_dev *input; struct sh_keysc_info pdata; @@ -169,7 +168,6 @@ static int __devinit sh_keysc_probe(stru struct sh_keysc_info *pdata; struct resource *res; struct input_dev *input; - char clk_name[8]; int i; int irq, error; @@ -210,19 +208,11 @@ static int __devinit sh_keysc_probe(stru goto err1; } - snprintf(clk_name, sizeof(clk_name), "keysc%d", pdev->id); - priv->clk = clk_get(&pdev->dev, clk_name); - if (IS_ERR(priv->clk)) { - dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); - error = PTR_ERR(priv->clk); - goto err2; - } - priv->input = input_allocate_device(); if (!priv->input) { dev_err(&pdev->dev, "failed to allocate input device\n"); error = -ENOMEM; - goto err3; + goto err2; } input = priv->input; @@ -244,7 +234,7 @@ static int __devinit sh_keysc_probe(stru error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev); if (error) { dev_err(&pdev->dev, "failed to request IRQ\n"); - goto err4; + goto err3; } for (i = 0; i < SH_KEYSC_MAXKEYS; i++) @@ -254,10 +244,11 @@ static int __devinit sh_keysc_probe(stru error = input_register_device(input); if (error) { dev_err(&pdev->dev, "failed to register input device\n"); - goto err5; + goto err4; } - clk_enable(priv->clk); + pm_runtime_enable(&pdev->dev); + pm_runtime_get_sync(&pdev->dev); sh_keysc_write(priv, KYCR1, (sh_keysc_mode[pdata->mode].kymd << 8) | pdata->scan_timing); @@ -267,12 +258,10 @@ static int __devinit sh_keysc_probe(stru return 0; - err5: - free_irq(irq, pdev); err4: - input_free_device(input); + free_irq(irq, pdev); err3: - clk_put(priv->clk); + input_free_device(input); err2: iounmap(priv->iomem_base); err1: @@ -292,8 +281,8 @@ static int __devexit sh_keysc_remove(str free_irq(platform_get_irq(pdev, 0), pdev); iounmap(priv->iomem_base); - clk_disable(priv->clk); - clk_put(priv->clk); + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); platform_set_drvdata(pdev, NULL); kfree(priv); @@ -311,14 +300,13 @@ static int sh_keysc_suspend(struct devic value = sh_keysc_read(priv, KYCR1); if (device_may_wakeup(dev)) { - value |= 0x80; + sh_keysc_write(priv, KYCR1, value | 0x80); enable_irq_wake(irq); } else { - value &= ~0x80; + sh_keysc_write(priv, KYCR1, value & ~0x80); + pm_runtime_put_sync(dev); } - sh_keysc_write(priv, KYCR1, value); - return 0; } @@ -329,6 +317,8 @@ static int sh_keysc_resume(struct device if (device_may_wakeup(dev)) disable_irq_wake(irq); + else + pm_runtime_get_sync(dev); return 0; }