From patchwork Wed Oct 26 10:58:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 79395 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp341501qge; Wed, 26 Oct 2016 03:58:50 -0700 (PDT) X-Received: by 10.98.87.79 with SMTP id l76mr3074567pfb.174.1477479530373; Wed, 26 Oct 2016 03:58:50 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r133si1943828pgr.239.2016.10.26.03.58.50; Wed, 26 Oct 2016 03:58:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754812AbcJZK6j (ORCPT + 4 others); Wed, 26 Oct 2016 06:58:39 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:36225 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754013AbcJZK6f (ORCPT ); Wed, 26 Oct 2016 06:58:35 -0400 Received: by mail-wm0-f46.google.com with SMTP id b80so217587501wme.1 for ; Wed, 26 Oct 2016 03:58:34 -0700 (PDT) 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=0rt5ptZqBEHrkMiBf374pai7VKaOzXWnlK2r/Lyekjk=; b=VEXbbujFBT4Ji6vELgKQP0aqtTWrylblcFXvkar8mDZ3belzzvEYlmdPS9WBAlyMAj 5ow+nbtaFItTPtjoJ1plM28bMLioKlPc4jEkpj3Ngo1rAG5/QmUDS8Q4A6WwT5DKp3Ig XYrkTTSI7ZVnnEQ2CHgO1sww9hv+DpSYw2HbsFILHUXVENaoRx92aKE9C/WPqZ9VHKyy ubfpxjr/VmFEdvgbA2PgtBGZl8bvUzzHafR/pZml3N29rzNu6yOOJUrgyprXxvBr8OWV D+WMYPw1x7GNfaTHRrED2FUuuO3Xv9gHS1ffv2P7yVXBMWrzgKPmCLJHR740z8SVqXKi rojg== 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=0rt5ptZqBEHrkMiBf374pai7VKaOzXWnlK2r/Lyekjk=; b=eWZ2hRdwAP3RG0L2xHrNJ+Xsum3/Vvpp1dyCqYA9VSg681jaSboOFbrBFx2lcBe8uv U3GRM99wTokPgHHQ2NGYIRwLspsrr/EayLnq0aOCn3Ln+7bAYLjRf6e5nlT7RDRLSj3d 353LUo2vS9O7+nyiFo+U9H0dr5VHuC3BrfaR3momusyLUEDdpMpu4TLfZEjr5okc3XB2 uvqnVGeoq2/aHJ45e5oukKnKN4NZwhwGqQbi+esoVOe1Kwkz1X8zqQv4otScMNYmsV8Z zVUDWlN48vc9Djsvw0/q1EmjOpWr/sFFCPZcjtlctl5d/5P7zS5uPeegz+Guqr43YqAH ekEg== X-Gm-Message-State: ABUngvfTuK66GhD6d2E8HgEzu6czou/j09EWAt7JUvhc6bRwzQDf+mCVlR957lzSKmmK3qID X-Received: by 10.28.39.67 with SMTP id n64mr8057415wmn.68.1477479511067; Wed, 26 Oct 2016 03:58:31 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id yo1sm1972572wjc.16.2016.10.26.03.58.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Oct 2016 03:58:30 -0700 (PDT) From: Alexandre Bailon To: khilman@baylibre.com, david@lechnology.com, b-liu@ti.com, balbi@kernel.org Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Alexandre Bailon Subject: [PATCH v2 1/3] usb: musb: da8xx: Call earlier clk_prepare_enable() Date: Wed, 26 Oct 2016 12:58:21 +0200 Message-Id: <1477479503-5131-2-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1477479503-5131-1-git-send-email-abailon@baylibre.com> References: <1477479503-5131-1-git-send-email-abailon@baylibre.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 210b7e4..6749aa1 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; }