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: 70032 Delivered-To: patches@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2098505qgf; Tue, 14 Jun 2016 08:07:47 -0700 (PDT) X-Received: by 10.25.141.204 with SMTP id p195mr1671466lfd.8.1465916866000; Tue, 14 Jun 2016 08:07:46 -0700 (PDT) Return-Path: Received: from mail-lf0-x22b.google.com (mail-lf0-x22b.google.com. [2a00:1450:4010:c07::22b]) by mx.google.com with ESMTPS id s5si14660666lfs.188.2016.06.14.08.07.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jun 2016 08:07:45 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) client-ip=2a00:1450:4010:c07::22b; 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::22b as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22b.google.com with SMTP id q132so68628195lfe.3 for ; Tue, 14 Jun 2016 08:07:45 -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=BIgJkh9WcMJXfwfvmS1fzEJLzeGiyS+8vd/bi2tgKpxmIneuqIzF+b//M22Cl000KV qQS6B3eSF533VmCcrVzVBGB74pkUuNBDvmagFrHesI9twb02875smHbDz40AoCsdZ5wT W8CPCq4/K/4dQnf4NxdKajI5rhsgZpu1qWuY6Sa5csRScWTPRQKcHWPMKNN8sQo7rPUx iT+ghHiMLNoiEpMn0gBffNpntQxx59UhQd4j61F+FXRPjBQSF5nRLcGxOEruLLl7nYxS 3xCFTkF5GBxNuBTP2FqJrARG/hvgMwIYIgHCiCls0RfAXQujwXOxk9M86h0byLpEvIhH EAAA== X-Gm-Message-State: ALyK8tI7j7KnQerehfRRJZTNjLYo4lPJ9j7IZ8hg0UU+OWJXtKLVHpt4hpvEvdVezdWW8muxMHM= X-Received: by 10.25.24.163 with SMTP id 35mr1707545lfy.103.1465916865477; Tue, 14 Jun 2016 08:07:45 -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.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> 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(-) -- 1.9.1 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);