From patchwork Mon Nov 21 14:59:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Liu X-Patchwork-Id: 83240 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1573541qge; Mon, 21 Nov 2016 06:59:57 -0800 (PST) X-Received: by 10.13.202.13 with SMTP id m13mr13752755ywd.251.1479740397630; Mon, 21 Nov 2016 06:59:57 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 124si4853932ybz.239.2016.11.21.06.59.57; Mon, 21 Nov 2016 06:59:57 -0800 (PST) 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; 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; dmarc=fail (p=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754542AbcKUO7x (ORCPT + 4 others); Mon, 21 Nov 2016 09:59:53 -0500 Received: from fllnx210.ext.ti.com ([198.47.19.17]:41593 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754031AbcKUO7v (ORCPT ); Mon, 21 Nov 2016 09:59:51 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id uALExoLL019252; Mon, 21 Nov 2016 08:59:50 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id uALExos2020134; Mon, 21 Nov 2016 08:59:50 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Mon, 21 Nov 2016 08:59:50 -0600 Received: from dbdmail01.india.ti.com (dbdmail01.india.ti.com [172.24.162.206]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id uALExn5h028202; Mon, 21 Nov 2016 08:59:50 -0600 Received: from uda0271908.am.dhcp.ti.com (uda0271908.am.dhcp.ti.com [128.247.83.228]) by dbdmail01.india.ti.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id uALExW7S009732; Mon, 21 Nov 2016 20:29:48 +0530 From: Bin Liu To: Greg KH CC: Subject: [PATCH 10/11] usb: musb: da8xx: Call earlier clk_prepare_enable() Date: Mon, 21 Nov 2016 08:59:30 -0600 Message-ID: <1479740371-24405-11-git-send-email-b-liu@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1479740371-24405-1-git-send-email-b-liu@ti.com> References: <1479740371-24405-1-git-send-email-b-liu@ti.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Alexandre Bailon 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 Signed-off-by: Bin Liu --- drivers/usb/musb/da8xx.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) -- 1.9.1 -- 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 f205a0381fcc..373b61786fe0 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -369,6 +369,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) @@ -380,12 +386,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 */ @@ -395,7 +395,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); @@ -415,9 +415,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; }