Received: by 10.223.185.116 with SMTP id b49csp2239876wrg; Sat, 24 Feb 2018 14:44:39 -0800 (PST) X-Google-Smtp-Source: AH8x227VnwTAqCai3h+s2JSHY64zpoeIk0wsvtv40akFdRw8NPyXnZOPrLYpvkoOBlYHEyKE4BKq X-Received: by 10.101.83.194 with SMTP id z2mr4819298pgr.133.1519512279874; Sat, 24 Feb 2018 14:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519512279; cv=none; d=google.com; s=arc-20160816; b=LRXCyrtrVYHjKnsyLm3mUQt1lfUrXxaTwVFulo7gMPbi6cp688GkvyUb2hGvr34Kr9 75pcQjJfmmfMC0c31JEIrNxYzJSlacpBMCJoXE7kw3OAgSnpwyUaamKozLjmqP3vf3NL m0WU2Du+G8m1Z7UPGexJQGPbHVLk9WDf0UMT825oNHPKUVRwceEhMJ+AcRJI4+X/7KpT SrgEtIFbzxs1aixAN45CN9KuuySYdMBDgwHUoOolLmwiMVR4zE6uHc14rXWKpIMhoF5M 7xw+wGv7GHL/Zbxc1bZsX53qJg3v2BrzktbdF60BuBpE2AF0A5pQfJAW0JVVw0Ym1xNn Fbww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=GbOZXLiKjUGtZ0KtPPi/OxaUIGecYetwZ+YB+MJlSbo=; b=rXfFHU4Tqk3agBXEo/gtx8xPPfgO1e23ZOWcRBHzG0QfDRCtcRQN2xf25VEar5NjnU +KdiAwVDjMfErmUCLrKBq538uMtZvWeMCx52fBeLezXedb7pFk03UueG13RTM8fd+hfK Cf0pZhnubutFy4+q2E86TLaq8rpC5/QljTzLxCbXCbXNDWGAke76hWy0w+PpKcaqf2Gm QObpnEcxdv3UU4X0bhtnc7gUN9NsxIkCv2fJEsODUk1kaGwP6C53NW+mJX9eyGvLcDat y303hCRX+CipCrqd80TtyAYrvgANzePUpPN0oCe1srvoY+qBb852xjhlPQC4t4b+8HCX N6Yw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r79si4190737pfb.126.2018.02.24.14.44.25; Sat, 24 Feb 2018 14:44:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751638AbeBXWnb (ORCPT + 99 others); Sat, 24 Feb 2018 17:43:31 -0500 Received: from agrajag.zerfleddert.de ([88.198.237.222]:33094 "EHLO agrajag.zerfleddert.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751545AbeBXWna (ORCPT ); Sat, 24 Feb 2018 17:43:30 -0500 Received: by agrajag.zerfleddert.de (Postfix, from userid 1000) id EF85F5B204A2; Sat, 24 Feb 2018 23:43:28 +0100 (CET) Date: Sat, 24 Feb 2018 23:43:28 +0100 From: Tobias Jordan To: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wolfram Sang Subject: [PATCH] i2c: imx: Fix PM device usage count Message-ID: <20180224224328.2pfki7rqcxqetmlz@agrajag.zerfleddert.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pm_runtime_get_sync() increases the device's usage count even when reporting an error, so add a call to pm_runtime_put_noidle() in the related error branches. Fixes: 588eb93ea49f ("i2c: imx: add runtime pm support to improve the performance") Signed-off-by: Tobias Jordan --- In i2c_imx_xfer(), one could also move the "out" label up (in front of the call to pm_runtime_put_autosuspend()), but I'm not sure what the underlying error scenario is; calling _put_noidle() seems to be the safer bet. This is one of a number of patches for problems found using coccinelle scripting in the SIL2LinuxMP project. The patch has been compile-tested; it's based on linux-next-20180223. For a discussion of the corresponding issue, see https://marc.info/?l=linux-pm&m=151904483924999&w=2 drivers/i2c/busses/i2c-imx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 999557729ad2..dae3c923d42c 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -890,8 +890,10 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter, dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__); result = pm_runtime_get_sync(i2c_imx->adapter.dev.parent); - if (result < 0) + if (result < 0) { + pm_runtime_put_noidle(i2c_imx->adapter.dev.parent); goto out; + } /* Start I2C transfer */ result = i2c_imx_start(i2c_imx); @@ -1179,8 +1181,10 @@ static int i2c_imx_remove(struct platform_device *pdev) int ret; ret = pm_runtime_get_sync(&pdev->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(&pdev->dev); return ret; + } /* remove adapter */ dev_dbg(&i2c_imx->adapter.dev, "adapter removed\n"); -- 2.11.0