diff options
author | Kishon Vijay Abraham I <kishon@ti.com> | 2012-06-26 08:10:32 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-07-02 03:40:49 -0400 |
commit | ded017ee6c7b90f7356bd8488f8af1c10ba90490 (patch) | |
tree | 1ed1612aa13f24e1aa8480fb497d2a0311fae9cc /drivers/usb/gadget | |
parent | b8a3efa3a363720687d21228d6b23b988a223bbb (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/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/fsl_udc_core.c | 15 | ||||
-rw-r--r-- | drivers/usb/gadget/mv_udc_core.c | 13 | ||||
-rw-r--r-- | drivers/usb/gadget/omap_udc.c | 25 | ||||
-rw-r--r-- | drivers/usb/gadget/pxa25x_udc.c | 11 | ||||
-rw-r--r-- | drivers/usb/gadget/pxa27x_udc.c | 11 | ||||
-rw-r--r-- | drivers/usb/gadget/s3c-hsudc.c | 9 |
6 files changed, 45 insertions, 39 deletions
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 | ||
2370 | err_unregister: | 2371 | err_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); |
2375 | err_free_irq: | 2376 | err_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 | ||
3012 | cleanup0: | 3013 | cleanup0: |
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: | |||
1385 | err_remap: | 1386 | err_remap: |
1386 | release_mem_region(res->start, resource_size(res)); | 1387 | release_mem_region(res->start, resource_size(res)); |
1387 | err_res: | 1388 | err_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); |