From patchwork Fri Jul 29 17:42:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 9252751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 357D86077C for ; Fri, 29 Jul 2016 18:14:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 281FA27DC2 for ; Fri, 29 Jul 2016 18:14:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B2A3283FD; Fri, 29 Jul 2016 18:14:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B977027DC2 for ; Fri, 29 Jul 2016 18:14:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753485AbcG2SO2 (ORCPT ); Fri, 29 Jul 2016 14:14:28 -0400 Received: from glaubenleben.de ([85.214.105.140]:45809 "EHLO glaubenleben.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751695AbcG2SO1 (ORCPT ); Fri, 29 Jul 2016 14:14:27 -0400 X-Greylist: delayed 1876 seconds by postgrey-1.27 at vger.kernel.org; Fri, 29 Jul 2016 14:14:26 EDT Received: from p4fcbd551.dip0.t-ipconnect.de ([79.203.213.81] helo=localhost.localdomain) by glaubenleben.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bTBoQ-0000vA-H1; Fri, 29 Jul 2016 19:43:06 +0200 From: Andreas Kemnade To: Bin Liu , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, letux-kernel@openphoenux.org Cc: Andreas Kemnade Subject: [PATCH] musb: omap2430: do not assume balanced enable()/disable() Date: Fri, 29 Jul 2016 19:42:31 +0200 Message-Id: <1469814151-2571-1-git-send-email-andreas@kemnade.info> X-Mailer: git-send-email 2.1.4 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The code assumes that omap2430_musb_enable() and omap2430_musb_disable() is called in a balanced way. The That fact is broken by the fact that musb_init_controller() calls musb_platform_disable() to switch from unknown state to off state. That means that phy_power_off() is called first so that phy->power_count gets -1 and the phy is not enabled on phy_power_on(). In the probably common case of using the phy_twl4030, that prevents also charging the battery and so makes further kernel debugging hard. The patch prevents phy_power_off() from being called when it is already off. Signed-off-by: Andreas Kemnade --- drivers/usb/musb/omap2430.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index aecb934..c7ae117 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -415,9 +415,10 @@ static void omap2430_musb_disable(struct musb *musb) struct device *dev = musb->controller; struct omap2430_glue *glue = dev_get_drvdata(dev->parent); - if (!WARN_ON(!musb->phy)) - phy_power_off(musb->phy); - + if (glue->enabled) { + if (!WARN_ON(!musb->phy)) + phy_power_off(musb->phy); + } if (glue->status != MUSB_UNKNOWN) omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DISCONNECT);