From patchwork Fri Nov 4 16:43:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 80895 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp71810qge; Fri, 4 Nov 2016 09:44:41 -0700 (PDT) X-Received: by 10.99.42.80 with SMTP id q77mr23478313pgq.3.1478277881785; Fri, 04 Nov 2016 09:44:41 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y3si17475952pfa.215.2016.11.04.09.44.41; Fri, 04 Nov 2016 09:44:41 -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 S965068AbcKDQoj (ORCPT + 4 others); Fri, 4 Nov 2016 12:44:39 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:36371 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932291AbcKDQno (ORCPT ); Fri, 4 Nov 2016 12:43:44 -0400 Received: by mail-wm0-f45.google.com with SMTP id p190so62705432wmp.1 for ; Fri, 04 Nov 2016 09:43:44 -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=cA1oe24cAKl8ZS7raueN7Orl++X8nkWVBlZmXhjMzIR9fqdPq0qCWW0psuCqE3cStR lQnVWel73/TEV2pCcGhG/LdswIvF52UIl3QWpexeLBTAYn+veWa2EmPInkQfmrpuvInp GsymKRRT58fkhv4o22QUii8rJaQZB0jeDw6P6Yf/gghqk5rzjNsUwqp3ZmI2SqlT8Nmg 7ZUn+cujB8iW1nxEm6iSutG2g+Wgc/qIvchkc5qm7TTsomv5rG/3o+rS7JY/vZSHsEjM 81pHnsGfB5QFmvjX5fgjBUsz7cWYot2GR1o1+CZ1oYBTvMHQjxBVSYHe2MFJTMszlnN/ G4tQ== 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=grSP0bVaIYjyY2bhNdc+9W/yxflX7j1IZWnPx5gvLF3m7kfMUtKmfvQURdjm/ySsIN sv1zhB9jJCx+u6+S5n+k8I/Og/CTHO+fyK0+FDKgcJLeCaIhu6yPUfmZre+lNHvewuW5 cI1FqzlSFdLe1wERXyO6cqjtwEnoDDBnIw9kSpKMLiHyVz4LACppk85buT02V5Oj+gRM 9vgwZSCxt/hF0YrcMZQ1YScgkMEoGSf+Rc2ZthzWPHIBRAC5PK3eMziNe5R0HFeEp/LQ Kks4eIu9eo8mnErTPeZkD/i4IvAeMOopRjFIOThn1y+4R3H3/0ppuqaY1fyxuABdM5/o q6Cw== X-Gm-Message-State: ABUngvf3DupLk1vkcH5o+qh4XC3lkal3Qz1U8HDaEHg5P0WPnIIP18JZxrcltexsLr5jNzeX X-Received: by 10.28.91.141 with SMTP id p135mr4103729wmb.128.1478277823311; Fri, 04 Nov 2016 09:43:43 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id af4sm15148128wjc.17.2016.11.04.09.43.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Nov 2016 09:43:42 -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 v4 1/4] usb: musb: da8xx: Call earlier clk_prepare_enable() Date: Fri, 4 Nov 2016 17:43:35 +0100 Message-Id: <1478277818-5091-2-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1478277818-5091-1-git-send-email-abailon@baylibre.com> References: <1478277818-5091-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; }