From patchwork Mon Jun 29 09:06:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 32914 X-Patchwork-Delegate: me@felipebalbi.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5T98wUL030800 for ; Mon, 29 Jun 2009 09:08:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751915AbZF2JIx (ORCPT ); Mon, 29 Jun 2009 05:08:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751828AbZF2JIx (ORCPT ); Mon, 29 Jun 2009 05:08:53 -0400 Received: from smtp.nokia.com ([192.100.122.230]:28685 "EHLO mgw-mx03.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751307AbZF2JIw (ORCPT ); Mon, 29 Jun 2009 05:08:52 -0400 Received: from esebh105.NOE.Nokia.com (esebh105.ntc.nokia.com [172.21.138.211]) by mgw-mx03.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n5T98kDk002865; Mon, 29 Jun 2009 12:08:49 +0300 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 29 Jun 2009 12:07:17 +0300 Received: from mgw-sa02.ext.nokia.com ([147.243.1.48]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 29 Jun 2009 12:07:16 +0300 Received: from localhost.localdomain (esdhcp036212.research.nokia.com [172.21.36.212]) by mgw-sa02.ext.nokia.com (Switch-3.2.6/Switch-3.2.6) with ESMTP id n5T97FYb001260; Mon, 29 Jun 2009 12:07:15 +0300 From: Roger Quadros To: felipe.balbi@nokia.com Cc: linux-usb@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v2] usb: musb: Warn and check for OTG transceiver misconfiguration Date: Mon, 29 Jun 2009 12:06:48 +0300 Message-Id: <1246266408-1467-1-git-send-email-ext-roger.quadros@nokia.com> X-Mailer: git-send-email 1.6.0.4 X-OriginalArrivalTime: 29 Jun 2009 09:07:16.0553 (UTC) FILETIME=[FFB4DB90:01C9F898] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Warn if OTG is selected in Kconfig but not initialized by platform code. Add checks to prevent NULL pointer exception in case the OTG transceiver has not been initialized. i.e. musb->xceiv == NULL Signed-off-by: Roger Quadros Tested-by: Paul Walmsley --- drivers/usb/musb/musb_core.c | 7 ++++++- drivers/usb/musb/omap2430.c | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 554a414..d0cfc22 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1861,7 +1861,8 @@ static void musb_free(struct musb *musb) } #ifdef CONFIG_USB_MUSB_OTG - put_device(musb->xceiv->dev); + if (musb->xceiv) + put_device(musb->xceiv->dev); #endif #ifdef CONFIG_USB_MUSB_HDRC_HCD @@ -1958,6 +1959,10 @@ bad_config: musb->isr = generic_interrupt; status = musb_platform_init(musb); +#ifdef CONFIG_USB_MUSB_OTG + if (!musb->xceiv) + WARN(1, "MUSB: OTG transceiver not set up correctly\n"); +#endif if (status < 0) goto fail; if (!musb->isr) { diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 3487520..8987d60 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -271,7 +271,8 @@ int musb_platform_suspend(struct musb *musb) l |= ENABLEWAKEUP; /* enable wakeup */ omap_writel(l, OTG_SYSCONFIG); - otg_set_suspend(musb->xceiv, 1); + if (musb->xceiv) + otg_set_suspend(musb->xceiv, 1); if (musb->set_clock) musb->set_clock(musb->clock, 0);