From patchwork Tue Nov 15 17:42:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 82376 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1650454qge; Tue, 15 Nov 2016 09:43:05 -0800 (PST) X-Received: by 10.36.133.136 with SMTP id r130mr4224589itd.25.1479231785046; Tue, 15 Nov 2016 09:43:05 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4si2676106itg.90.2016.11.15.09.43.04; Tue, 15 Nov 2016 09:43:05 -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; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.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 S933905AbcKORm7 (ORCPT + 26 others); Tue, 15 Nov 2016 12:42:59 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:34902 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933552AbcKORmx (ORCPT ); Tue, 15 Nov 2016 12:42:53 -0500 Received: by mail-wm0-f49.google.com with SMTP id a197so181906793wmd.0 for ; Tue, 15 Nov 2016 09:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yk7DxrLnMQ7vNBw5hf6wHKXFXZiRmAGJd7nLZHfp+98=; b=IKlisonpd6Kf9HCHxVdfH6zjC3pE5XVmSlDE5kHhok5jBco803s6XQ2cNMjGXGChbE lKEjBGelvQ/nCKbLvpeMPBAQL4/ZNjUjR5aDQRYAU3lH+7NKLy6XqPzf42Hti4YLF49c JklFLAsWoegzQO/OtX4XUwQb+b1bYdGUQ9V/IoT5qtNx/DNl+CLixi4AcJkPkgvRvLsL sRQ6cwlhAFUuSdCdHKDMzs4fkQ8pu4QlwXVTg/arL76voIWNKd2oqksXcM09spze+hKx sUOWXRETkWKFxfEmrsjHOAdwGCf4rolrRH2Li7IJpBt+NmseubUdSvC83SA0OeRFHo5G b4fg== 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=yk7DxrLnMQ7vNBw5hf6wHKXFXZiRmAGJd7nLZHfp+98=; b=OTWii2sWy+bcGT2JQRv9gOgQfKgdLt9hVlz9iSWHEq0lEdHpaxQ6VV8Tqob/6HEj4G pi060R4QH6UU0wlH/QoO61OrUC+xyVZTBSoBybd2uTvd+R41JeExNgTEtKKc5ZnXL6KI sbSgbZbIUC1OKmt4UC1O8tv22WFanrebhG6l3J5nkkiUHTQnvVaGVY8L4kRudbZ6JGv6 jWKwscNctt6uivi4xoEQJxb0t5/gB9S0UPgBxOcFU1Bh6QlEiXZEzMUCQ/Eqm4jY0h4K yiJ99HIF08JSOeX2nYuDR/ewv9mGmsNfNuwIp3L9pRSX1rgnGx5gOrgJf8Xzdi/Jd8At H//Q== X-Gm-Message-State: ABUngvf8h8Ow22Ifso3nL+Nkdo7HZ3R7f3qk9hQR/m/25VAKEDw7to9egtuTaqGxcB05ORZ2 X-Received: by 10.194.107.97 with SMTP id hb1mr24459970wjb.134.1479231772089; Tue, 15 Nov 2016 09:42:52 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id bj1sm35836295wjc.17.2016.11.15.09.42.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Nov 2016 09:42:51 -0800 (PST) From: Alexandre Bailon To: david@lechnology.com, b-liu@ti.com, balbi@kernel.org Cc: khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, nsekhar@ti.com, Alexandre Bailon Subject: [PATCH v6 1/2] usb: musb: da8xx: Call earlier clk_prepare_enable() Date: Tue, 15 Nov 2016 18:42:46 +0100 Message-Id: <1479231767-2434-2-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1479231767-2434-1-git-send-email-abailon@baylibre.com> References: <1479231767-2434-1-git-send-email-abailon@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The first attempt to read a register may fail because the clock may not be enabled, and then the probe of musb driver will fail. Call clk_prepare_enable() before the first register read. Signed-off-by: Alexandre Bailon --- drivers/usb/musb/da8xx.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) -- 2.7.3 diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 2440f88..4fc226c 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -366,6 +366,12 @@ static int da8xx_musb_init(struct musb *musb) musb->mregs += DA8XX_MENTOR_CORE_OFFSET; + ret = clk_prepare_enable(glue->clk); + if (ret) { + dev_err(glue->dev, "failed to enable clock\n"); + return ret; + } + /* Returns zero if e.g. not clocked */ rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG); if (!rev) @@ -377,12 +383,6 @@ static int da8xx_musb_init(struct musb *musb) goto fail; } - ret = clk_prepare_enable(glue->clk); - if (ret) { - dev_err(glue->dev, "failed to enable clock\n"); - goto fail; - } - setup_timer(&otg_workaround, otg_timer, (unsigned long)musb); /* Reset the controller */ @@ -392,7 +392,7 @@ static int da8xx_musb_init(struct musb *musb) ret = phy_init(glue->phy); if (ret) { dev_err(glue->dev, "Failed to init phy.\n"); - goto err_phy_init; + goto fail; } ret = phy_power_on(glue->phy); @@ -412,9 +412,8 @@ static int da8xx_musb_init(struct musb *musb) err_phy_power_on: phy_exit(glue->phy); -err_phy_init: - clk_disable_unprepare(glue->clk); fail: + clk_disable_unprepare(glue->clk); return ret; }