Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758829AbcDFGah (ORCPT ); Wed, 6 Apr 2016 02:30:37 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:57803 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752763AbcDFGaf (ORCPT ); Wed, 6 Apr 2016 02:30:35 -0400 Subject: Re: [PATCH v6 12/12] usb: host: xhci-plat: Add otg device to platform data To: Yoshihiro Shimoda , "stern@rowland.harvard.edu" , "balbi@kernel.org" , "gregkh@linuxfoundation.org" , "peter.chen@freescale.com" References: <1459865117-7032-1-git-send-email-rogerq@ti.com> <1459865117-7032-13-git-send-email-rogerq@ti.com> CC: "dan.j.williams@intel.com" , "jun.li@freescale.com" , "mathias.nyman@linux.intel.com" , "tony@atomide.com" , "Joao.Pinto@synopsys.com" , "abrestic@chromium.org" , "r.baldyga@samsung.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-omap@vger.kernel.org" From: Roger Quadros Message-ID: <5704ACF2.6020201@ti.com> Date: Wed, 6 Apr 2016 09:30:10 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3694 Lines: 140 Hi, On 06/04/16 06:23, Yoshihiro Shimoda wrote: > Hi, > >> Sent: Tuesday, April 05, 2016 11:05 PM >> >> Host controllers that are part of an OTG/dual-role instance >> need to somehow pass the OTG controller device information >> to the HCD core. >> >> We use platform data to pass the OTG controller device. >> >> Signed-off-by: Roger Quadros >> --- >> drivers/usb/host/xhci-plat.c | 35 ++++++++++++++++++++++++++++------- >> include/linux/usb/xhci_pdriver.h | 3 +++ >> 2 files changed, 31 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c >> index 5c15e9b..3d0f597 100644 >> --- a/drivers/usb/host/xhci-plat.c >> +++ b/drivers/usb/host/xhci-plat.c >> @@ -230,11 +230,20 @@ static int xhci_plat_probe(struct platform_device *pdev) >> goto put_usb3_hcd; >> } >> >> - ret = usb_add_hcd(hcd, irq, IRQF_SHARED); >> + if (pdata->otg_dev) > > I think that this should be changed like below: > if (pdata && pdata->otg_dev) Indeed, I'll fix this and the remaining occurrences. Thanks. cheers, -roger > > Otherwise, panic happened on my environment (arm64 / r8a7795 board) because the pdata was NULL. > >> + ret = usb_otg_add_hcd(hcd, irq, IRQF_SHARED, pdata->otg_dev); >> + else >> + ret = usb_add_hcd(hcd, irq, IRQF_SHARED); >> + >> if (ret) >> goto disable_usb_phy; >> >> - ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); >> + if (pdata->otg_dev) > > Ditto. > >> + ret = usb_otg_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED, >> + pdata->otg_dev); >> + else >> + ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); >> + >> if (ret) >> goto dealloc_usb2_hcd; >> >> @@ -242,7 +251,10 @@ static int xhci_plat_probe(struct platform_device *pdev) >> >> >> dealloc_usb2_hcd: >> - usb_remove_hcd(hcd); >> + if (pdata->otg_dev) > > Ditto. > >> + usb_otg_remove_hcd(hcd); >> + else >> + usb_remove_hcd(hcd); >> >> disable_usb_phy: >> usb_phy_shutdown(hcd->usb_phy); >> @@ -260,16 +272,25 @@ put_hcd: >> return ret; >> } >> >> -static int xhci_plat_remove(struct platform_device *dev) >> +static int xhci_plat_remove(struct platform_device *pdev) >> { >> - struct usb_hcd *hcd = platform_get_drvdata(dev); >> + struct usb_hcd *hcd = platform_get_drvdata(pdev); >> struct xhci_hcd *xhci = hcd_to_xhci(hcd); >> struct clk *clk = xhci->clk; >> + struct usb_xhci_pdata *pdata = dev_get_platdata(&pdev->dev); >> + >> + if (pdata->otg_dev) > > Ditto. > >> + usb_otg_remove_hcd(xhci->shared_hcd); >> + else >> + usb_remove_hcd(xhci->shared_hcd); >> >> - usb_remove_hcd(xhci->shared_hcd); >> usb_phy_shutdown(hcd->usb_phy); >> >> - usb_remove_hcd(hcd); >> + if (pdata->otg_dev) > > Ditto. > > Best regards, > Yoshihiro Shimoda > >> + usb_otg_remove_hcd(hcd); >> + else >> + usb_remove_hcd(hcd); >> + >> usb_put_hcd(xhci->shared_hcd); >> >> if (!IS_ERR(clk)) >> diff --git a/include/linux/usb/xhci_pdriver.h b/include/linux/usb/xhci_pdriver.h >> index 376654b..5c68b83 100644 >> --- a/include/linux/usb/xhci_pdriver.h >> +++ b/include/linux/usb/xhci_pdriver.h >> @@ -18,10 +18,13 @@ >> * >> * @usb3_lpm_capable: determines if this xhci platform supports USB3 >> * LPM capability >> + * @otg_dev: OTG controller device. Only requied if part of >> + * OTG/dual-role. >> * >> */ >> struct usb_xhci_pdata { >> unsigned usb3_lpm_capable:1; >> + struct device *otg_dev; >> }; >> >> #endif /* __USB_CORE_XHCI_PDRIVER_H */ >> -- >> 2.5.0 >> >> -- >> 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