From patchwork Thu Nov 3 15:26:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 80680 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp692010qge; Thu, 3 Nov 2016 08:26:16 -0700 (PDT) X-Received: by 10.98.150.79 with SMTP id c76mr17703774pfe.154.1478186776930; Thu, 03 Nov 2016 08:26:16 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m63si10210024pgm.88.2016.11.03.08.26.16; Thu, 03 Nov 2016 08:26:16 -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 S1758054AbcKCP0O (ORCPT + 4 others); Thu, 3 Nov 2016 11:26:14 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:37484 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758032AbcKCP0M (ORCPT ); Thu, 3 Nov 2016 11:26:12 -0400 Received: by mail-wm0-f42.google.com with SMTP id t79so107950962wmt.0 for ; Thu, 03 Nov 2016 08:26:12 -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=ldzfLSMvG9yHUvOjF1iIHPbqC4HsC/82okejUbOfEwjXYatJJiNoVV0R4Wbnv9AiLU HegbXwlVygniyGxCRAetaWPi6Eg5cf2cjWyZxCx3n0TDVacUkNAt+Bz52xt5cbLepEaT LnChTs3FHK7coStWGvCNXEJWOs7vvPO8i0VJjF37CoXuxuUC7VItFmopxhUNWmqnpA3u xcwS3nI1YjQaBFZ+iZDUJIQ5muw8UqeLO/wrsbKmIuzTauB5xwKOMYBNZ2T4RcBvssXd AZprczE8N2ocpKjJ7ojfnPbSX5dMVDWywZkZ5TyV+qP9TWgCLIhMCXe4FfAdpQj1NDQu 6JKA== 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=mOMlmA2jiDDw8QMWeLDZ7gwqPmfWpjwnoHqXSIXHALvtipGfKUj8XgV9d5bP7s21o0 vryc5JKEiquCbV1UyON5Bksel0myFfuwuktmuBUeLmNimlp4PKN7EY/iae4XrKpyY4lZ +cATPG8mb885q4SNJ5n849wHXvl188QbWUXh1HNGWZjVrKtxgtvL28L8XyEQy1bJWvgD 00f9wFrWBseY1qVDbkKlCe8gZp/789WSoDv4or+8Gqmt7U+iZlAMGXkMnX9Yysiug28c K66EASwpxASqEg1VGSXKRFtUSkCIa5o3aknS6RTiCPjTavh4nEUZf/3FAr3kgbAOgaeA Lidg== X-Gm-Message-State: ABUngvfDK6qJYLGpjrc5a/lWWFt5/kuXgb/1V7bmaV3K29qE1tyP92K7Ac3a0nUEJeq5Wk25 X-Received: by 10.28.35.14 with SMTP id j14mr2544377wmj.24.1478186770957; Thu, 03 Nov 2016 08:26:10 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id wh3sm9108948wjb.49.2016.11.03.08.26.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Nov 2016 08:26:10 -0700 (PDT) From: Alexandre Bailon To: david@lechnology.com, b-liu@ti.com, balbi@kernel.org Cc: kishon@ti.com, khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, nsekhar@ti.com, Alexandre Bailon Subject: [PATCH v3 1/5] usb: musb: da8xx: Call earlier clk_prepare_enable() Date: Thu, 3 Nov 2016 16:26:01 +0100 Message-Id: <1478186765-19840-2-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1478186765-19840-1-git-send-email-abailon@baylibre.com> References: <1478186765-19840-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; }