From patchwork Tue Aug 7 12:37:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 1285481 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 0D26D3FD8D for ; Tue, 7 Aug 2012 12:41:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754476Ab2HGMl1 (ORCPT ); Tue, 7 Aug 2012 08:41:27 -0400 Received: from na3sys009aog111.obsmtp.com ([74.125.149.205]:51736 "EHLO na3sys009aog111.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753849Ab2HGMlW (ORCPT ); Tue, 7 Aug 2012 08:41:22 -0400 Received: from mail-lb0-f178.google.com ([209.85.217.178]) (using TLSv1) by na3sys009aob111.postini.com ([74.125.148.12]) with SMTP ID DSNKUCEM47KVJFK1JXXBXJZXgKMemsltA0Mc@postini.com; Tue, 07 Aug 2012 05:41:21 PDT Received: by lbok6 with SMTP id k6so701057lbo.9 for ; Tue, 07 Aug 2012 05:40:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=iNT+0WMAm1fyeXCGRiAfIK4vqdzCRbNLWkfYEPa3pFU=; b=DRvSNQLFRoGSkRo+z4DGA8oLNn6ji9pVFQ9qbHlig04o1rSvTk+qVylRlQRGvM9g5a SZ4BZaJo6ORUrl0+UEIEPGHrHr6LFOmPq1L4FYu919cykuu5kSHwMMha4MELmB7VkZJt LBw8fSy7PlSAv9MgpT+PlsPhdzw4OH61spsGcrlEYSwQL1kM4mPrpnWXivvTQS6IU6p/ Jed+5KS1Zk6qze80SEE3X5mnLv52Xv0dRl6WapE30UqOlpmoy1SzPuMW96ppt/O7tFS2 kEnCicgclCdr30j2HfEle7P2fv9SXkFmbdZSyzS2CjRfhfgTf2NsOUq97xoKrqRrMW5v 5wFw== Received: by 10.152.106.233 with SMTP id gx9mr14367602lab.48.1344343249956; Tue, 07 Aug 2012 05:40:49 -0700 (PDT) Received: from localhost (cs78217178.pp.htv.fi. [62.78.217.178]) by mx.google.com with ESMTPS id o5sm4349308lbg.5.2012.08.07.05.40.48 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 07 Aug 2012 05:40:49 -0700 (PDT) From: Felipe Balbi To: Shubhrajyoti Datta Cc: Linux OMAP Mailing List , Linux ARM Kernel Mailing List , w.sang@pengutronix.de, vaibhav.bedia@ti.com, Felipe Balbi Subject: [PATCH v3] i2c: omap: switch over to autosuspend API Date: Tue, 7 Aug 2012 15:37:16 +0300 Message-Id: <1344343036-8832-1-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.7.12.rc0 X-Gm-Message-State: ALoCoQkLGh7ZBaJjTs07GPM5XvL8kgZB5wHbD/gpQxtoTKx+MXWDPP46evwrFUUZx40IRTUHRLx8 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org this helps us reduce unnecessary pm transitions in case we have another i2c message starting soon. Signed-off-by: Felipe Balbi --- drivers/i2c/busses/i2c-omap.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 60928f2..35e8207 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -55,6 +55,9 @@ /* timeout waiting for the controller to respond */ #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) +/* timeout for pm runtime autosuspend */ +#define OMAP_I2C_PM_TIMEOUT 1000 /* ms */ + /* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */ enum { OMAP_I2C_REV_REG = 0, @@ -645,7 +648,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) omap_i2c_wait_for_bb(dev); out: - pm_runtime_put(dev->dev); + pm_runtime_mark_last_busy(dev->dev); + pm_runtime_put_autosuspend(dev->dev); return r; } @@ -1113,6 +1117,9 @@ omap_i2c_probe(struct platform_device *pdev) dev->regs = (u8 *)reg_map_ip_v1; pm_runtime_enable(dev->dev); + pm_runtime_set_autosuspend_delay(dev->dev, OMAP_I2C_PM_TIMEOUT); + pm_runtime_use_autosuspend(dev->dev); + r = pm_runtime_get_sync(dev->dev); if (IS_ERR_VALUE(r)) goto err_free_mem; @@ -1189,7 +1196,8 @@ omap_i2c_probe(struct platform_device *pdev) of_i2c_register_devices(adap); - pm_runtime_put(dev->dev); + pm_runtime_mark_last_busy(dev->dev); + pm_runtime_put_autosuspend(dev->dev); return 0;