Commit ded017ee authored by Kishon Vijay Abraham I's avatar Kishon Vijay Abraham I Committed by Felipe Balbi

usb: phy: fix return value check of usb_get_phy

usb_get_phy will return -ENODEV if it's not able to find the phy. Hence
fixed all the callers of usb_get_phy to check for this error condition
instead of relying on a non-zero value as success condition.
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent b8a3efa3
...@@ -2689,7 +2689,7 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev) ...@@ -2689,7 +2689,7 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
} }
di->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2); di->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2);
if (!di->usb_phy) { if (IS_ERR_OR_NULL(di->usb_phy)) {
dev_err(di->dev, "failed to get usb transceiver\n"); dev_err(di->dev, "failed to get usb transceiver\n");
ret = -EINVAL; ret = -EINVAL;
goto free_usb; goto free_usb;
......
...@@ -416,7 +416,7 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) ...@@ -416,7 +416,7 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
isp->phy = usb_get_phy(USB_PHY_TYPE_USB2); isp->phy = usb_get_phy(USB_PHY_TYPE_USB2);
if (!isp->phy) if (IS_ERR_OR_NULL(isp->phy))
goto fail0; goto fail0;
isp->dev = &pdev->dev; isp->dev = &pdev->dev;
......
...@@ -322,11 +322,11 @@ static int pda_power_probe(struct platform_device *pdev) ...@@ -322,11 +322,11 @@ static int pda_power_probe(struct platform_device *pdev)
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
transceiver = usb_get_phy(USB_PHY_TYPE_USB2); transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
if (transceiver && !pdata->is_usb_online) { if (!IS_ERR_OR_NULL(transceiver)) {
pdata->is_usb_online = otg_is_usb_online; if (!pdata->is_usb_online)
} pdata->is_usb_online = otg_is_usb_online;
if (transceiver && !pdata->is_ac_online) { if (!pdata->is_ac_online)
pdata->is_ac_online = otg_is_ac_online; pdata->is_ac_online = otg_is_ac_online;
} }
#endif #endif
...@@ -373,7 +373,7 @@ static int pda_power_probe(struct platform_device *pdev) ...@@ -373,7 +373,7 @@ static int pda_power_probe(struct platform_device *pdev)
} }
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (transceiver && pdata->use_otg_notifier) { if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
otg_nb.notifier_call = otg_handle_notification; otg_nb.notifier_call = otg_handle_notification;
ret = usb_register_notifier(transceiver, &otg_nb); ret = usb_register_notifier(transceiver, &otg_nb);
if (ret) { if (ret) {
...@@ -408,7 +408,7 @@ static int pda_power_probe(struct platform_device *pdev) ...@@ -408,7 +408,7 @@ static int pda_power_probe(struct platform_device *pdev)
if (pdata->is_ac_online && ac_irq) if (pdata->is_ac_online && ac_irq)
free_irq(ac_irq->start, &pda_psy_ac); free_irq(ac_irq->start, &pda_psy_ac);
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (transceiver) if (!IS_ERR_OR_NULL(transceiver))
usb_put_phy(transceiver); usb_put_phy(transceiver);
#endif #endif
ac_irq_failed: ac_irq_failed:
...@@ -443,7 +443,7 @@ static int pda_power_remove(struct platform_device *pdev) ...@@ -443,7 +443,7 @@ static int pda_power_remove(struct platform_device *pdev)
if (pdata->is_ac_online) if (pdata->is_ac_online)
power_supply_unregister(&pda_psy_ac); power_supply_unregister(&pda_psy_ac);
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (transceiver) if (!IS_ERR_OR_NULL(transceiver))
usb_put_phy(transceiver); usb_put_phy(transceiver);
#endif #endif
if (ac_draw) { if (ac_draw) {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/err.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/i2c/twl.h> #include <linux/i2c/twl.h>
...@@ -480,7 +481,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev) ...@@ -480,7 +481,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
INIT_WORK(&bci->work, twl4030_bci_usb_work); INIT_WORK(&bci->work, twl4030_bci_usb_work);
bci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); bci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
if (bci->transceiver != NULL) { if (!IS_ERR_OR_NULL(bci->transceiver)) {
bci->usb_nb.notifier_call = twl4030_bci_usb_ncb; bci->usb_nb.notifier_call = twl4030_bci_usb_ncb;
usb_register_notifier(bci->transceiver, &bci->usb_nb); usb_register_notifier(bci->transceiver, &bci->usb_nb);
} }
...@@ -507,7 +508,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev) ...@@ -507,7 +508,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
return 0; return 0;
fail_unmask_interrupts: fail_unmask_interrupts:
if (bci->transceiver != NULL) { if (!IS_ERR_OR_NULL(bci->transceiver)) {
usb_unregister_notifier(bci->transceiver, &bci->usb_nb); usb_unregister_notifier(bci->transceiver, &bci->usb_nb);
usb_put_phy(bci->transceiver); usb_put_phy(bci->transceiver);
} }
...@@ -538,7 +539,7 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev) ...@@ -538,7 +539,7 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev)
twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xff, twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xff,
TWL4030_INTERRUPTS_BCIIMR2A); TWL4030_INTERRUPTS_BCIIMR2A);
if (bci->transceiver != NULL) { if (!IS_ERR_OR_NULL(bci->transceiver)) {
usb_unregister_notifier(bci->transceiver, &bci->usb_nb); usb_unregister_notifier(bci->transceiver, &bci->usb_nb);
usb_put_phy(bci->transceiver); usb_put_phy(bci->transceiver);
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/dmapool.h> #include <linux/dmapool.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/err.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -1712,7 +1713,7 @@ static int udc_start(struct ci13xxx *udc) ...@@ -1712,7 +1713,7 @@ static int udc_start(struct ci13xxx *udc)
if (retval) if (retval)
goto unreg_device; goto unreg_device;
if (udc->transceiver) { if (!IS_ERR_OR_NULL(udc->transceiver)) {
retval = otg_set_peripheral(udc->transceiver->otg, retval = otg_set_peripheral(udc->transceiver->otg,
&udc->gadget); &udc->gadget);
if (retval) if (retval)
...@@ -1729,7 +1730,7 @@ static int udc_start(struct ci13xxx *udc) ...@@ -1729,7 +1730,7 @@ static int udc_start(struct ci13xxx *udc)
return retval; return retval;
remove_trans: remove_trans:
if (udc->transceiver) { if (!IS_ERR_OR_NULL(udc->transceiver)) {
otg_set_peripheral(udc->transceiver->otg, &udc->gadget); otg_set_peripheral(udc->transceiver->otg, &udc->gadget);
usb_put_phy(udc->transceiver); usb_put_phy(udc->transceiver);
} }
...@@ -1740,7 +1741,7 @@ static int udc_start(struct ci13xxx *udc) ...@@ -1740,7 +1741,7 @@ static int udc_start(struct ci13xxx *udc)
unreg_device: unreg_device:
device_unregister(&udc->gadget.dev); device_unregister(&udc->gadget.dev);
put_transceiver: put_transceiver:
if (udc->transceiver) if (!IS_ERR_OR_NULL(udc->transceiver))
usb_put_phy(udc->transceiver); usb_put_phy(udc->transceiver);
free_pools: free_pools:
dma_pool_destroy(udc->td_pool); dma_pool_destroy(udc->td_pool);
...@@ -1772,7 +1773,7 @@ static void udc_stop(struct ci13xxx *udc) ...@@ -1772,7 +1773,7 @@ static void udc_stop(struct ci13xxx *udc)
dma_pool_destroy(udc->td_pool); dma_pool_destroy(udc->td_pool);
dma_pool_destroy(udc->qh_pool); dma_pool_destroy(udc->qh_pool);
if (udc->transceiver) { if (!IS_ERR_OR_NULL(udc->transceiver)) {
otg_set_peripheral(udc->transceiver->otg, NULL); otg_set_peripheral(udc->transceiver->otg, NULL);
usb_put_phy(udc->transceiver); usb_put_phy(udc->transceiver);
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/err.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/list.h> #include <linux/list.h>
...@@ -1229,7 +1230,7 @@ static int fsl_vbus_draw(struct usb_gadget *gadget, unsigned mA) ...@@ -1229,7 +1230,7 @@ static int fsl_vbus_draw(struct usb_gadget *gadget, unsigned mA)
struct fsl_udc *udc; struct fsl_udc *udc;
udc = container_of(gadget, struct fsl_udc, gadget); udc = container_of(gadget, struct fsl_udc, gadget);
if (udc->transceiver) if (!IS_ERR_OR_NULL(udc->transceiver))
return usb_phy_set_power(udc->transceiver, mA); return usb_phy_set_power(udc->transceiver, mA);
return -ENOTSUPP; return -ENOTSUPP;
} }
...@@ -1983,13 +1984,13 @@ static int fsl_start(struct usb_gadget_driver *driver, ...@@ -1983,13 +1984,13 @@ static int fsl_start(struct usb_gadget_driver *driver,
goto out; goto out;
} }
if (udc_controller->transceiver) { if (!IS_ERR_OR_NULL(udc_controller->transceiver)) {
/* Suspend the controller until OTG enable it */ /* Suspend the controller until OTG enable it */
udc_controller->stopped = 1; udc_controller->stopped = 1;
printk(KERN_INFO "Suspend udc for OTG auto detect\n"); printk(KERN_INFO "Suspend udc for OTG auto detect\n");
/* connect to bus through transceiver */ /* connect to bus through transceiver */
if (udc_controller->transceiver) { if (!IS_ERR_OR_NULL(udc_controller->transceiver)) {
retval = otg_set_peripheral( retval = otg_set_peripheral(
udc_controller->transceiver->otg, udc_controller->transceiver->otg,
&udc_controller->gadget); &udc_controller->gadget);
...@@ -2030,7 +2031,7 @@ static int fsl_stop(struct usb_gadget_driver *driver) ...@@ -2030,7 +2031,7 @@ static int fsl_stop(struct usb_gadget_driver *driver)
if (!driver || driver != udc_controller->driver || !driver->unbind) if (!driver || driver != udc_controller->driver || !driver->unbind)
return -EINVAL; return -EINVAL;
if (udc_controller->transceiver) if (!IS_ERR_OR_NULL(udc_controller->transceiver))
otg_set_peripheral(udc_controller->transceiver->otg, NULL); otg_set_peripheral(udc_controller->transceiver->otg, NULL);
/* stop DR, disable intr */ /* stop DR, disable intr */
...@@ -2456,7 +2457,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) ...@@ -2456,7 +2457,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
#ifdef CONFIG_USB_OTG #ifdef CONFIG_USB_OTG
if (pdata->operating_mode == FSL_USB2_DR_OTG) { if (pdata->operating_mode == FSL_USB2_DR_OTG) {
udc_controller->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); udc_controller->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
if (!udc_controller->transceiver) { if (IS_ERR_OR_NULL(udc_controller->transceiver)) {
ERR("Can't find OTG driver!\n"); ERR("Can't find OTG driver!\n");
ret = -ENODEV; ret = -ENODEV;
goto err_kfree; goto err_kfree;
...@@ -2540,7 +2541,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) ...@@ -2540,7 +2541,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
goto err_free_irq; goto err_free_irq;
} }
if (!udc_controller->transceiver) { if (IS_ERR_OR_NULL(udc_controller->transceiver)) {
/* initialize usb hw reg except for regs for EP, /* initialize usb hw reg except for regs for EP,
* leave usbintr reg untouched */ * leave usbintr reg untouched */
dr_controller_setup(udc_controller); dr_controller_setup(udc_controller);
...@@ -2564,7 +2565,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) ...@@ -2564,7 +2565,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
if (ret < 0) if (ret < 0)
goto err_free_irq; goto err_free_irq;
if (udc_controller->transceiver) if (!IS_ERR_OR_NULL(udc_controller->transceiver))
udc_controller->gadget.is_otg = 1; udc_controller->gadget.is_otg = 1;
/* setup QH and epctrl for ep0 */ /* setup QH and epctrl for ep0 */
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/err.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/list.h> #include <linux/list.h>
...@@ -1381,7 +1382,7 @@ static int mv_udc_start(struct usb_gadget_driver *driver, ...@@ -1381,7 +1382,7 @@ static int mv_udc_start(struct usb_gadget_driver *driver,
return retval; return retval;
} }
if (udc->transceiver) { if (!IS_ERR_OR_NULL(udc->transceiver)) {
retval = otg_set_peripheral(udc->transceiver->otg, retval = otg_set_peripheral(udc->transceiver->otg,
&udc->gadget); &udc->gadget);
if (retval) { if (retval) {
...@@ -2107,7 +2108,7 @@ static int __devexit mv_udc_remove(struct platform_device *dev) ...@@ -2107,7 +2108,7 @@ static int __devexit mv_udc_remove(struct platform_device *dev)
* then vbus irq will not be requested in udc driver. * then vbus irq will not be requested in udc driver.
*/ */
if (udc->pdata && udc->pdata->vbus if (udc->pdata && udc->pdata->vbus
&& udc->clock_gating && udc->transceiver == NULL) && udc->clock_gating && IS_ERR_OR_NULL(udc->transceiver))
free_irq(udc->pdata->vbus->irq, &dev->dev); free_irq(udc->pdata->vbus->irq, &dev->dev);
/* free memory allocated in probe */ /* free memory allocated in probe */
...@@ -2325,7 +2326,7 @@ static int __devinit mv_udc_probe(struct platform_device *dev) ...@@ -2325,7 +2326,7 @@ static int __devinit mv_udc_probe(struct platform_device *dev)
eps_init(udc); eps_init(udc);
/* VBUS detect: we can disable/enable clock on demand.*/ /* VBUS detect: we can disable/enable clock on demand.*/
if (udc->transceiver) if (!IS_ERR_OR_NULL(udc->transceiver))
udc->clock_gating = 1; udc->clock_gating = 1;
else if (pdata->vbus) { else if (pdata->vbus) {
udc->clock_gating = 1; udc->clock_gating = 1;
...@@ -2369,7 +2370,7 @@ static int __devinit mv_udc_probe(struct platform_device *dev) ...@@ -2369,7 +2370,7 @@ static int __devinit mv_udc_probe(struct platform_device *dev)
err_unregister: err_unregister:
if (udc->pdata && udc->pdata->vbus if (udc->pdata && udc->pdata->vbus
&& udc->clock_gating && udc->transceiver == NULL) && udc->clock_gating && IS_ERR_OR_NULL(udc->transceiver))
free_irq(pdata->vbus->irq, &dev->dev); free_irq(pdata->vbus->irq, &dev->dev);
device_unregister(&udc->gadget.dev); device_unregister(&udc->gadget.dev);
err_free_irq: err_free_irq:
...@@ -2404,7 +2405,7 @@ static int mv_udc_suspend(struct device *_dev) ...@@ -2404,7 +2405,7 @@ static int mv_udc_suspend(struct device *_dev)
struct mv_udc *udc = the_controller; struct mv_udc *udc = the_controller;
/* if OTG is enabled, the following will be done in OTG driver*/ /* if OTG is enabled, the following will be done in OTG driver*/
if (udc->transceiver) if (!IS_ERR_OR_NULL(udc->transceiver))
return 0; return 0;
if (udc->pdata->vbus && udc->pdata->vbus->poll) if (udc->pdata->vbus && udc->pdata->vbus->poll)
...@@ -2437,7 +2438,7 @@ static int mv_udc_resume(struct device *_dev) ...@@ -2437,7 +2438,7 @@ static int mv_udc_resume(struct device *_dev)
int retval; int retval;
/* if OTG is enabled, the following will be done in OTG driver*/ /* if OTG is enabled, the following will be done in OTG driver*/
if (udc->transceiver) if (!IS_ERR_OR_NULL(udc->transceiver))
return 0; return 0;
if (!udc->clock_gating) { if (!udc->clock_gating) {
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/usb/otg.h> #include <linux/usb/otg.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h>
#include <linux/prefetch.h> #include <linux/prefetch.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
...@@ -1211,7 +1212,7 @@ static int omap_wakeup(struct usb_gadget *gadget) ...@@ -1211,7 +1212,7 @@ static int omap_wakeup(struct usb_gadget *gadget)
/* NOTE: non-OTG systems may use SRP TOO... */ /* NOTE: non-OTG systems may use SRP TOO... */
} else if (!(udc->devstat & UDC_ATT)) { } else if (!(udc->devstat & UDC_ATT)) {
if (udc->transceiver) if (!IS_ERR_OR_NULL(udc->transceiver))
retval = otg_start_srp(udc->transceiver->otg); retval = otg_start_srp(udc->transceiver->otg);
} }
spin_unlock_irqrestore(&udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
...@@ -1343,7 +1344,7 @@ static int omap_vbus_draw(struct usb_gadget *gadget, unsigned mA) ...@@ -1343,7 +1344,7 @@ static int omap_vbus_draw(struct usb_gadget *gadget, unsigned mA)
struct omap_udc *udc; struct omap_udc *udc;
udc = container_of(gadget, struct omap_udc, gadget); udc = container_of(gadget, struct omap_udc, gadget);
if (udc->transceiver) if (!IS_ERR_OR_NULL(udc->transceiver))
return usb_phy_set_power(udc->transceiver, mA); return usb_phy_set_power(udc->transceiver, mA);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1792,12 +1793,12 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src) ...@@ -1792,12 +1793,12 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src)
if (devstat & UDC_ATT) { if (devstat & UDC_ATT) {
udc->gadget.speed = USB_SPEED_FULL; udc->gadget.speed = USB_SPEED_FULL;
VDBG("connect\n"); VDBG("connect\n");
if (!udc->transceiver) if (IS_ERR_OR_NULL(udc->transceiver))
pullup_enable(udc); pullup_enable(udc);
// if (driver->connect) call it // if (driver->connect) call it
} else if (udc->gadget.speed != USB_SPEED_UNKNOWN) { } else if (udc->gadget.speed != USB_SPEED_UNKNOWN) {
udc->gadget.speed = USB_SPEED_UNKNOWN; udc->gadget.speed = USB_SPEED_UNKNOWN;
if (!udc->transceiver) if (IS_ERR_OR_NULL(udc->transceiver))
pullup_disable(udc); pullup_disable(udc);
DBG("disconnect, gadget %s\n", DBG("disconnect, gadget %s\n",
udc->driver->driver.name); udc->driver->driver.name);
...@@ -1837,12 +1838,12 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src) ...@@ -1837,12 +1838,12 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src)
udc->driver->suspend(&udc->gadget); udc->driver->suspend(&udc->gadget);
spin_lock(&udc->lock); spin_lock(&udc->lock);
} }
if (udc->transceiver) if (!IS_ERR_OR_NULL(udc->transceiver))
usb_phy_set_suspend( usb_phy_set_suspend(
udc->transceiver, 1); udc->transceiver, 1);
} else { } else {
VDBG("resume\n"); VDBG("resume\n");
if (udc->transceiver) if (!IS_ERR_OR_NULL(udc->transceiver))
usb_phy_set_suspend( usb_phy_set_suspend(
udc->transceiver, 0); udc->transceiver, 0);
if (udc->gadget.speed == USB_SPEED_FULL if (udc->gadget.speed == USB_SPEED_FULL
...@@ -2154,7 +2155,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver, ...@@ -2154,7 +2155,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver,
omap_writew(UDC_IRQ_SRC_MASK, UDC_IRQ_SRC); omap_writew(UDC_IRQ_SRC_MASK, UDC_IRQ_SRC);
/* connect to bus through transceiver */ /* connect to bus through transceiver */
if (udc->transceiver) { if (!IS_ERR_OR_NULL(udc->transceiver)) {
status = otg_set_peripheral(udc->transceiver->otg, status = otg_set_peripheral(udc->transceiver->otg,
&udc->gadget); &udc->gadget);
if (status < 0) { if (status < 0) {
...@@ -2201,7 +2202,7 @@ static int omap_udc_stop(struct usb_gadget_driver *driver) ...@@ -2201,7 +2202,7 @@ static int omap_udc_stop(struct usb_gadget_driver *driver)
if (machine_without_vbus_sense()) if (machine_without_vbus_sense())
omap_vbus_session(&udc->gadget, 0); omap_vbus_session(&udc->gadget, 0);
if (udc->transceiver) if (!IS_ERR_OR_NULL(udc->transceiver))
(void) otg_set_peripheral(udc->transceiver->otg, NULL); (void) otg_set_peripheral(udc->transceiver->otg, NULL);
else else
pullup_disable(udc); pullup_disable(udc);
...@@ -2866,7 +2867,7 @@ static int __init omap_udc_probe(struct platform_device *pdev) ...@@ -2866,7 +2867,7 @@ static int __init omap_udc_probe(struct platform_device *pdev)
* but not having one probably means no VBUS detection. * but not having one probably means no VBUS detection.
*/ */
xceiv = usb_get_phy(USB_PHY_TYPE_USB2); xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (xceiv) if (!IS_ERR_OR_NULL(xceiv))
type = xceiv->label; type = xceiv->label;
else if (config->otg) { else if (config->otg) {
DBG("OTG requires external transceiver!\n"); DBG("OTG requires external transceiver!\n");
...@@ -2898,7 +2899,7 @@ static int __init omap_udc_probe(struct platform_device *pdev) ...@@ -2898,7 +2899,7 @@ static int __init omap_udc_probe(struct platform_device *pdev)
case 16: case 16:
case 19: case 19:
case 25: case 25:
if (!xceiv) { if (IS_ERR_OR_NULL(xceiv)) {
DBG("external transceiver not registered!\n"); DBG("external transceiver not registered!\n");
type = "unknown"; type = "unknown";
} }
...@@ -3010,7 +3011,7 @@ static int __init omap_udc_probe(struct platform_device *pdev) ...@@ -3010,7 +3011,7 @@ static int __init omap_udc_probe(struct platform_device *pdev)
udc = NULL; udc = NULL;
cleanup0: cleanup0:
if (xceiv) if (!IS_ERR_OR_NULL(xceiv))
usb_put_phy(xceiv); usb_put_phy(xceiv);
if (cpu_is_omap16xx() || cpu_is_omap24xx() || cpu_is_omap7xx()) { if (cpu_is_omap16xx() || cpu_is_omap24xx() || cpu_is_omap7xx()) {
...@@ -3040,7 +3041,7 @@ static int __exit omap_udc_remove(struct platform_device *pdev) ...@@ -3040,7 +3041,7 @@ static int __exit omap_udc_remove(struct platform_device *pdev)
udc->done = &done; udc->done = &done;
pullup_disable(udc); pullup_disable(udc);
if (udc->transceiver) { if (!IS_ERR_OR_NULL(udc->transceiver)) {
usb_put_phy(udc->transceiver); usb_put_phy(udc->transceiver);
udc->transceiver = NULL; udc->transceiver = NULL;
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/err.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -993,7 +994,7 @@ static int pxa25x_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA) ...@@ -993,7 +994,7 @@ static int pxa25x_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
udc = container_of(_gadget, struct pxa25x_udc, gadget); udc = container_of(_gadget, struct pxa25x_udc, gadget);
if (udc->transceiver) if (!IS_ERR_OR_NULL(udc->transceiver))
return usb_phy_set_power(udc->transceiver, mA); return usb_phy_set_power(udc->transceiver, mA);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1299,7 +1300,7 @@ static int pxa25x_start(struct usb_gadget_driver *driver, ...@@ -1299,7 +1300,7 @@ static int pxa25x_start(struct usb_gadget_driver *driver,
DMSG("registered gadget driver '%s'\n", driver->driver.name); DMSG("registered gadget driver '%s'\n", driver->driver.name);
/* connect to bus through transceiver */ /* connect to bus through transceiver */
if (dev->transceiver) { if (!IS_ERR_OR_NULL(dev->transceiver)) {
retval = otg_set_peripheral(dev->transceiver->otg, retval = otg_set_peripheral(dev->transceiver->otg,
&dev->gadget); &dev->gadget);
if (retval) { if (retval) {
...@@ -1359,7 +1360,7 @@ static int pxa25x_stop(struct usb_gadget_driver *driver) ...@@ -1359,7 +1360,7 @@ static int pxa25x_stop(struct usb_gadget_driver *driver)
stop_activity(dev, driver); stop_activity(dev, driver);
local_irq_enable(); local_irq_enable();
if (dev->transceiver) if (!IS_ERR_OR_NULL(dev->transceiver))
(void) otg_set_peripheral(dev->transceiver->otg, NULL); (void) otg_set_peripheral(dev->transceiver->otg, NULL);
driver->unbind(&dev->gadget); driver->unbind(&dev->gadget);
...@@ -2237,7 +2238,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev) ...@@ -2237,7 +2238,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev)
if (gpio_is_valid(dev->mach->gpio_pullup)) if (gpio_is_valid(dev->mach->gpio_pullup))
gpio_free(dev->mach->gpio_pullup); gpio_free(dev->mach->gpio_pullup);
err_gpio_pullup: err_gpio_pullup:
if (dev->transceiver) { if (!IS_ERR_OR_NULL(dev->transceiver)) {
usb_put_phy(dev->transceiver); usb_put_phy(dev->transceiver);
dev->transceiver = NULL; dev->transceiver = NULL;
} }
...@@ -2279,7 +2280,7 @@ static int __exit pxa25x_udc_remove(struct platform_device *pdev) ...@@ -2279,7 +2280,7 @@ static int __exit pxa25x_udc_remove(struct platform_device *pdev)
clk_put(dev->clk); clk_put(dev->clk);
if (dev->transceiver) { if (!IS_ERR_OR_NULL(dev->transceiver)) {
usb_put_phy(dev->transceiver); usb_put_phy(dev->transceiver);
dev->transceiver = NULL; dev->transceiver = NULL;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/err.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/list.h> #include <linux/list.h>
...@@ -1573,7 +1574,7 @@ static int should_enable_udc(struct pxa_udc *udc) ...@@ -1573,7 +1574,7 @@ static int should_enable_udc(struct pxa_udc *udc)
int put_on; int put_on;
put_on = ((udc->pullup_on) && (udc->driver)); put_on = ((udc->pullup_on) && (udc->driver));
put_on &= ((udc->vbus_sensed) || (!udc->transceiver)); put_on &= ((udc->vbus_sensed) || (IS_ERR_OR_NULL(udc->transceiver)));
return put_on; return put_on;
} }
...@@ -1594,7 +1595,7 @@ static int should_disable_udc(struct pxa_udc *udc) ...@@ -1594,7 +1595,7 @@ static int should_disable_udc(struct pxa_udc *udc)
int put_off; int put_off;
put_off = ((!udc->pullup_on) || (!udc->driver)); put_off = ((!udc->pullup_on) || (!udc->driver));
put_off |= ((!udc->vbus_sensed) && (udc->transceiver)); put_off |= ((!udc->vbus_sensed) && (!IS_ERR_OR_NULL(udc->transceiver)));
return put_off; return put_off;
} }
...@@ -1665,7 +1666,7 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA) ...@@ -1665,7 +1666,7 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
struct pxa_udc *udc; struct pxa_udc *udc;
udc = to_gadget_udc(_gadget); udc = to_gadget_udc(_gadget);
if (udc->transceiver) if (!IS_ERR_OR_NULL(udc->transceiver))
return usb_phy_set_power(udc->transceiver, mA); return usb_phy_set_power(udc->transceiver, mA);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1834,7 +1835,7 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver, ...@@ -1834,7 +1835,7 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver,
dev_dbg(udc->dev, "registered gadget driver '%s'\n", dev_dbg(udc->dev, "registered gadget driver '%s'\n",
driver->driver.name); driver->driver.name);
if (udc->transceiver) { if (!IS_ERR_OR_NULL(udc->transceiver)) {
retval = otg_set_peripheral(udc->transceiver->otg, retval = otg_set_peripheral(udc->transceiver->otg,
&udc->gadget); &udc->gadget);
if (retval) { if (retval) {
...@@ -1908,7 +1909,7 @@ static int pxa27x_udc_stop(struct usb_gadget_driver *driver) ...@@ -1908,7 +1909,7 @@ static int pxa27x_udc_stop(struct usb_gadget_driver *driver)
dev_info(udc->dev, "unregistered gadget driver '%s'\n", dev_info(udc->dev, "unregistered gadget driver '%s'\n",
driver->driver.name); driver->driver.name);
if (udc->transceiver) if (!IS_ERR_OR_NULL(udc->transceiver))
return otg_set_peripheral(udc->transceiver->otg, NULL); return otg_set_peripheral(udc->transceiver->otg, NULL);
return 0; return 0;
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h>
#include <linux/usb/ch9.h> #include <linux/usb/ch9.h>
#include <linux/usb/gadget.h> #include <linux/usb/gadget.h>
#include <linux/usb/otg.h> #include <linux/usb/otg.h>
...@@ -1165,7 +1166,7 @@ static int s3c_hsudc_start(struct usb_gadget *gadget, ...@@ -1165,7 +1166,7 @@ static int s3c_hsudc_start(struct usb_gadget *gadget,
} }
/* connect to bus through transceiver */ /* connect to bus through transceiver */
if (hsudc->transceiver) { if (!IS_ERR_OR_NULL(hsudc->transceiver)) {
ret = otg_set_peripheral(hsudc->transceiver->otg, ret = otg_set_peripheral(hsudc->transceiver->otg,
&hsudc->gadget); &hsudc->gadget);
if (ret) { if (ret) {
...@@ -1220,7 +1221,7 @@ static int s3c_hsudc_stop(struct usb_gadget *gadget, ...@@ -1220,7 +1221,7 @@ static int s3c_hsudc_stop(struct usb_gadget *gadget,
s3c_hsudc_stop_activity(hsudc); s3c_hsudc_stop_activity(hsudc);
spin_unlock_irqrestore(&hsudc->lock, flags); spin_unlock_irqrestore(&hsudc->lock, flags);
if (hsudc->transceiver) if (!IS_ERR_OR_NULL(hsudc->transceiver))
(void) otg_set_peripheral(hsudc->transceiver->otg, NULL); (void) otg_set_peripheral(hsudc->transceiver->otg, NULL);
disable_irq(hsudc->irq); disable_irq(hsudc->irq);
...@@ -1249,7 +1250,7 @@ static int s3c_hsudc_vbus_draw(struct usb_gadget *gadget, unsigned mA) ...@@ -1249,7 +1250,7 @@ static int s3c_hsudc_vbus_draw(struct usb_gadget *gadget, unsigned mA)
if (!hsudc) if (!hsudc)
return -ENODEV; return -ENODEV;
if (hsudc->transceiver) if (!IS_ERR_OR_NULL(hsudc->transceiver))
return usb_phy_set_power(hsudc->transceiver, mA); return usb_phy_set_power(hsudc->transceiver, mA);
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -1385,7 +1386,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) ...@@ -1385,7 +1386,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev)
err_remap: err_remap:
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
err_res: err_res:
if (hsudc->transceiver) if (!IS_ERR_OR_NULL(hsudc->transceiver))
usb_put_phy(hsudc->transceiver); usb_put_phy(hsudc->transceiver);
regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies);
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/err.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/fsl_devices.h> #include <linux/fsl_devices.h>
...@@ -146,7 +147,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver, ...@@ -146,7 +147,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
dev_dbg(&pdev->dev, "hcd=0x%p ehci=0x%p, transceiver=0x%p\n", dev_dbg(&pdev->dev, "hcd=0x%p ehci=0x%p, transceiver=0x%p\n",
hcd, ehci, ehci->transceiver); hcd, ehci, ehci->transceiver);
if (ehci->transceiver) { if (!IS_ERR_OR_NULL(ehci->transceiver)) {
retval = otg_set_host(ehci->transceiver->otg, retval = otg_set_host(ehci->transceiver->otg,
&ehci_to_hcd(ehci)->self); &ehci_to_hcd(ehci)->self);
if (retval) { if (retval) {
...@@ -192,7 +193,7 @@ static void usb_hcd_fsl_remove(struct usb_hcd *hcd, ...@@ -192,7 +193,7 @@ static void usb_hcd_fsl_remove(struct usb_hcd *hcd,
struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
struct ehci_hcd *ehci = hcd_to_ehci(hcd); struct ehci_hcd *ehci = hcd_to_ehci(hcd);
if (ehci->transceiver) { if (!IS_ERR_OR_NULL(ehci->transceiver)) {
otg_set_host(ehci->transceiver->otg, NULL); otg_set_host(ehci->transceiver->otg, NULL);
usb_put_phy(ehci->transceiver); usb_put_phy(ehci->transceiver);
} }
......
...@@ -146,7 +146,7 @@ static int ehci_msm_probe(struct platform_device *pdev) ...@@ -146,7 +146,7 @@ static int ehci_msm_probe(struct platform_device *pdev)
* management. * management.
*/ */
phy = usb_get_phy(USB_PHY_TYPE_USB2); phy = usb_get_phy(USB_PHY_TYPE_USB2);
if (!phy) { if (IS_ERR_OR_NULL(phy)) {
dev_err(&pdev->dev, "unable to find transceiver\n"); dev_err(&pdev->dev, "unable to find transceiver\n");
ret = -ENODEV; ret = -ENODEV;
goto unmap; goto unmap;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h>
#include <linux/usb/otg.h> #include <linux/usb/otg.h>
#include <linux/platform_data/mv_usb.h> #include <linux/platform_data/mv_usb.h>
...@@ -254,7 +255,7 @@ static int mv_ehci_probe(struct platform_device *pdev) ...@@ -254,7 +255,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
if (ehci_mv->mode == MV_USB_MODE_OTG) { if (ehci_mv->mode == MV_USB_MODE_OTG) {
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
ehci_mv->otg = usb_get_phy(USB_PHY_TYPE_USB2); ehci_mv->otg = usb_get_phy(USB_PHY_TYPE_USB2);
if (!ehci_mv->otg) { if (IS_ERR_OR_NULL(ehci_mv->otg)) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"unable to find transceiver\n"); "unable to find transceiver\n");
retval = -ENODEV; retval = -ENODEV;
...@@ -302,7 +303,7 @@ static int mv_ehci_probe(struct platform_device *pdev) ...@@ -302,7 +303,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
pdata->set_vbus(0); pdata->set_vbus(0);
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
err_put_transceiver: err_put_transceiver:
if (ehci_mv->otg) if (!IS_ERR_OR_NULL(ehci_mv->otg))
usb_put_phy(ehci_mv->otg); usb_put_phy(ehci_mv->otg);
#endif #endif
err_disable_clk: err_disable_clk:
...@@ -331,7 +332,7 @@ static int mv_ehci_remove(struct platform_device *pdev) ...@@ -331,7 +332,7 @@ static int mv_ehci_remove(struct platform_device *pdev)
if (hcd->rh_registered) if (hcd->rh_registered)
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
if (ehci_mv->otg) { if (!IS_ERR_OR_NULL(ehci_mv->otg)) {
otg_set_host(ehci_mv->otg->otg, NULL); otg_set_host(ehci_mv->otg->otg, NULL);
usb_put_phy(ehci_mv->otg); usb_put_phy(ehci_mv->otg);
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/platform_data/tegra_usb.h> #include <linux/platform_data/tegra_usb.h>
#include <linux/irq.h> #include <linux/irq.h>
...@@ -750,7 +751,7 @@ static int tegra_ehci_probe(struct platform_device *pdev) ...@@ -750,7 +751,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (pdata->operating_mode == TEGRA_USB_OTG) { if (pdata->operating_mode == TEGRA_USB_OTG) {
tegra->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); tegra->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
if (tegra->transceiver) if (!IS_ERR_OR_NULL(tegra->transceiver))
otg_set_host(tegra->transceiver->otg, &hcd->self); otg_set_host(tegra->transceiver->otg, &hcd->self);
} }
#endif #endif
...@@ -773,7 +774,7 @@ static int tegra_ehci_probe(struct platform_device *pdev) ...@@ -773,7 +774,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
fail: fail:
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (tegra->transceiver) { if (!IS_ERR_OR_NULL(tegra->transceiver)) {
otg_set_host(tegra->transceiver->otg, NULL); otg_set_host(tegra->transceiver->otg, NULL);
usb_put_phy(tegra->transceiver); usb_put_phy(tegra->transceiver);
} }
...@@ -808,7 +809,7 @@ static int tegra_ehci_remove(struct platform_device *pdev) ...@@ -808,7 +809,7 @@ static int tegra_ehci_remove(struct platform_device *pdev)
pm_runtime_put_noidle(&pdev->dev); pm_runtime_put_noidle(&pdev->dev);
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (tegra->transceiver) { if (!IS_ERR_OR_NULL(tegra->transceiver)) {
otg_set_host(tegra->transceiver->otg, NULL); otg_set_host(tegra->transceiver->otg, NULL);
usb_put_phy(tegra->transceiver); usb_put_phy(tegra->transceiver);
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <mach/hardware.h> #include <mach/hardware.h>
...@@ -212,7 +213,7 @@ static int ohci_omap_init(struct usb_hcd *hcd) ...@@ -212,7 +213,7 @@ static int ohci_omap_init(struct usb_hcd *hcd)
#ifdef CONFIG_USB_OTG #ifdef CONFIG_USB_OTG
if (need_transceiver) { if (need_transceiver) {
ohci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); ohci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
if (ohci->transceiver) { if (!IS_ERR_OR_NULL(ohci->transceiver)) {
int status = otg_set_host(ohci->transceiver->otg, int status = otg_set_host(ohci->transceiver->otg,
&ohci_to_hcd(ohci)->self); &ohci_to_hcd(ohci)->self);
dev_dbg(hcd->self.controller, "init %s transceiver, status %d\n", dev_dbg(hcd->self.controller, "init %s transceiver, status %d\n",
...@@ -403,7 +404,7 @@ usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) ...@@ -403,7 +404,7 @@ usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev)
struct ohci_hcd *ohci = hcd_to_ohci (hcd); struct ohci_hcd *ohci = hcd_to_ohci (hcd);
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
if (ohci->transceiver) { if (!IS_ERR_OR_NULL(ohci->transceiver)) {
(void) otg_set_host(ohci->transceiver->otg, 0); (void) otg_set_host(ohci->transceiver->otg, 0);
usb_put_phy(ohci->transceiver); usb_put_phy(ohci->transceiver);
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
...@@ -365,7 +366,7 @@ static int am35x_musb_init(struct musb *musb) ...@@ -365,7 +366,7 @@ static int am35x_musb_init(struct musb *musb)
usb_nop_xceiv_register(); usb_nop_xceiv_register();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv) if (IS_ERR_OR_NULL(musb->xceiv))
return -ENODEV; return -ENODEV;
if (is_host_enabled(musb)) if (is_host_enabled(musb))
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/err.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/prefetch.h> #include <linux/prefetch.h>
...@@ -416,7 +417,7 @@ static int bfin_musb_init(struct musb *musb) ...@@ -416,7 +417,7 @@ static int bfin_musb_init(struct musb *musb)
usb_nop_xceiv_register(); usb_nop_xceiv_register();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv) { if (IS_ERR_OR_NULL(musb->xceiv)) {
gpio_free(musb->config->gpio_vrsel); gpio_free(musb->config->gpio_vrsel);
return -ENODEV; return -ENODEV;
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
...@@ -426,7 +427,7 @@ static int da8xx_musb_init(struct musb *musb) ...@@ -426,7 +427,7 @@ static int da8xx_musb_init(struct musb *musb)
usb_nop_xceiv_register(); usb_nop_xceiv_register();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv) if (IS_ERR_OR_NULL(musb->xceiv))
goto fail; goto fail;
if (is_host_enabled(musb)) if (is_host_enabled(musb))
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
...@@ -385,7 +386,7 @@ static int davinci_musb_init(struct musb *musb) ...@@ -385,7 +386,7 @@ static int davinci_musb_init(struct musb *musb)
usb_nop_xceiv_register(); usb_nop_xceiv_register();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv) if (IS_ERR_OR_NULL(musb->xceiv))
goto unregister; goto unregister;
musb->mregs += DAVINCI_BASE_OFFSET; musb->mregs += DAVINCI_BASE_OFFSET;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/err.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
...@@ -377,7 +378,7 @@ static int dsps_musb_init(struct musb *musb) ...@@ -377,7 +378,7 @@ static int dsps_musb_init(struct musb *musb)
/* NOP driver needs change if supporting dual instance */ /* NOP driver needs change if supporting dual instance */
usb_nop_xceiv_register(); usb_nop_xceiv_register();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv) if (IS_ERR_OR_NULL(musb->xceiv))
return -ENODEV; return -ENODEV;
/* Returns zero if e.g. not clocked */ /* Returns zero if e.g. not clocked */
......
...@@ -320,7 +320,7 @@ static int omap2430_musb_init(struct musb *musb) ...@@ -320,7 +320,7 @@ static int omap2430_musb_init(struct musb *musb)
* which needs a driver, drivers aren't always needed. * which needs a driver, drivers aren't always needed.
*/ */
musb->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); musb->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
if (!musb->xceiv) { if (IS_ERR_OR_NULL(musb->xceiv)) {
pr_err("HS USB OTG: no transceiver configured\n"); pr_err("HS USB OTG: no transceiver configured\n");
return -ENODEV; return -ENODEV;
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/err.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/prefetch.h> #include <linux/prefetch.h>
#include <linux/usb.h> #include <linux/usb.h>
...@@ -1079,7 +1080,7 @@ static int tusb_musb_init(struct musb *musb) ...@@ -1079,7 +1080,7 @@ static int tusb_musb_init(struct musb *musb)
usb_nop_xceiv_register(); usb_nop_xceiv_register();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv) if (IS_ERR_OR_NULL(musb->xceiv))
return -ENODEV; return -ENODEV;
pdev = to_platform_device(musb->controller); pdev = to_platform_device(musb->controller);
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
...@@ -38,7 +39,7 @@ struct ux500_glue { ...@@ -38,7 +39,7 @@ struct ux500_glue {
static int ux500_musb_init(struct musb *musb) static int ux500_musb_init(struct musb *musb)
{ {
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv) { if (IS_ERR_OR_NULL(musb->xceiv)) {
pr_err("HS USB OTG: no transceiver configured\n"); pr_err("HS USB OTG: no transceiver configured\n");
return -ENODEV; return -ENODEV;
} }
......
...@@ -67,7 +67,7 @@ struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type) ...@@ -67,7 +67,7 @@ struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type)
return NULL; return NULL;
phy = usb_get_phy(type); phy = usb_get_phy(type);
if (phy) { if (!IS_ERR(phy)) {
*ptr = phy; *ptr = phy;
devres_add(dev, ptr); devres_add(dev, ptr);
} else } else
...@@ -82,7 +82,7 @@ EXPORT_SYMBOL(devm_usb_get_phy); ...@@ -82,7 +82,7 @@ EXPORT_SYMBOL(devm_usb_get_phy);
* @type - the type of the phy the controller requires * @type - the type of the phy the controller requires
* *
* Returns the phy driver, after getting a refcount to it; or * Returns the phy driver, after getting a refcount to it; or
* null if there is no such phy. The caller is responsible for * -ENODEV if there is no such phy. The caller is responsible for
* calling usb_put_phy() to release that count. * calling usb_put_phy() to release that count.
* *
* For use by USB host and peripheral drivers. * For use by USB host and peripheral drivers.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment