Received: by 10.223.185.116 with SMTP id b49csp2240565wrg; Sat, 24 Feb 2018 14:46:01 -0800 (PST) X-Google-Smtp-Source: AH8x225i4LjczvE0ktIDaxMxGozOyHJM+pZHKdWbvNAVJKJrVEqHKF5wEL3f5VjhqjI9qPMgUzsX X-Received: by 2002:a17:902:36a:: with SMTP id 97-v6mr6121049pld.365.1519512361749; Sat, 24 Feb 2018 14:46:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519512361; cv=none; d=google.com; s=arc-20160816; b=hkfZk0YpFKRfdD713mEUgbts+IjQwDUqnPYb1qAVQ0GNuusFV+mE9vvRpoWfjC7Wz7 s6V/uMig4oOUxKhnVeLxk5Ism+i9B13y+meguPuQTi2EcZVf55iq4S5kfXRQWBTD6Jmz R/KmT02KfnPdbD1M4iHet5IgkE0wzIAp8oxkChBfWyKsCuakHn6A3AHG3rtENCa/TWHX 8VAb9VB1D04vS/4P+CAZ60uoWFRJNCJN0RcRzFyELCMXRVgkYO5ON4tak1VbfNGpLUPd csLr7g0zg+ev9KQv/RxDAadXL0aYAr8BKI3v509dYDv5ggNgiD4P5RI3wuVMImUGTUSf 6oQQ== 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=sC232qloq2v11vnfgO3LOwNua4q849qg3CiaxY+0DYA=; b=YIMGHI/4hbBBlNmTzTV9GZZcXNDMFcG6UZqQgTnISRIzRs09DokZsuKIx/sp9DWDWX FqpMBxPukCLNru10XpKkETvWC3dYGib8e6+vZHiOhfOuxSCv5+uf8NC1nh5Edo3tI8kV gC3ANrIGlSE129889ornPJVVZdeW8o/ON1Iecal1tQIYTD75kAHMwRmnbwT8h9JFX1hh 7w+VQy2+54t+GzyXztsTOZNKq54oyZ9umewxMsVo6y2QLUZkC2gSxINw0yb7Tr0raLEr H2YLM3nLMEwOP1g3cpzxepJFB1LUmMFWZTB4NQYqx0JzFceL2MH171ZEVPdVFsAxp0jl NNXw== 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 j15-v6si4283968pli.649.2018.02.24.14.45.47; Sat, 24 Feb 2018 14:46:01 -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 S1751730AbeBXWoH (ORCPT + 99 others); Sat, 24 Feb 2018 17:44:07 -0500 Received: from agrajag.zerfleddert.de ([88.198.237.222]:33108 "EHLO agrajag.zerfleddert.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751542AbeBXWoG (ORCPT ); Sat, 24 Feb 2018 17:44:06 -0500 Received: by agrajag.zerfleddert.de (Postfix, from userid 1000) id B62C95B20753; Sat, 24 Feb 2018 23:44:04 +0100 (CET) Date: Sat, 24 Feb 2018 23:44:04 +0100 From: Tobias Jordan To: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wolfram Sang Subject: [PATCH] i2c: sprd: Fix PM device usage count Message-ID: <20180224224404.un32pjj76chi2bqc@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: 8b9ec0719834 ("i2c: Add Spreadtrum I2C controller driver") Signed-off-by: Tobias Jordan --- 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-sprd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c index 25fcc3c1e32b..5dae56e9ef73 100644 --- a/drivers/i2c/busses/i2c-sprd.c +++ b/drivers/i2c/busses/i2c-sprd.c @@ -284,8 +284,10 @@ static int sprd_i2c_master_xfer(struct i2c_adapter *i2c_adap, int im, ret; ret = pm_runtime_get_sync(i2c_dev->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(i2c_dev->dev); return ret; + } for (im = 0; im < num - 1; im++) { ret = sprd_i2c_handle_msg(i2c_adap, &msgs[im], 0); @@ -572,8 +574,10 @@ static int sprd_i2c_remove(struct platform_device *pdev) int ret; ret = pm_runtime_get_sync(i2c_dev->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(i2c_dev->dev); return ret; + } i2c_del_adapter(&i2c_dev->adap); clk_disable_unprepare(i2c_dev->clk); -- 2.11.0