From patchwork Tue Jun 14 15:07:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 635352 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rTY106DRkz9t1S for ; Wed, 15 Jun 2016 01:07:48 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=HmwYLaIm; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751190AbcFNPHs (ORCPT ); Tue, 14 Jun 2016 11:07:48 -0400 Received: from mail-lf0-f43.google.com ([209.85.215.43]:35853 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750968AbcFNPHr (ORCPT ); Tue, 14 Jun 2016 11:07:47 -0400 Received: by mail-lf0-f43.google.com with SMTP id q132so68628208lfe.3 for ; Tue, 14 Jun 2016 08:07:46 -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=RYAvsiti3xR0pwKBYdySV+Hi9RWKzge5wjhr+AmkPAc=; b=HmwYLaImR0VjBRIb7+rANwWaHXWMtXWixtbRadS5n2q3EbFv1+bTAwRSpzTPZmFsOG YfjyghPsaoPkM0MmU0KsmYAznMuvdVjn6aNXlt04SMI1/pT3oGIjTzVKTI0kTRaPUagn K6iBHklZqIRjqKKxlHfugSz+iHp8EjcleKGUU= 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=RYAvsiti3xR0pwKBYdySV+Hi9RWKzge5wjhr+AmkPAc=; b=Wklm5m3Zn+i6HfR6lu41oVqeaGHQTEFvEXbO+xYbskit3fdd3rYBBNNfqDLVP9d9rY MEKzUoq11HAG2UJiJKdoVLCHDwZ+9W8BKMNqu8Y9hYEOe0/2+phydqk8Ps+s9qtpgTk0 vQ2FQ0lck+cy6FboiYLMY6aZYdmspDaO2JmLupt5eIxiJq4TiLnGKjU1JNbiAE7gjiMV 7COaBUyuVtf2wO+vlXckQqd+EuC/rMgfZc5arytCUqOe30XfDFdBDZHkx1HnbK+lHfuF S6a3Wo2WWl0SuSn3SneZlev4KMKZ9ZOVt5LkesyxuvZrfwa78enEc8tP+Y1y4+dMjenF C2zA== X-Gm-Message-State: ALyK8tI5jn7MGcJUeDTrPKKpcRe65q/cr+VlMiaNCKNSJZ7mUTnpaqf6BdxJytE2s0MVjoHR X-Received: by 10.25.24.163 with SMTP id 35mr1707545lfy.103.1465916865477; Tue, 14 Jun 2016 08:07:45 -0700 (PDT) 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.43 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Jun 2016 08:07:43 -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 01/10] i2c: designware-platdrv: Return error in ->probe() when clk ungate fails Date: Tue, 14 Jun 2016 17:07:19 +0200 Message-Id: <1465916848-8207-2-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> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The error code received from clk_prepare_enable() becomes ignored when i2c_dw_plat_prepare_clk() is called in ->probe(). Fix this by invoking clk_prepare_enable() in ->probe() instead of i2c_dw_plat_prepare_clk(), as it allows the error code to be properly propagated. A side-effect from this change, makes the i2c_dw_plat_prepare_clk() used only when CONFIG_PM is set. Avoid the compiler warning by moving the function within the corresponding #ifdef. Signed-off-by: Ulf Hansson --- drivers/i2c/busses/i2c-designware-platdrv.c | 30 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index d656657..e39962b 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -136,18 +136,6 @@ static inline int dw_i2c_acpi_configure(struct platform_device *pdev) } #endif -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_probe(struct platform_device *pdev) { struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev); @@ -220,7 +208,11 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST; dev->clk = devm_clk_get(&pdev->dev, NULL); - if (!i2c_dw_plat_prepare_clk(dev, true)) { + if (!IS_ERR(dev->clk)) { + r = clk_prepare_enable(dev->clk); + if (r) + return r; + dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz; if (!dev->sda_hold_time && ht) @@ -302,6 +294,18 @@ 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);