aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorKishon Vijay Abraham I <kishon@ti.com>2012-06-26 08:10:32 -0400
committerFelipe Balbi <balbi@ti.com>2012-07-02 03:40:49 -0400
commitded017ee6c7b90f7356bd8488f8af1c10ba90490 (patch)
tree1ed1612aa13f24e1aa8480fb497d2a0311fae9cc /drivers
parentb8a3efa3a363720687d21228d6b23b988a223bbb (diff)
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: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/power/ab8500_charger.c2
-rw-r--r--drivers/power/isp1704_charger.c2
-rw-r--r--drivers/power/pda_power.c16
-rw-r--r--drivers/power/twl4030_charger.c7
-rw-r--r--drivers/usb/chipidea/udc.c9
-rw-r--r--drivers/usb/gadget/fsl_udc_core.c15
-rw-r--r--drivers/usb/gadget/mv_udc_core.c13
-rw-r--r--drivers/usb/gadget/omap_udc.c25
-rw-r--r--drivers/usb/gadget/pxa25x_udc.c11
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c11
-rw-r--r--drivers/usb/gadget/s3c-hsudc.c9
-rw-r--r--drivers/usb/host/ehci-fsl.c5
-rw-r--r--drivers/usb/host/ehci-msm.c2
-rw-r--r--drivers/usb/host/ehci-mv.c7
-rw-r--r--drivers/usb/host/ehci-tegra.c7
-rw-r--r--drivers/usb/host/ohci-omap.c5
-rw-r--r--drivers/usb/musb/am35x.c3
-rw-r--r--drivers/usb/musb/blackfin.c3
-rw-r--r--drivers/usb/musb/da8xx.c3
-rw-r--r--drivers/usb/musb/davinci.c3
-rw-r--r--drivers/usb/musb/musb_dsps.c3
-rw-r--r--drivers/usb/musb/omap2430.c2
-rw-r--r--drivers/usb/musb/tusb6010.c3
-rw-r--r--drivers/usb/musb/ux500.c3
-rw-r--r--drivers/usb/otg/otg.c4
25 files changed, 96 insertions, 77 deletions
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index 6bd6f1c41967..d4f0c98428cb 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -2689,7 +2689,7 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
2689 } 2689 }
2690 2690
2691 di->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2); 2691 di->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2);
2692 if (!di->usb_phy) { 2692 if (IS_ERR_OR_NULL(di->usb_phy)) {
2693 dev_err(di->dev, "failed to get usb transceiver\n"); 2693 dev_err(di->dev, "failed to get usb transceiver\n");
2694 ret = -EINVAL; 2694 ret = -EINVAL;
2695 goto free_usb; 2695 goto free_usb;
diff --git a/drivers/power/isp1704_charger.c b/drivers/power/isp1704_charger.c
index 090e5f9e72c9..122911978da2 100644
--- a/drivers/power/isp1704_charger.c
+++ b/drivers/power/isp1704_charger.c
@@ -416,7 +416,7 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
416 return -ENOMEM; 416 return -ENOMEM;
417 417
418 isp->phy = usb_get_phy(USB_PHY_TYPE_USB2); 418 isp->phy = usb_get_phy(USB_PHY_TYPE_USB2);
419 if (!isp->phy) 419 if (IS_ERR_OR_NULL(isp->phy))
420 goto fail0; 420 goto fail0;
421 421
422 isp->dev = &pdev->dev; 422 isp->dev = &pdev->dev;
diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
index 7602d49e4d81..8dbcd53c5e67 100644
--- a/drivers/power/pda_power.c
+++ b/drivers/power/pda_power.c
@@ -322,11 +322,11 @@ static int pda_power_probe(struct platform_device *pdev)
322 322
323#ifdef CONFIG_USB_OTG_UTILS 323#ifdef CONFIG_USB_OTG_UTILS
324 transceiver = usb_get_phy(USB_PHY_TYPE_USB2); 324 transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
325 if (transceiver && !pdata->is_usb_online) { 325 if (!IS_ERR_OR_NULL(transceiver)) {
326 pdata->is_usb_online = otg_is_usb_online; 326 if (!pdata->is_usb_online)
327 } 327 pdata->is_usb_online = otg_is_usb_online;
328 if (transceiver && !pdata->is_ac_online) { 328 if (!pdata->is_ac_online)
329 pdata->is_ac_online = otg_is_ac_online; 329 pdata->is_ac_online = otg_is_ac_online;
330 } 330 }
331#endif 331#endif
332 332
@@ -373,7 +373,7 @@ static int pda_power_probe(struct platform_device *pdev)
373 } 373 }
374 374
375#ifdef CONFIG_USB_OTG_UTILS 375#ifdef CONFIG_USB_OTG_UTILS
376 if (transceiver && pdata->use_otg_notifier) { 376 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
377 otg_nb.notifier_call = otg_handle_notification; 377 otg_nb.notifier_call = otg_handle_notification;
378 ret = usb_register_notifier(transceiver, &otg_nb); 378 ret = usb_register_notifier(transceiver, &otg_nb);
379 if (ret) { 379 if (ret) {
@@ -408,7 +408,7 @@ usb_supply_failed:
408 if (pdata->is_ac_online && ac_irq) 408 if (pdata->is_ac_online && ac_irq)
409 free_irq(ac_irq->start, &pda_psy_ac); 409 free_irq(ac_irq->start, &pda_psy_ac);
410#ifdef CONFIG_USB_OTG_UTILS 410#ifdef CONFIG_USB_OTG_UTILS
411 if (transceiver) 411 if (!IS_ERR_OR_NULL(transceiver))
412 usb_put_phy(transceiver); 412 usb_put_phy(transceiver);
413#endif 413#endif
414ac_irq_failed: 414ac_irq_failed:
@@ -443,7 +443,7 @@ static int pda_power_remove(struct platform_device *pdev)
443 if (pdata->is_ac_online) 443 if (pdata->is_ac_online)
444 power_supply_unregister(&pda_psy_ac); 444 power_supply_unregister(&pda_psy_ac);
445#ifdef CONFIG_USB_OTG_UTILS 445#ifdef CONFIG_USB_OTG_UTILS
446 if (transceiver) 446 if (!IS_ERR_OR_NULL(transceiver))
447 usb_put_phy(transceiver); 447 usb_put_phy(transceiver);
448#endif 448#endif
449 if (ac_draw) { 449 if (ac_draw) {
diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c
index 13f9db2e8538..7cacbaa68efe 100644
--- a/drivers/power/twl4030_charger.c
+++ b/drivers/power/twl4030_charger.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/err.h>
18#include <linux/platform_device.h> 19#include <linux/platform_device.h>
19#include <linux/interrupt.h> 20#include <linux/interrupt.h>
20#include <linux/i2c/twl.h> 21#include <linux/i2c/twl.h>
@@ -480,7 +481,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
480 INIT_WORK(&bci->work, twl4030_bci_usb_work); 481 INIT_WORK(&bci->work, twl4030_bci_usb_work);
481 482
482 bci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); 483 bci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
483 if (bci->transceiver != NULL) { 484 if (!IS_ERR_OR_NULL(bci->transceiver)) {
484 bci->usb_nb.notifier_call = twl4030_bci_usb_ncb; 485 bci->usb_nb.notifier_call = twl4030_bci_usb_ncb;
485 usb_register_notifier(bci->transceiver, &bci->usb_nb); 486 usb_register_notifier(bci->transceiver, &bci->usb_nb);
486 } 487 }
@@ -507,7 +508,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
507 return 0; 508 return 0;
508 509
509fail_unmask_interrupts: 510fail_unmask_interrupts:
510 if (bci->transceiver != NULL) { 511 if (!IS_ERR_OR_NULL(bci->transceiver)) {
511 usb_unregister_notifier(bci->transceiver, &bci->usb_nb); 512 usb_unregister_notifier(bci->transceiver, &bci->usb_nb);
512 usb_put_phy(bci->transceiver); 513 usb_put_phy(bci->transceiver);
513 } 514 }
@@ -538,7 +539,7 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev)
538 twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xff, 539 twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xff,
539 TWL4030_INTERRUPTS_BCIIMR2A); 540 TWL4030_INTERRUPTS_BCIIMR2A);
540 541
541 if (bci->transceiver != NULL) { 542 if (!IS_ERR_OR_NULL(bci->transceiver)) {
542 usb_unregister_notifier(bci->transceiver, &bci->usb_nb); 543 usb_unregister_notifier(bci->transceiver, &bci->usb_nb);
543 usb_put_phy(bci->transceiver); 544 usb_put_phy(bci->transceiver);
544 } 545 }
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index a06d28b119f5..4688ab71bd27 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -14,6 +14,7 @@
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/dmapool.h> 15#include <linux/dmapool.h>
16#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
17#include <linux/err.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/platform_device.h> 19#include <linux/platform_device.h>
19#include <linux/module.h> 20#include <linux/module.h>
@@ -1712,7 +1713,7 @@ static int udc_start(struct ci13xxx *udc)
1712 if (retval) 1713 if (retval)
1713 goto unreg_device; 1714 goto unreg_device;
1714 1715
1715 if (udc->transceiver) { 1716 if (!IS_ERR_OR_NULL(udc->transceiver)) {
1716 retval = otg_set_peripheral(udc->transceiver->otg, 1717 retval = otg_set_peripheral(udc->transceiver->otg,
1717 &udc->gadget); 1718 &udc->gadget);
1718 if (retval) 1719 if (retval)
@@ -1729,7 +1730,7 @@ static int udc_start(struct ci13xxx *udc)
1729 return retval; 1730 return retval;
1730 1731
1731remove_trans: 1732remove_trans:
1732 if (udc->transceiver) { 1733 if (!IS_ERR_OR_NULL(udc->transceiver)) {
1733 otg_set_peripheral(udc->transceiver->otg, &udc->gadget); 1734 otg_set_peripheral(udc->transceiver->otg, &udc->gadget);
1734 usb_put_phy(udc->transceiver); 1735 usb_put_phy(udc->transceiver);
1735 } 1736 }
@@ -1740,7 +1741,7 @@ remove_dbg:
1740unreg_device: 1741unreg_device:
1741 device_unregister(&udc->gadget.dev); 1742 device_unregister(&udc->gadget.dev);
1742put_transceiver: 1743put_transceiver:
1743 if (udc->transceiver) 1744 if (!IS_ERR_OR_NULL(udc->transceiver))
1744 usb_put_phy(udc->transceiver); 1745 usb_put_phy(udc->transceiver);
1745free_pools: 1746free_pools:
1746 dma_pool_destroy(udc->td_pool); 1747 dma_pool_destroy(udc->td_pool);
@@ -1772,7 +1773,7 @@ static void udc_stop(struct ci13xxx *udc)
1772 dma_pool_destroy(udc->td_pool); 1773 dma_pool_destroy(udc->td_pool);
1773 dma_pool_destroy(udc->qh_pool); 1774 dma_pool_destroy(udc->qh_pool);
1774 1775
1775 if (udc->transceiver) { 1776 if (!IS_ERR_OR_NULL(udc->transceiver)) {
1776 otg_set_peripheral(udc->transceiver->otg, NULL); 1777 otg_set_peripheral(udc->transceiver->otg, NULL);
1777 usb_put_phy(udc->transceiver); 1778 usb_put_phy(udc->transceiver);
1778 } 1779 }
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index 0808820ba495..8d8fca635cc7 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -24,6 +24,7 @@
24#include <linux/ioport.h> 24#include <linux/ioport.h>
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/err.h>
27#include <linux/slab.h> 28#include <linux/slab.h>
28#include <linux/init.h> 29#include <linux/init.h>
29#include <linux/list.h> 30#include <linux/list.h>
@@ -1229,7 +1230,7 @@ static int fsl_vbus_draw(struct usb_gadget *gadget, unsigned mA)
1229 struct fsl_udc *udc; 1230 struct fsl_udc *udc;
1230 1231
1231 udc = container_of(gadget, struct fsl_udc, gadget); 1232 udc = container_of(gadget, struct fsl_udc, gadget);
1232 if (udc->transceiver) 1233 if (!IS_ERR_OR_NULL(udc->transceiver))
1233 return usb_phy_set_power(udc->transceiver, mA); 1234 return usb_phy_set_power(udc->transceiver, mA);
1234 return -ENOTSUPP; 1235 return -ENOTSUPP;
1235} 1236}
@@ -1983,13 +1984,13 @@ static int fsl_start(struct usb_gadget_driver *driver,
1983 goto out; 1984 goto out;
1984 } 1985 }
1985 1986
1986 if (udc_controller->transceiver) { 1987 if (!IS_ERR_OR_NULL(udc_controller->transceiver)) {
1987 /* Suspend the controller until OTG enable it */ 1988 /* Suspend the controller until OTG enable it */
1988 udc_controller->stopped = 1; 1989 udc_controller->stopped = 1;
1989 printk(KERN_INFO "Suspend udc for OTG auto detect\n"); 1990 printk(KERN_INFO "Suspend udc for OTG auto detect\n");
1990 1991
1991 /* connect to bus through transceiver */ 1992 /* connect to bus through transceiver */
1992 if (udc_controller->transceiver) { 1993 if (!IS_ERR_OR_NULL(udc_controller->transceiver)) {
1993 retval = otg_set_peripheral( 1994 retval = otg_set_peripheral(
1994 udc_controller->transceiver->otg, 1995 udc_controller->transceiver->otg,
1995 &udc_controller->gadget); 1996 &udc_controller->gadget);
@@ -2030,7 +2031,7 @@ static int fsl_stop(struct usb_gadget_driver *driver)
2030 if (!driver || driver != udc_controller->driver || !driver->unbind) 2031 if (!driver || driver != udc_controller->driver || !driver->unbind)
2031 return -EINVAL; 2032 return -EINVAL;
2032 2033
2033 if (udc_controller->transceiver) 2034 if (!IS_ERR_OR_NULL(udc_controller->transceiver))
2034 otg_set_peripheral(udc_controller->transceiver->otg, NULL); 2035 otg_set_peripheral(udc_controller->transceiver->otg, NULL);
2035 2036
2036 /* stop DR, disable intr */ 2037 /* stop DR, disable intr */
@@ -2456,7 +2457,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
2456#ifdef CONFIG_USB_OTG 2457#ifdef CONFIG_USB_OTG
2457 if (pdata->operating_mode == FSL_USB2_DR_OTG) { 2458 if (pdata->operating_mode == FSL_USB2_DR_OTG) {
2458 udc_controller->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); 2459 udc_controller->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
2459 if (!udc_controller->transceiver) { 2460 if (IS_ERR_OR_NULL(udc_controller->transceiver)) {
2460 ERR("Can't find OTG driver!\n"); 2461 ERR("Can't find OTG driver!\n");
2461 ret = -ENODEV; 2462 ret = -ENODEV;
2462 goto err_kfree; 2463 goto err_kfree;
@@ -2540,7 +2541,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
2540 goto err_free_irq; 2541 goto err_free_irq;
2541 } 2542 }
2542 2543
2543 if (!udc_controller->transceiver) { 2544 if (IS_ERR_OR_NULL(udc_controller->transceiver)) {
2544 /* initialize usb hw reg except for regs for EP, 2545 /* initialize usb hw reg except for regs for EP,
2545 * leave usbintr reg untouched */ 2546 * leave usbintr reg untouched */
2546 dr_controller_setup(udc_controller); 2547 dr_controller_setup(udc_controller);
@@ -2564,7 +2565,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
2564 if (ret < 0) 2565 if (ret < 0)
2565 goto err_free_irq; 2566 goto err_free_irq;
2566 2567
2567 if (udc_controller->transceiver) 2568 if (!IS_ERR_OR_NULL(udc_controller->transceiver))
2568 udc_controller->gadget.is_otg = 1; 2569 udc_controller->gadget.is_otg = 1;
2569 2570
2570 /* setup QH and epctrl for ep0 */ 2571 /* setup QH and epctrl for ep0 */
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index 75ff41a5c959..9305de41af28 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -19,6 +19,7 @@
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/err.h>
22#include <linux/init.h> 23#include <linux/init.h>
23#include <linux/timer.h> 24#include <linux/timer.h>
24#include <linux/list.h> 25#include <linux/list.h>
@@ -1381,7 +1382,7 @@ static int mv_udc_start(struct usb_gadget_driver *driver,
1381 return retval; 1382 return retval;
1382 } 1383 }
1383 1384
1384 if (udc->transceiver) { 1385 if (!IS_ERR_OR_NULL(udc->transceiver)) {
1385 retval = otg_set_peripheral(udc->transceiver->otg, 1386 retval = otg_set_peripheral(udc->transceiver->otg,
1386 &udc->gadget); 1387 &udc->gadget);
1387 if (retval) { 1388 if (retval) {
@@ -2107,7 +2108,7 @@ static int __devexit mv_udc_remove(struct platform_device *dev)
2107 * then vbus irq will not be requested in udc driver. 2108 * then vbus irq will not be requested in udc driver.
2108 */ 2109 */
2109 if (udc->pdata && udc->pdata->vbus 2110 if (udc->pdata && udc->pdata->vbus
2110 && udc->clock_gating && udc->transceiver == NULL) 2111 && udc->clock_gating && IS_ERR_OR_NULL(udc->transceiver))
2111 free_irq(udc->pdata->vbus->irq, &dev->dev); 2112 free_irq(udc->pdata->vbus->irq, &dev->dev);
2112 2113
2113 /* free memory allocated in probe */ 2114 /* free memory allocated in probe */
@@ -2325,7 +2326,7 @@ static int __devinit mv_udc_probe(struct platform_device *dev)
2325 eps_init(udc); 2326 eps_init(udc);
2326 2327
2327 /* VBUS detect: we can disable/enable clock on demand.*/ 2328 /* VBUS detect: we can disable/enable clock on demand.*/
2328 if (udc->transceiver) 2329 if (!IS_ERR_OR_NULL(udc->transceiver))
2329 udc->clock_gating = 1; 2330 udc->clock_gating = 1;
2330 else if (pdata->vbus) { 2331 else if (pdata->vbus) {
2331 udc->clock_gating = 1; 2332 udc->clock_gating = 1;
@@ -2369,7 +2370,7 @@ static int __devinit mv_udc_probe(struct platform_device *dev)
2369 2370
2370err_unregister: 2371err_unregister:
2371 if (udc->pdata && udc->pdata->vbus 2372 if (udc->pdata && udc->pdata->vbus
2372 && udc->clock_gating && udc->transceiver == NULL) 2373 && udc->clock_gating && IS_ERR_OR_NULL(udc->transceiver))
2373 free_irq(pdata->vbus->irq, &dev->dev); 2374 free_irq(pdata->vbus->irq, &dev->dev);
2374 device_unregister(&udc->gadget.dev); 2375 device_unregister(&udc->gadget.dev);
2375err_free_irq: 2376err_free_irq:
@@ -2404,7 +2405,7 @@ static int mv_udc_suspend(struct device *_dev)
2404 struct mv_udc *udc = the_controller; 2405 struct mv_udc *udc = the_controller;
2405 2406
2406 /* if OTG is enabled, the following will be done in OTG driver*/ 2407 /* if OTG is enabled, the following will be done in OTG driver*/
2407 if (udc->transceiver) 2408 if (!IS_ERR_OR_NULL(udc->transceiver))
2408 return 0; 2409 return 0;
2409 2410
2410 if (udc->pdata->vbus && udc->pdata->vbus->poll) 2411 if (udc->pdata->vbus && udc->pdata->vbus->poll)
@@ -2437,7 +2438,7 @@ static int mv_udc_resume(struct device *_dev)
2437 int retval; 2438 int retval;
2438 2439
2439 /* if OTG is enabled, the following will be done in OTG driver*/ 2440 /* if OTG is enabled, the following will be done in OTG driver*/
2440 if (udc->transceiver) 2441 if (!IS_ERR_OR_NULL(udc->transceiver))
2441 return 0; 2442 return 0;
2442 2443
2443 if (!udc->clock_gating) { 2444 if (!udc->clock_gating) {
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index cf8bf26f12ed..7b71295adf6f 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -35,6 +35,7 @@
35#include <linux/usb/otg.h> 35#include <linux/usb/otg.h>
36#include <linux/dma-mapping.h> 36#include <linux/dma-mapping.h>
37#include <linux/clk.h> 37#include <linux/clk.h>
38#include <linux/err.h>
38#include <linux/prefetch.h> 39#include <linux/prefetch.h>
39 40
40#include <asm/byteorder.h> 41#include <asm/byteorder.h>
@@ -1211,7 +1212,7 @@ static int omap_wakeup(struct usb_gadget *gadget)
1211 1212
1212 /* NOTE: non-OTG systems may use SRP TOO... */ 1213 /* NOTE: non-OTG systems may use SRP TOO... */
1213 } else if (!(udc->devstat & UDC_ATT)) { 1214 } else if (!(udc->devstat & UDC_ATT)) {
1214 if (udc->transceiver) 1215 if (!IS_ERR_OR_NULL(udc->transceiver))
1215 retval = otg_start_srp(udc->transceiver->otg); 1216 retval = otg_start_srp(udc->transceiver->otg);
1216 } 1217 }
1217 spin_unlock_irqrestore(&udc->lock, flags); 1218 spin_unlock_irqrestore(&udc->lock, flags);
@@ -1343,7 +1344,7 @@ static int omap_vbus_draw(struct usb_gadget *gadget, unsigned mA)
1343 struct omap_udc *udc; 1344 struct omap_udc *udc;
1344 1345
1345 udc = container_of(gadget, struct omap_udc, gadget); 1346 udc = container_of(gadget, struct omap_udc, gadget);
1346 if (udc->transceiver) 1347 if (!IS_ERR_OR_NULL(udc->transceiver))
1347 return usb_phy_set_power(udc->transceiver, mA); 1348 return usb_phy_set_power(udc->transceiver, mA);
1348 return -EOPNOTSUPP; 1349 return -EOPNOTSUPP;
1349} 1350}
@@ -1792,12 +1793,12 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src)
1792 if (devstat & UDC_ATT) { 1793 if (devstat & UDC_ATT) {
1793 udc->gadget.speed = USB_SPEED_FULL; 1794 udc->gadget.speed = USB_SPEED_FULL;
1794 VDBG("connect\n"); 1795 VDBG("connect\n");
1795 if (!udc->transceiver) 1796 if (IS_ERR_OR_NULL(udc->transceiver))
1796 pullup_enable(udc); 1797 pullup_enable(udc);
1797 // if (driver->connect) call it 1798 // if (driver->connect) call it
1798 } else if (udc->gadget.speed != USB_SPEED_UNKNOWN) { 1799 } else if (udc->gadget.speed != USB_SPEED_UNKNOWN) {
1799 udc->gadget.speed = USB_SPEED_UNKNOWN; 1800 udc->gadget.speed = USB_SPEED_UNKNOWN;
1800 if (!udc->transceiver) 1801 if (IS_ERR_OR_NULL(udc->transceiver))
1801 pullup_disable(udc); 1802 pullup_disable(udc);
1802 DBG("disconnect, gadget %s\n", 1803 DBG("disconnect, gadget %s\n",
1803 udc->driver->driver.name); 1804 udc->driver->driver.name);
@@ -1837,12 +1838,12 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src)
1837 udc->driver->suspend(&udc->gadget); 1838 udc->driver->suspend(&udc->gadget);
1838 spin_lock(&udc->lock); 1839 spin_lock(&udc->lock);
1839 } 1840 }
1840 if (udc->transceiver) 1841 if (!IS_ERR_OR_NULL(udc->transceiver))
1841 usb_phy_set_suspend( 1842 usb_phy_set_suspend(
1842 udc->transceiver, 1); 1843 udc->transceiver, 1);
1843 } else { 1844 } else {
1844 VDBG("resume\n"); 1845 VDBG("resume\n");
1845 if (udc->transceiver) 1846 if (!IS_ERR_OR_NULL(udc->transceiver))
1846 usb_phy_set_suspend( 1847 usb_phy_set_suspend(
1847 udc->transceiver, 0); 1848 udc->transceiver, 0);
1848 if (udc->gadget.speed == USB_SPEED_FULL 1849 if (udc->gadget.speed == USB_SPEED_FULL
@@ -2154,7 +2155,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver,
2154 omap_writew(UDC_IRQ_SRC_MASK, UDC_IRQ_SRC); 2155 omap_writew(UDC_IRQ_SRC_MASK, UDC_IRQ_SRC);
2155 2156
2156 /* connect to bus through transceiver */ 2157 /* connect to bus through transceiver */
2157 if (udc->transceiver) { 2158 if (!IS_ERR_OR_NULL(udc->transceiver)) {
2158 status = otg_set_peripheral(udc->transceiver->otg, 2159 status = otg_set_peripheral(udc->transceiver->otg,
2159 &udc->gadget); 2160 &udc->gadget);
2160 if (status < 0) { 2161 if (status < 0) {
@@ -2201,7 +2202,7 @@ static int omap_udc_stop(struct usb_gadget_driver *driver)
2201 if (machine_without_vbus_sense()) 2202 if (machine_without_vbus_sense())
2202 omap_vbus_session(&udc->gadget, 0); 2203 omap_vbus_session(&udc->gadget, 0);
2203 2204
2204 if (udc->transceiver) 2205 if (!IS_ERR_OR_NULL(udc->transceiver))
2205 (void) otg_set_peripheral(udc->transceiver->otg, NULL); 2206 (void) otg_set_peripheral(udc->transceiver->otg, NULL);
2206 else 2207 else
2207 pullup_disable(udc); 2208 pullup_disable(udc);
@@ -2866,7 +2867,7 @@ static int __init omap_udc_probe(struct platform_device *pdev)
2866 * but not having one probably means no VBUS detection. 2867 * but not having one probably means no VBUS detection.
2867 */ 2868 */
2868 xceiv = usb_get_phy(USB_PHY_TYPE_USB2); 2869 xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
2869 if (xceiv) 2870 if (!IS_ERR_OR_NULL(xceiv))
2870 type = xceiv->label; 2871 type = xceiv->label;
2871 else if (config->otg) { 2872 else if (config->otg) {
2872 DBG("OTG requires external transceiver!\n"); 2873 DBG("OTG requires external transceiver!\n");
@@ -2898,7 +2899,7 @@ static int __init omap_udc_probe(struct platform_device *pdev)
2898 case 16: 2899 case 16:
2899 case 19: 2900 case 19:
2900 case 25: 2901 case 25:
2901 if (!xceiv) { 2902 if (IS_ERR_OR_NULL(xceiv)) {
2902 DBG("external transceiver not registered!\n"); 2903 DBG("external transceiver not registered!\n");
2903 type = "unknown"; 2904 type = "unknown";
2904 } 2905 }
@@ -3010,7 +3011,7 @@ cleanup1:
3010 udc = NULL; 3011 udc = NULL;
3011 3012
3012cleanup0: 3013cleanup0:
3013 if (xceiv) 3014 if (!IS_ERR_OR_NULL(xceiv))
3014 usb_put_phy(xceiv); 3015 usb_put_phy(xceiv);
3015 3016
3016 if (cpu_is_omap16xx() || cpu_is_omap24xx() || cpu_is_omap7xx()) { 3017 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 udc->done = &done; 3041 udc->done = &done;
3041 3042
3042 pullup_disable(udc); 3043 pullup_disable(udc);
3043 if (udc->transceiver) { 3044 if (!IS_ERR_OR_NULL(udc->transceiver)) {
3044 usb_put_phy(udc->transceiver); 3045 usb_put_phy(udc->transceiver);
3045 udc->transceiver = NULL; 3046 udc->transceiver = NULL;
3046 } 3047 }
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index cc0b1e63dcab..fa8e93c2465f 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -21,6 +21,7 @@
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/errno.h> 23#include <linux/errno.h>
24#include <linux/err.h>
24#include <linux/delay.h> 25#include <linux/delay.h>
25#include <linux/slab.h> 26#include <linux/slab.h>
26#include <linux/init.h> 27#include <linux/init.h>
@@ -993,7 +994,7 @@ static int pxa25x_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
993 994
994 udc = container_of(_gadget, struct pxa25x_udc, gadget); 995 udc = container_of(_gadget, struct pxa25x_udc, gadget);
995 996
996 if (udc->transceiver) 997 if (!IS_ERR_OR_NULL(udc->transceiver))
997 return usb_phy_set_power(udc->transceiver, mA); 998 return usb_phy_set_power(udc->transceiver, mA);
998 return -EOPNOTSUPP; 999 return -EOPNOTSUPP;
999} 1000}
@@ -1299,7 +1300,7 @@ fail:
1299 DMSG("registered gadget driver '%s'\n", driver->driver.name); 1300 DMSG("registered gadget driver '%s'\n", driver->driver.name);
1300 1301
1301 /* connect to bus through transceiver */ 1302 /* connect to bus through transceiver */
1302 if (dev->transceiver) { 1303 if (!IS_ERR_OR_NULL(dev->transceiver)) {
1303 retval = otg_set_peripheral(dev->transceiver->otg, 1304 retval = otg_set_peripheral(dev->transceiver->otg,
1304 &dev->gadget); 1305 &dev->gadget);
1305 if (retval) { 1306 if (retval) {
@@ -1359,7 +1360,7 @@ static int pxa25x_stop(struct usb_gadget_driver *driver)
1359 stop_activity(dev, driver); 1360 stop_activity(dev, driver);
1360 local_irq_enable(); 1361 local_irq_enable();
1361 1362
1362 if (dev->transceiver) 1363 if (!IS_ERR_OR_NULL(dev->transceiver))
1363 (void) otg_set_peripheral(dev->transceiver->otg, NULL); 1364 (void) otg_set_peripheral(dev->transceiver->otg, NULL);
1364 1365
1365 driver->unbind(&dev->gadget); 1366 driver->unbind(&dev->gadget);
@@ -2237,7 +2238,7 @@ lubbock_fail0:
2237 if (gpio_is_valid(dev->mach->gpio_pullup)) 2238 if (gpio_is_valid(dev->mach->gpio_pullup))
2238 gpio_free(dev->mach->gpio_pullup); 2239 gpio_free(dev->mach->gpio_pullup);
2239 err_gpio_pullup: 2240 err_gpio_pullup:
2240 if (dev->transceiver) { 2241 if (!IS_ERR_OR_NULL(dev->transceiver)) {
2241 usb_put_phy(dev->transceiver); 2242 usb_put_phy(dev->transceiver);
2242 dev->transceiver = NULL; 2243 dev->transceiver = NULL;
2243 } 2244 }
@@ -2279,7 +2280,7 @@ static int __exit pxa25x_udc_remove(struct platform_device *pdev)
2279 2280
2280 clk_put(dev->clk); 2281 clk_put(dev->clk);
2281 2282
2282 if (dev->transceiver) { 2283 if (!IS_ERR_OR_NULL(dev->transceiver)) {
2283 usb_put_phy(dev->transceiver); 2284 usb_put_phy(dev->transceiver);
2284 dev->transceiver = NULL; 2285 dev->transceiver = NULL;
2285 } 2286 }
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 8f744aab9628..644b4305cb99 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -13,6 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/err.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
17#include <linux/delay.h> 18#include <linux/delay.h>
18#include <linux/list.h> 19#include <linux/list.h>
@@ -1573,7 +1574,7 @@ static int should_enable_udc(struct pxa_udc *udc)
1573 int put_on; 1574 int put_on;
1574 1575
1575 put_on = ((udc->pullup_on) && (udc->driver)); 1576 put_on = ((udc->pullup_on) && (udc->driver));
1576 put_on &= ((udc->vbus_sensed) || (!udc->transceiver)); 1577 put_on &= ((udc->vbus_sensed) || (IS_ERR_OR_NULL(udc->transceiver)));
1577 return put_on; 1578 return put_on;
1578} 1579}
1579 1580
@@ -1594,7 +1595,7 @@ static int should_disable_udc(struct pxa_udc *udc)
1594 int put_off; 1595 int put_off;
1595 1596
1596 put_off = ((!udc->pullup_on) || (!udc->driver)); 1597 put_off = ((!udc->pullup_on) || (!udc->driver));
1597 put_off |= ((!udc->vbus_sensed) && (udc->transceiver)); 1598 put_off |= ((!udc->vbus_sensed) && (!IS_ERR_OR_NULL(udc->transceiver)));
1598 return put_off; 1599 return put_off;
1599} 1600}
1600 1601
@@ -1665,7 +1666,7 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
1665 struct pxa_udc *udc; 1666 struct pxa_udc *udc;
1666 1667
1667 udc = to_gadget_udc(_gadget); 1668 udc = to_gadget_udc(_gadget);
1668 if (udc->transceiver) 1669 if (!IS_ERR_OR_NULL(udc->transceiver))
1669 return usb_phy_set_power(udc->transceiver, mA); 1670 return usb_phy_set_power(udc->transceiver, mA);
1670 return -EOPNOTSUPP; 1671 return -EOPNOTSUPP;
1671} 1672}
@@ -1834,7 +1835,7 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver,
1834 dev_dbg(udc->dev, "registered gadget driver '%s'\n", 1835 dev_dbg(udc->dev, "registered gadget driver '%s'\n",
1835 driver->driver.name); 1836 driver->driver.name);
1836 1837
1837 if (udc->transceiver) { 1838 if (!IS_ERR_OR_NULL(udc->transceiver)) {
1838 retval = otg_set_peripheral(udc->transceiver->otg, 1839 retval = otg_set_peripheral(udc->transceiver->otg,
1839 &udc->gadget); 1840 &udc->gadget);
1840 if (retval) { 1841 if (retval) {
@@ -1908,7 +1909,7 @@ static int pxa27x_udc_stop(struct usb_gadget_driver *driver)
1908 dev_info(udc->dev, "unregistered gadget driver '%s'\n", 1909 dev_info(udc->dev, "unregistered gadget driver '%s'\n",
1909 driver->driver.name); 1910 driver->driver.name);
1910 1911
1911 if (udc->transceiver) 1912 if (!IS_ERR_OR_NULL(udc->transceiver))
1912 return otg_set_peripheral(udc->transceiver->otg, NULL); 1913 return otg_set_peripheral(udc->transceiver->otg, NULL);
1913 return 0; 1914 return 0;
1914} 1915}
diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c
index 22326f274466..7c915625f240 100644
--- a/drivers/usb/gadget/s3c-hsudc.c
+++ b/drivers/usb/gadget/s3c-hsudc.c
@@ -24,6 +24,7 @@
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/clk.h> 26#include <linux/clk.h>
27#include <linux/err.h>
27#include <linux/usb/ch9.h> 28#include <linux/usb/ch9.h>
28#include <linux/usb/gadget.h> 29#include <linux/usb/gadget.h>
29#include <linux/usb/otg.h> 30#include <linux/usb/otg.h>
@@ -1165,7 +1166,7 @@ static int s3c_hsudc_start(struct usb_gadget *gadget,
1165 } 1166 }
1166 1167
1167 /* connect to bus through transceiver */ 1168 /* connect to bus through transceiver */
1168 if (hsudc->transceiver) { 1169 if (!IS_ERR_OR_NULL(hsudc->transceiver)) {
1169 ret = otg_set_peripheral(hsudc->transceiver->otg, 1170 ret = otg_set_peripheral(hsudc->transceiver->otg,
1170 &hsudc->gadget); 1171 &hsudc->gadget);
1171 if (ret) { 1172 if (ret) {
@@ -1220,7 +1221,7 @@ static int s3c_hsudc_stop(struct usb_gadget *gadget,
1220 s3c_hsudc_stop_activity(hsudc); 1221 s3c_hsudc_stop_activity(hsudc);
1221 spin_unlock_irqrestore(&hsudc->lock, flags); 1222 spin_unlock_irqrestore(&hsudc->lock, flags);
1222 1223
1223 if (hsudc->transceiver) 1224 if (!IS_ERR_OR_NULL(hsudc->transceiver))
1224 (void) otg_set_peripheral(hsudc->transceiver->otg, NULL); 1225 (void) otg_set_peripheral(hsudc->transceiver->otg, NULL);
1225 1226
1226 disable_irq(hsudc->irq); 1227 disable_irq(hsudc->irq);
@@ -1249,7 +1250,7 @@ static int s3c_hsudc_vbus_draw(struct usb_gadget *gadget, unsigned mA)
1249 if (!hsudc) 1250 if (!hsudc)
1250 return -ENODEV; 1251 return -ENODEV;
1251 1252
1252 if (hsudc->transceiver) 1253 if (!IS_ERR_OR_NULL(hsudc->transceiver))
1253 return usb_phy_set_power(hsudc->transceiver, mA); 1254 return usb_phy_set_power(hsudc->transceiver, mA);
1254 1255
1255 return -EOPNOTSUPP; 1256 return -EOPNOTSUPP;
@@ -1385,7 +1386,7 @@ err_irq:
1385err_remap: 1386err_remap:
1386 release_mem_region(res->start, resource_size(res)); 1387 release_mem_region(res->start, resource_size(res));
1387err_res: 1388err_res:
1388 if (hsudc->transceiver) 1389 if (!IS_ERR_OR_NULL(hsudc->transceiver))
1389 usb_put_phy(hsudc->transceiver); 1390 usb_put_phy(hsudc->transceiver);
1390 1391
1391 regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); 1392 regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies);
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index ba290589d858..32865a7145a8 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -27,6 +27,7 @@
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/pm.h> 29#include <linux/pm.h>
30#include <linux/err.h>
30#include <linux/platform_device.h> 31#include <linux/platform_device.h>
31#include <linux/fsl_devices.h> 32#include <linux/fsl_devices.h>
32 33
@@ -146,7 +147,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
146 dev_dbg(&pdev->dev, "hcd=0x%p ehci=0x%p, transceiver=0x%p\n", 147 dev_dbg(&pdev->dev, "hcd=0x%p ehci=0x%p, transceiver=0x%p\n",
147 hcd, ehci, ehci->transceiver); 148 hcd, ehci, ehci->transceiver);
148 149
149 if (ehci->transceiver) { 150 if (!IS_ERR_OR_NULL(ehci->transceiver)) {
150 retval = otg_set_host(ehci->transceiver->otg, 151 retval = otg_set_host(ehci->transceiver->otg,
151 &ehci_to_hcd(ehci)->self); 152 &ehci_to_hcd(ehci)->self);
152 if (retval) { 153 if (retval) {
@@ -192,7 +193,7 @@ static void usb_hcd_fsl_remove(struct usb_hcd *hcd,
192 struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; 193 struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
193 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 194 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
194 195
195 if (ehci->transceiver) { 196 if (!IS_ERR_OR_NULL(ehci->transceiver)) {
196 otg_set_host(ehci->transceiver->otg, NULL); 197 otg_set_host(ehci->transceiver->otg, NULL);
197 usb_put_phy(ehci->transceiver); 198 usb_put_phy(ehci->transceiver);
198 } 199 }
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index c7615fb93dbb..6b4ffb598db1 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -146,7 +146,7 @@ static int ehci_msm_probe(struct platform_device *pdev)
146 * management. 146 * management.
147 */ 147 */
148 phy = usb_get_phy(USB_PHY_TYPE_USB2); 148 phy = usb_get_phy(USB_PHY_TYPE_USB2);
149 if (!phy) { 149 if (IS_ERR_OR_NULL(phy)) {
150 dev_err(&pdev->dev, "unable to find transceiver\n"); 150 dev_err(&pdev->dev, "unable to find transceiver\n");
151 ret = -ENODEV; 151 ret = -ENODEV;
152 goto unmap; 152 goto unmap;
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index ef7aa0df40a6..0e8c168ca24c 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -13,6 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/clk.h> 15#include <linux/clk.h>
16#include <linux/err.h>
16#include <linux/usb/otg.h> 17#include <linux/usb/otg.h>
17#include <linux/platform_data/mv_usb.h> 18#include <linux/platform_data/mv_usb.h>
18 19
@@ -254,7 +255,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
254 if (ehci_mv->mode == MV_USB_MODE_OTG) { 255 if (ehci_mv->mode == MV_USB_MODE_OTG) {
255#ifdef CONFIG_USB_OTG_UTILS 256#ifdef CONFIG_USB_OTG_UTILS
256 ehci_mv->otg = usb_get_phy(USB_PHY_TYPE_USB2); 257 ehci_mv->otg = usb_get_phy(USB_PHY_TYPE_USB2);
257 if (!ehci_mv->otg) { 258 if (IS_ERR_OR_NULL(ehci_mv->otg)) {
258 dev_err(&pdev->dev, 259 dev_err(&pdev->dev,
259 "unable to find transceiver\n"); 260 "unable to find transceiver\n");
260 retval = -ENODEV; 261 retval = -ENODEV;
@@ -302,7 +303,7 @@ err_set_vbus:
302 pdata->set_vbus(0); 303 pdata->set_vbus(0);
303#ifdef CONFIG_USB_OTG_UTILS 304#ifdef CONFIG_USB_OTG_UTILS
304err_put_transceiver: 305err_put_transceiver:
305 if (ehci_mv->otg) 306 if (!IS_ERR_OR_NULL(ehci_mv->otg))
306 usb_put_phy(ehci_mv->otg); 307 usb_put_phy(ehci_mv->otg);
307#endif 308#endif
308err_disable_clk: 309err_disable_clk:
@@ -331,7 +332,7 @@ static int mv_ehci_remove(struct platform_device *pdev)
331 if (hcd->rh_registered) 332 if (hcd->rh_registered)
332 usb_remove_hcd(hcd); 333 usb_remove_hcd(hcd);
333 334
334 if (ehci_mv->otg) { 335 if (!IS_ERR_OR_NULL(ehci_mv->otg)) {
335 otg_set_host(ehci_mv->otg->otg, NULL); 336 otg_set_host(ehci_mv->otg->otg, NULL);
336 usb_put_phy(ehci_mv->otg); 337 usb_put_phy(ehci_mv->otg);
337 } 338 }
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 14df2f5cf6ae..477ecfa05154 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <linux/clk.h> 19#include <linux/clk.h>
20#include <linux/err.h>
20#include <linux/platform_device.h> 21#include <linux/platform_device.h>
21#include <linux/platform_data/tegra_usb.h> 22#include <linux/platform_data/tegra_usb.h>
22#include <linux/irq.h> 23#include <linux/irq.h>
@@ -750,7 +751,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
750#ifdef CONFIG_USB_OTG_UTILS 751#ifdef CONFIG_USB_OTG_UTILS
751 if (pdata->operating_mode == TEGRA_USB_OTG) { 752 if (pdata->operating_mode == TEGRA_USB_OTG) {
752 tegra->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); 753 tegra->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
753 if (tegra->transceiver) 754 if (!IS_ERR_OR_NULL(tegra->transceiver))
754 otg_set_host(tegra->transceiver->otg, &hcd->self); 755 otg_set_host(tegra->transceiver->otg, &hcd->self);
755 } 756 }
756#endif 757#endif
@@ -773,7 +774,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
773 774
774fail: 775fail:
775#ifdef CONFIG_USB_OTG_UTILS 776#ifdef CONFIG_USB_OTG_UTILS
776 if (tegra->transceiver) { 777 if (!IS_ERR_OR_NULL(tegra->transceiver)) {
777 otg_set_host(tegra->transceiver->otg, NULL); 778 otg_set_host(tegra->transceiver->otg, NULL);
778 usb_put_phy(tegra->transceiver); 779 usb_put_phy(tegra->transceiver);
779 } 780 }
@@ -808,7 +809,7 @@ static int tegra_ehci_remove(struct platform_device *pdev)
808 pm_runtime_put_noidle(&pdev->dev); 809 pm_runtime_put_noidle(&pdev->dev);
809 810
810#ifdef CONFIG_USB_OTG_UTILS 811#ifdef CONFIG_USB_OTG_UTILS
811 if (tegra->transceiver) { 812 if (!IS_ERR_OR_NULL(tegra->transceiver)) {
812 otg_set_host(tegra->transceiver->otg, NULL); 813 otg_set_host(tegra->transceiver->otg, NULL);
813 usb_put_phy(tegra->transceiver); 814 usb_put_phy(tegra->transceiver);
814 } 815 }
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 92a77dfd1930..c7b06f504c60 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -18,6 +18,7 @@
18#include <linux/jiffies.h> 18#include <linux/jiffies.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/err.h>
21#include <linux/gpio.h> 22#include <linux/gpio.h>
22 23
23#include <mach/hardware.h> 24#include <mach/hardware.h>
@@ -212,7 +213,7 @@ static int ohci_omap_init(struct usb_hcd *hcd)
212#ifdef CONFIG_USB_OTG 213#ifdef CONFIG_USB_OTG
213 if (need_transceiver) { 214 if (need_transceiver) {
214 ohci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2); 215 ohci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
215 if (ohci->transceiver) { 216 if (!IS_ERR_OR_NULL(ohci->transceiver)) {
216 int status = otg_set_host(ohci->transceiver->otg, 217 int status = otg_set_host(ohci->transceiver->otg,
217 &ohci_to_hcd(ohci)->self); 218 &ohci_to_hcd(ohci)->self);
218 dev_dbg(hcd->self.controller, "init %s transceiver, status %d\n", 219 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 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 404 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
404 405
405 usb_remove_hcd(hcd); 406 usb_remove_hcd(hcd);
406 if (ohci->transceiver) { 407 if (!IS_ERR_OR_NULL(ohci->transceiver)) {
407 (void) otg_set_host(ohci->transceiver->otg, 0); 408 (void) otg_set_host(ohci->transceiver->otg, 0);
408 usb_put_phy(ohci->transceiver); 409 usb_put_phy(ohci->transceiver);
409 } 410 }
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 4a8cbf0e8d51..7a95ab87ac00 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -29,6 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/clk.h> 31#include <linux/clk.h>
32#include <linux/err.h>
32#include <linux/io.h> 33#include <linux/io.h>
33#include <linux/platform_device.h> 34#include <linux/platform_device.h>
34#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
@@ -365,7 +366,7 @@ static int am35x_musb_init(struct musb *musb)
365 366
366 usb_nop_xceiv_register(); 367 usb_nop_xceiv_register();
367 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); 368 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
368 if (!musb->xceiv) 369 if (IS_ERR_OR_NULL(musb->xceiv))
369 return -ENODEV; 370 return -ENODEV;
370 371
371 if (is_host_enabled(musb)) 372 if (is_host_enabled(musb))
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index 452940986d6d..428e6aa3e78a 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -15,6 +15,7 @@
15#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/err.h>
18#include <linux/platform_device.h> 19#include <linux/platform_device.h>
19#include <linux/dma-mapping.h> 20#include <linux/dma-mapping.h>
20#include <linux/prefetch.h> 21#include <linux/prefetch.h>
@@ -416,7 +417,7 @@ static int bfin_musb_init(struct musb *musb)
416 417
417 usb_nop_xceiv_register(); 418 usb_nop_xceiv_register();
418 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); 419 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
419 if (!musb->xceiv) { 420 if (IS_ERR_OR_NULL(musb->xceiv)) {
420 gpio_free(musb->config->gpio_vrsel); 421 gpio_free(musb->config->gpio_vrsel);
421 return -ENODEV; 422 return -ENODEV;
422 } 423 }
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index d731c80c4fef..0f9fcec4e1d3 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -29,6 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/clk.h> 31#include <linux/clk.h>
32#include <linux/err.h>
32#include <linux/io.h> 33#include <linux/io.h>
33#include <linux/platform_device.h> 34#include <linux/platform_device.h>
34#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
@@ -426,7 +427,7 @@ static int da8xx_musb_init(struct musb *musb)
426 427
427 usb_nop_xceiv_register(); 428 usb_nop_xceiv_register();
428 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); 429 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
429 if (!musb->xceiv) 430 if (IS_ERR_OR_NULL(musb->xceiv))
430 goto fail; 431 goto fail;
431 432
432 if (is_host_enabled(musb)) 433 if (is_host_enabled(musb))
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index 582268de3fa2..f6492043655e 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -28,6 +28,7 @@
28#include <linux/list.h> 28#include <linux/list.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/clk.h> 30#include <linux/clk.h>
31#include <linux/err.h>
31#include <linux/io.h> 32#include <linux/io.h>
32#include <linux/gpio.h> 33#include <linux/gpio.h>
33#include <linux/platform_device.h> 34#include <linux/platform_device.h>
@@ -385,7 +386,7 @@ static int davinci_musb_init(struct musb *musb)
385 386
386 usb_nop_xceiv_register(); 387 usb_nop_xceiv_register();
387 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); 388 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
388 if (!musb->xceiv) 389 if (IS_ERR_OR_NULL(musb->xceiv))
389 goto unregister; 390 goto unregister;
390 391
391 musb->mregs += DAVINCI_BASE_OFFSET; 392 musb->mregs += DAVINCI_BASE_OFFSET;
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 92603e498e61..217808d9fbe1 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -31,6 +31,7 @@
31 31
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/io.h> 33#include <linux/io.h>
34#include <linux/err.h>
34#include <linux/platform_device.h> 35#include <linux/platform_device.h>
35#include <linux/dma-mapping.h> 36#include <linux/dma-mapping.h>
36#include <linux/pm_runtime.h> 37#include <linux/pm_runtime.h>
@@ -377,7 +378,7 @@ static int dsps_musb_init(struct musb *musb)
377 /* NOP driver needs change if supporting dual instance */ 378 /* NOP driver needs change if supporting dual instance */
378 usb_nop_xceiv_register(); 379 usb_nop_xceiv_register();
379 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); 380 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
380 if (!musb->xceiv) 381 if (IS_ERR_OR_NULL(musb->xceiv))
381 return -ENODEV; 382 return -ENODEV;
382 383
383 /* Returns zero if e.g. not clocked */ 384 /* Returns zero if e.g. not clocked */
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 2813490ba631..5fdb9da8dd56 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -320,7 +320,7 @@ static int omap2430_musb_init(struct musb *musb)
320 * which needs a driver, drivers aren't always needed. 320 * which needs a driver, drivers aren't always needed.
321 */ 321 */
322 musb->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); 322 musb->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
323 if (!musb->xceiv) { 323 if (IS_ERR_OR_NULL(musb->xceiv)) {
324 pr_err("HS USB OTG: no transceiver configured\n"); 324 pr_err("HS USB OTG: no transceiver configured\n");
325 return -ENODEV; 325 return -ENODEV;
326 } 326 }
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 8ddf3d5f7cdc..1a1bd9cf40c5 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -17,6 +17,7 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/err.h>
20#include <linux/init.h> 21#include <linux/init.h>
21#include <linux/prefetch.h> 22#include <linux/prefetch.h>
22#include <linux/usb.h> 23#include <linux/usb.h>
@@ -1079,7 +1080,7 @@ static int tusb_musb_init(struct musb *musb)
1079 1080
1080 usb_nop_xceiv_register(); 1081 usb_nop_xceiv_register();
1081 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); 1082 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
1082 if (!musb->xceiv) 1083 if (IS_ERR_OR_NULL(musb->xceiv))
1083 return -ENODEV; 1084 return -ENODEV;
1084 1085
1085 pdev = to_platform_device(musb->controller); 1086 pdev = to_platform_device(musb->controller);
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 46cf80a8cacd..a8c0fadce1b0 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -23,6 +23,7 @@
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/clk.h> 25#include <linux/clk.h>
26#include <linux/err.h>
26#include <linux/io.h> 27#include <linux/io.h>
27#include <linux/platform_device.h> 28#include <linux/platform_device.h>
28 29
@@ -38,7 +39,7 @@ struct ux500_glue {
38static int ux500_musb_init(struct musb *musb) 39static int ux500_musb_init(struct musb *musb)
39{ 40{
40 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); 41 musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
41 if (!musb->xceiv) { 42 if (IS_ERR_OR_NULL(musb->xceiv)) {
42 pr_err("HS USB OTG: no transceiver configured\n"); 43 pr_err("HS USB OTG: no transceiver configured\n");
43 return -ENODEV; 44 return -ENODEV;
44 } 45 }
diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index 0fa4d8c1b1e8..88d62b16f632 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -67,7 +67,7 @@ struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type)
67 return NULL; 67 return NULL;
68 68
69 phy = usb_get_phy(type); 69 phy = usb_get_phy(type);
70 if (phy) { 70 if (!IS_ERR(phy)) {
71 *ptr = phy; 71 *ptr = phy;
72 devres_add(dev, ptr); 72 devres_add(dev, ptr);
73 } else 73 } else
@@ -82,7 +82,7 @@ EXPORT_SYMBOL(devm_usb_get_phy);
82 * @type - the type of the phy the controller requires 82 * @type - the type of the phy the controller requires
83 * 83 *
84 * Returns the phy driver, after getting a refcount to it; or 84 * Returns the phy driver, after getting a refcount to it; or
85 * null if there is no such phy. The caller is responsible for 85 * -ENODEV if there is no such phy. The caller is responsible for
86 * calling usb_put_phy() to release that count. 86 * calling usb_put_phy() to release that count.
87 * 87 *
88 * For use by USB host and peripheral drivers. 88 * For use by USB host and peripheral drivers.