From patchwork Tue Aug 7 12:38:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 1285491 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 607B93FCC5 for ; Tue, 7 Aug 2012 12:42:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754204Ab2HGMmD (ORCPT ); Tue, 7 Aug 2012 08:42:03 -0400 Received: from na3sys009aog127.obsmtp.com ([74.125.149.107]:35666 "EHLO na3sys009aog127.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753817Ab2HGMmC (ORCPT ); Tue, 7 Aug 2012 08:42:02 -0400 Received: from mail-lb0-f182.google.com ([209.85.217.182]) (using TLSv1) by na3sys009aob127.postini.com ([74.125.148.12]) with SMTP ID DSNKUCENFOaMscXKM/Z2pK9L66hj4sTMV8C+@postini.com; Tue, 07 Aug 2012 05:42:01 PDT Received: by lbbgk8 with SMTP id gk8so2234567lbb.27 for ; Tue, 07 Aug 2012 05:41:40 -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:in-reply-to:references :x-gm-message-state; bh=iNT+0WMAm1fyeXCGRiAfIK4vqdzCRbNLWkfYEPa3pFU=; b=TR2zlNxdcPRc+uiB5EYNAyAJ8dqsfKh10lZj1kLtk7fa+1iJ+TDzXJZFJsFJGNNNIu 91R/6X03r8PT77Gl7+7w5mujRQ0jiRh0mn7IZnp1smA0bx/PFItiDkFdrPf8jDA5M7Xz 9H83iy1Dq64/s+CS+0KYRRvYiBt+8a0de+H4TKdeiT1RcPmVA76SvNVHSF+OOAkJnEZp Ce853uMz41n3ajrr6TrAf3fb5kDluOoyMqpkR+sGzJFF506c0eFziXboCt85TCZUuVpH 6IMv9SMcWbdwmWB8tFMlnvjzB+u/m2U8DXSWlWl1ZBMZo67A4A3oHbDnxUKdhiPDPMq1 WElg== Received: by 10.152.103.146 with SMTP id fw18mr14391750lab.30.1344343300695; Tue, 07 Aug 2012 05:41:40 -0700 (PDT) Received: from localhost (cs78217178.pp.htv.fi. [62.78.217.178]) by mx.google.com with ESMTPS id ta2sm19945385lab.15.2012.08.07.05.41.39 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 07 Aug 2012 05:41:39 -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:38:07 +0300 Message-Id: <1344343087-8947-1-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.7.12.rc0 In-Reply-To: References: X-Gm-Message-State: ALoCoQmUijVRAIWXa3ZgLnWTmYcCThapHmX4WXLD91D+YkfO8+27ypd440ZQkfaVPbsofivAy4+1 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;