Re: [PATCH 3/8][v3]usb:fsl:otg: Add support to add/remove usb host driver

From: Alan Stern
Date: Thu Aug 13 2015 - 14:47:36 EST


On Thu, 13 Aug 2015, Ramneek Mehresh wrote:

> Add workqueue to add/remove host driver (outside
> interrupt context) upon each id change.
>
> Signed-off-by: Li Yang <leoli@xxxxxxxxxxxxx>
> Signed-off-by: Ramneek Mehresh <ramneek.mehresh@xxxxxxxxxxxxx>
> ---
> Changes for v3:
> - removed CONFIG_FSL_USB2_OTG and CONFIG_FSL_USB2_OTG_MODULE
> macros
> - removed call to usb_hcd_resume_root_hub(hcd) from
> ehci_fsl_drv_resume()
>
> drivers/usb/host/ehci-fsl.c | 71 ++++++++++++++++++++++++++++++++-------------
> drivers/usb/host/ehci-fsl.h | 18 ++++++++++++
> 2 files changed, 69 insertions(+), 20 deletions(-)


> static int ehci_fsl_drv_suspend(struct device *dev)
> {
> struct usb_hcd *hcd = dev_get_drvdata(dev);
> - struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
> void __iomem *non_ehci = hcd->regs;
> + struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
> + struct usb_bus host = hcd->self;

I just noticed this line. It does not look right at all; it does a
structure copy instead of copying a pointer.

>
> if (of_device_is_compatible(dev->parent->of_node,
> "fsl,mpc5121-usb2-dr")) {
> return ehci_fsl_mpc512x_drv_suspend(dev);
> }
>
> + if (host.is_otg) {
> + /* remove hcd */
> + ehci_fsl->hcd_add = 0;
> + schedule_work(&ehci_fsl->change_hcd_work);
> + host.is_otg = 0;

And here you turn off the flag in the local copy of the structure,
which accomplishes nothing.

> + return 0;
> + }
> +
> ehci_prepare_ports_for_controller_suspend(hcd_to_ehci(hcd),
> device_may_wakeup(dev));
> if (!fsl_deep_sleep())
> @@ -557,15 +579,24 @@ static int ehci_fsl_drv_suspend(struct device *dev)
> static int ehci_fsl_drv_resume(struct device *dev)
> {
> struct usb_hcd *hcd = dev_get_drvdata(dev);
> - struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
> struct ehci_hcd *ehci = hcd_to_ehci(hcd);
> void __iomem *non_ehci = hcd->regs;
> + struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
> + struct usb_bus host = hcd->self;

Same here.

> --- a/drivers/usb/host/ehci-fsl.h
> +++ b/drivers/usb/host/ehci-fsl.h
> @@ -63,4 +63,22 @@
> #define UTMI_PHY_EN (1<<9)
> #define ULPI_PHY_CLK_SEL (1<<10)
> #define PHY_CLK_VALID (1<<17)
> +
> +struct ehci_fsl {
> +#ifdef CONFIG_PM
> + /* Saved USB PHY settings, need to restore after deep sleep. */
> + u32 usb_ctrl;
> +#endif

Do you need this #ifdef?

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/