From patchwork Sat Feb 24 22:43:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Jordan X-Patchwork-Id: 877479 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=elektrobit.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zpjwg6P8Mz9sWP for ; Sun, 25 Feb 2018 09:50:27 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751480AbeBXWuZ (ORCPT ); Sat, 24 Feb 2018 17:50:25 -0500 Received: from agrajag.zerfleddert.de ([88.198.237.222]:33290 "EHLO agrajag.zerfleddert.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751500AbeBXWuW (ORCPT ); Sat, 24 Feb 2018 17:50:22 -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-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 Reviewed-by: Nicholas Mc Guire --- 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) {