diff options
author | Kishon Vijay Abraham I <kishon@ti.com> | 2012-06-26 17:40:32 +0530 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-07-02 10:40:49 +0300 |
commit | ded017ee6c7b90f7356bd8488f8af1c10ba90490 (patch) | |
tree | 1ed1612aa13f24e1aa8480fb497d2a0311fae9cc /drivers/usb/host | |
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/host')
-rw-r--r-- | drivers/usb/host/ehci-fsl.c | 5 | ||||
-rw-r--r-- | drivers/usb/host/ehci-msm.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/ehci-mv.c | 7 | ||||
-rw-r--r-- | drivers/usb/host/ehci-tegra.c | 7 | ||||
-rw-r--r-- | drivers/usb/host/ohci-omap.c | 5 |
5 files changed, 15 insertions, 11 deletions
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 @@ #include <linux/types.h> #include <linux/delay.h> #include <linux/pm.h> +#include <linux/err.h> #include <linux/platform_device.h> #include <linux/fsl_devices.h> @@ -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", hcd, ehci, ehci->transceiver); - if (ehci->transceiver) { + if (!IS_ERR_OR_NULL(ehci->transceiver)) { retval = otg_set_host(ehci->transceiver->otg, &ehci_to_hcd(ehci)->self); if (retval) { @@ -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 ehci_hcd *ehci = hcd_to_ehci(hcd); - if (ehci->transceiver) { + if (!IS_ERR_OR_NULL(ehci->transceiver)) { otg_set_host(ehci->transceiver->otg, NULL); usb_put_phy(ehci->transceiver); } 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) * management. */ 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"); ret = -ENODEV; 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 @@ #include <linux/module.h> #include <linux/platform_device.h> #include <linux/clk.h> +#include <linux/err.h> #include <linux/usb/otg.h> #include <linux/platform_data/mv_usb.h> @@ -254,7 +255,7 @@ static int mv_ehci_probe(struct platform_device *pdev) if (ehci_mv->mode == MV_USB_MODE_OTG) { #ifdef CONFIG_USB_OTG_UTILS 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, "unable to find transceiver\n"); retval = -ENODEV; @@ -302,7 +303,7 @@ err_set_vbus: pdata->set_vbus(0); #ifdef CONFIG_USB_OTG_UTILS err_put_transceiver: - if (ehci_mv->otg) + if (!IS_ERR_OR_NULL(ehci_mv->otg)) usb_put_phy(ehci_mv->otg); #endif err_disable_clk: @@ -331,7 +332,7 @@ static int mv_ehci_remove(struct platform_device *pdev) if (hcd->rh_registered) usb_remove_hcd(hcd); - if (ehci_mv->otg) { + if (!IS_ERR_OR_NULL(ehci_mv->otg)) { otg_set_host(ehci_mv->otg->otg, NULL); usb_put_phy(ehci_mv->otg); } 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 @@ */ #include <linux/clk.h> +#include <linux/err.h> #include <linux/platform_device.h> #include <linux/platform_data/tegra_usb.h> #include <linux/irq.h> @@ -750,7 +751,7 @@ static int tegra_ehci_probe(struct platform_device *pdev) #ifdef CONFIG_USB_OTG_UTILS if (pdata->operating_mode == TEGRA_USB_OTG) { 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); } #endif @@ -773,7 +774,7 @@ static int tegra_ehci_probe(struct platform_device *pdev) fail: #ifdef CONFIG_USB_OTG_UTILS - if (tegra->transceiver) { + if (!IS_ERR_OR_NULL(tegra->transceiver)) { otg_set_host(tegra->transceiver->otg, NULL); usb_put_phy(tegra->transceiver); } @@ -808,7 +809,7 @@ static int tegra_ehci_remove(struct platform_device *pdev) pm_runtime_put_noidle(&pdev->dev); #ifdef CONFIG_USB_OTG_UTILS - if (tegra->transceiver) { + if (!IS_ERR_OR_NULL(tegra->transceiver)) { otg_set_host(tegra->transceiver->otg, NULL); usb_put_phy(tegra->transceiver); } 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 @@ #include <linux/jiffies.h> #include <linux/platform_device.h> #include <linux/clk.h> +#include <linux/err.h> #include <linux/gpio.h> #include <mach/hardware.h> @@ -212,7 +213,7 @@ static int ohci_omap_init(struct usb_hcd *hcd) #ifdef CONFIG_USB_OTG if (need_transceiver) { 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, &ohci_to_hcd(ohci)->self); 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) struct ohci_hcd *ohci = hcd_to_ohci (hcd); usb_remove_hcd(hcd); - if (ohci->transceiver) { + if (!IS_ERR_OR_NULL(ohci->transceiver)) { (void) otg_set_host(ohci->transceiver->otg, 0); usb_put_phy(ohci->transceiver); } |