From patchwork Tue Jun 14 15:07:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 70039 Delivered-To: patches@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2098858qgf; Tue, 14 Jun 2016 08:08:20 -0700 (PDT) X-Received: by 10.25.215.20 with SMTP id o20mr1603431lfg.18.1465916879616; Tue, 14 Jun 2016 08:07:59 -0700 (PDT) Return-Path: Received: from mail-lf0-x233.google.com (mail-lf0-x233.google.com. [2a00:1450:4010:c07::233]) by mx.google.com with ESMTPS id k1si11873833lbc.204.2016.06.14.08.07.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jun 2016 08:07:59 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::233 as permitted sender) client-ip=2a00:1450:4010:c07::233; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::233 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x233.google.com with SMTP id f6so85415649lfg.0 for ; Tue, 14 Jun 2016 08:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TqeR5sZLAHbDJRwBqfHigXp7pL9CuladLjbMwjT/Ra0=; b=fSATw/eNZGvGMdeQfyBLErsvTDxtepn/N4JlGm8mN04LOuCTljil2S2f2j8ae5HmPX XqZcnbQMpYhxEemfxsE/zO0sB/nw1N0l4niMzBlUziwnhPjF3LZ1HNqsfBm8t9qAHXFq /jBUFaE9NHSSsOVVwf8ZAeJ7HQiJw6HHonKLk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TqeR5sZLAHbDJRwBqfHigXp7pL9CuladLjbMwjT/Ra0=; b=mK392lAf4h2up79UszINvCHAF0cvq/rn8bxtm4SI0Y55YyaiZKMv9txUB91DuddSMb ZGIkBfQDEdUTCWEdX4PKudQcnFpKjUTb4nQRiWCZf/Lbsdh2ooisrFDu6zQHDTQLFRvn vMSopExtWUm4/E8TuJWn/DOxU8a5akYcnjG163wzHEYmzfo8pE2Gp41A/dwOrn5CLZxk 95feITFU2TtTiqntmNhUNOrFuorUuGt+PmGlpseXrCrC+sSigh/8fWvITHyF2Ioj1vQ5 R61G/TaePk65CwVQ+bl/gNlkbF5FwOxRIebqahyH4pSDYd9kglRyfVpF6xpruBqWTNUZ ZmBQ== X-Gm-Message-State: ALyK8tLakR4k/1tyljFnkmrV639npMwaCg4wqhaa6U8cYkKTx0Pv87NKwey5gbk6+Jydrc/NjSk= X-Received: by 10.25.213.200 with SMTP id m191mr1772757lfg.52.1465916877202; Tue, 14 Jun 2016 08:07:57 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-128-67.na.cust.bahnhof.se. [155.4.128.67]) by smtp.gmail.com with ESMTPSA id f195sm3477060lfb.47.2016.06.14.08.07.55 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Jun 2016 08:07:55 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , linux-i2c@vger.kernel.org Cc: Jarkko Nikula , Andy Shevchenko , Mika Westerberg , John Stultz , Guodong Xu , linux-arm-kernel@lists.infradead.org, Ulf Hansson Subject: [PATCH 08/10] i2c: designware-platdrv: Check return value from clk_prepare_enable() Date: Tue, 14 Jun 2016 17:07:26 +0200 Message-Id: <1465916848-8207-9-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465916848-8207-1-git-send-email-ulf.hansson@linaro.org> References: <1465916848-8207-1-git-send-email-ulf.hansson@linaro.org> As clk_prepare_enable() can fail, let's not ignore the error in the ->runtime_resume() callback, but instead propagate it. This change decreases the callers of i2c_dw_plat_prepare_clk() down to one, which seems like a justification of removing it. Instead let's call clk_disable_unprepare() directly when needed. Signed-off-by: Ulf Hansson --- drivers/i2c/busses/i2c-designware-platdrv.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) -- 1.9.1 diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 95a9f4e..2b91af3 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -308,25 +308,15 @@ static void dw_i2c_plat_complete(struct device *dev) #endif #ifdef CONFIG_PM -static int i2c_dw_plat_prepare_clk(struct dw_i2c_dev *i_dev, bool prepare) -{ - if (IS_ERR(i_dev->clk)) - return PTR_ERR(i_dev->clk); - - if (prepare) - return clk_prepare_enable(i_dev->clk); - - clk_disable_unprepare(i_dev->clk); - return 0; -} - static int dw_i2c_plat_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); i2c_dw_disable(i_dev); - i2c_dw_plat_prepare_clk(i_dev, false); + + if (!IS_ERR(i_dev->clk)) + clk_disable_unprepare(i_dev->clk); return 0; } @@ -335,10 +325,15 @@ static int dw_i2c_plat_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); + int ret; - i2c_dw_plat_prepare_clk(i_dev, true); - i2c_dw_init(i_dev); + if (!IS_ERR(i_dev->clk)) { + ret = clk_prepare_enable(i_dev->clk); + if (ret) + return ret; + } + i2c_dw_init(i_dev); return 0; }