aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/omap_udc.c
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/usb/gadget/omap_udc.c
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/usb/gadget/omap_udc.c')
-rw-r--r--drivers/usb/gadget/omap_udc.c25
1 files changed, 13 insertions, 12 deletions
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 }