Received: by 10.223.185.116 with SMTP id b49csp2240380wrg; Sat, 24 Feb 2018 14:45:38 -0800 (PST) X-Google-Smtp-Source: AH8x2271dpcK6D/WHFyKGRbU882Dpp+n5VXUqxFDbxaJKcUt19k0e+VtGnuvqSVhuiN8UVS/YM8X X-Received: by 10.99.44.22 with SMTP id s22mr4839341pgs.111.1519512338218; Sat, 24 Feb 2018 14:45:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519512338; cv=none; d=google.com; s=arc-20160816; b=t5GUaSkP2+odCPh40kNWV6c5ddV0MGjRNbwWqPzPYxQhMaYUU88Ehgdie9IGXNSh2B LZxabt2y+HatbCgsP58YrifMbgo+kg6rC3kZgnlWMv8jjHURBgK4JsncMyhYCpf6HhKh K1rhJB+SKp21DxoAyJY7EXgTCC38orhesXZsmKBGpaHJMWuCUgBpgEqlgopVpmp6S0hW ztgtvYXZAI19PN1tDAYb93I9HRetOk/D4DW17Dr8/Lf2X880Xl9bAS///3dW/JiCP6Ku +LRAB6/iXjgx/DCUAS8Lk0Fgj7UM5BrBKnWdwYL0F9psbhzEmTLYXZnJz1NShP8oJFk9 1O8Q== 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=hlCdP0+34tZqv/a/zf8Ms7I+A95DCv6mXxzTTFC1z6I=; b=XjTRXPL8KxtAPP3k9N44hfhyJ7JK1OsOh3e9foBGGynufVtfaB9bM8MZgTGEkBL4PI UU5ZR7+cDHtv31oVZY3ILh0t+h8GO5jgNquGOsMQV/nyOFLyWoIxCisB2YTNX4XmIOvM Pm45QyWEiYuYSk7p26+Fez2IaSKNQs6nafaNX/tHlVTGjYEc5/mkVq3IrL8qjolEZo7u O7fM0wNogFdkaQ0mJHkb2KC93SJ+23vz6r9pxA8gP4pH2Fj6RAnxcwQ9lEjfu/oFVldj NmltGllHbX/8e1Dy5FhyI2vo4b2Vi0iY9hcGV/x3SuRU6FmwSuELjwQ0QJBFVUzixpzY kFvg== 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 1-v6si4197547pll.459.2018.02.24.14.45.24; Sat, 24 Feb 2018 14:45:38 -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 S1751582AbeBXWnG (ORCPT + 99 others); Sat, 24 Feb 2018 17:43:06 -0500 Received: from agrajag.zerfleddert.de ([88.198.237.222]:33082 "EHLO agrajag.zerfleddert.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751558AbeBXWnF (ORCPT ); Sat, 24 Feb 2018 17:43:05 -0500 Received: by agrajag.zerfleddert.de (Postfix, from userid 1000) id C7B715B202C8; Sat, 24 Feb 2018 23:43:03 +0100 (CET) Date: Sat, 24 Feb 2018 23:43:03 +0100 From: Tobias Jordan To: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wolfram Sang Subject: [PATCH] i2c: img-scb: fix PM device usage count Message-ID: <20180224224303.3mpwhal2axcr6aos@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 error branch. Fixes: 93222bd9b966 ("i2c: img-scb: Add runtime PM") 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-img-scb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c index f038858b6c54..569a1a8a2753 100644 --- a/drivers/i2c/busses/i2c-img-scb.c +++ b/drivers/i2c/busses/i2c-img-scb.c @@ -1061,8 +1061,10 @@ static int img_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, } ret = pm_runtime_get_sync(adap->dev.parent); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(adap->dev.parent); return ret; + } for (i = 0; i < num; i++) { struct i2c_msg *msg = &msgs[i]; @@ -1162,8 +1164,10 @@ static int img_i2c_init(struct img_i2c *i2c) int ret; ret = pm_runtime_get_sync(i2c->adap.dev.parent); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(i2c->adap.dev.parent); return ret; + } rev = img_i2c_readl(i2c, SCB_CORE_REV_REG); if ((rev & 0x00ffffff) < 0x00020200) { -- 2.11.0