diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2015-01-21 00:56:05 +0200 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-01-27 09:39:51 -0600 |
commit | d21daf1e90514cee8e3fb11c8e28acee3fb87edf (patch) | |
tree | a44d5731b4bf452d65a5710d9f87e97945ce2573 /drivers | |
parent | 1f8d9b9b503070e5450f49e0a341ac3b43d9164d (diff) | |
download | op-kernel-dev-d21daf1e90514cee8e3fb11c8e28acee3fb87edf.zip op-kernel-dev-d21daf1e90514cee8e3fb11c8e28acee3fb87edf.tar.gz |
usb: isp1760: Fix USB disabled check
The isp1760 driver registration function returns an error if USB is
disabled. This made sense when the driver only supported host
controllers, but now that it supports peripheral controllers host
support isn't mandatory anymore.
Fix this by returning an error only when both the HCD and UDC functions
are disabled, either through the kernel configuration or at runtime.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/isp1760/isp1760-core.c | 24 | ||||
-rw-r--r-- | drivers/usb/isp1760/isp1760-hcd.c | 3 | ||||
-rw-r--r-- | drivers/usb/isp1760/isp1760-udc.c | 3 |
3 files changed, 21 insertions, 9 deletions
diff --git a/drivers/usb/isp1760/isp1760-core.c b/drivers/usb/isp1760/isp1760-core.c index 727e90a..b982755 100644 --- a/drivers/usb/isp1760/isp1760-core.c +++ b/drivers/usb/isp1760/isp1760-core.c @@ -112,9 +112,15 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, struct device *dev, unsigned int devflags) { struct isp1760_device *isp; + bool udc_disabled = !(devflags & ISP1760_FLAG_ISP1761); int ret; - if (usb_disabled()) + /* + * If neither the HCD not the UDC is enabled return an error, as no + * device would be registered. + */ + if ((!IS_ENABLED(CONFIG_USB_ISP1760_HCD) || usb_disabled()) && + (!IS_ENABLED(CONFIG_USB_ISP1761_UDC) || udc_disabled)) return -ENODEV; /* prevent usb-core allocating DMA pages */ @@ -137,12 +143,14 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, isp1760_init_core(isp); - ret = isp1760_hcd_register(&isp->hcd, isp->regs, mem, irq, - irqflags | IRQF_SHARED, dev); - if (ret < 0) - return ret; + if (IS_ENABLED(CONFIG_USB_ISP1760_HCD) && !usb_disabled()) { + ret = isp1760_hcd_register(&isp->hcd, isp->regs, mem, irq, + irqflags | IRQF_SHARED, dev); + if (ret < 0) + return ret; + } - if (devflags & ISP1760_FLAG_ISP1761) { + if (IS_ENABLED(CONFIG_USB_ISP1761_UDC) && !udc_disabled) { ret = isp1760_udc_register(isp, irq, irqflags | IRQF_SHARED | IRQF_DISABLED); if (ret < 0) { @@ -160,9 +168,7 @@ void isp1760_unregister(struct device *dev) { struct isp1760_device *isp = dev_get_drvdata(dev); - if (isp->devflags & ISP1760_FLAG_ISP1761) - isp1760_udc_unregister(isp); - + isp1760_udc_unregister(isp); isp1760_hcd_unregister(&isp->hcd); } diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c index 568446c..996b2c1 100644 --- a/drivers/usb/isp1760/isp1760-hcd.c +++ b/drivers/usb/isp1760/isp1760-hcd.c @@ -2226,6 +2226,9 @@ error: void isp1760_hcd_unregister(struct isp1760_hcd *priv) { + if (!priv->hcd) + return; + usb_remove_hcd(priv->hcd); usb_put_hcd(priv->hcd); } diff --git a/drivers/usb/isp1760/isp1760-udc.c b/drivers/usb/isp1760/isp1760-udc.c index 6bfda30..9612d79 100644 --- a/drivers/usb/isp1760/isp1760-udc.c +++ b/drivers/usb/isp1760/isp1760-udc.c @@ -1488,6 +1488,9 @@ void isp1760_udc_unregister(struct isp1760_device *isp) { struct isp1760_udc *udc = &isp->udc; + if (!udc->isp) + return; + usb_del_gadget_udc(&udc->gadget); free_irq(udc->irq, udc); |