Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2689,7 +2689,7 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
	}

	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");
		ret = -EINVAL;
		goto free_usb;
+1 −1
Original line number Diff line number Diff line
@@ -416,7 +416,7 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
		return -ENOMEM;

	isp->phy = usb_get_phy(USB_PHY_TYPE_USB2);
	if (!isp->phy)
	if (IS_ERR_OR_NULL(isp->phy))
		goto fail0;

	isp->dev = &pdev->dev;
+8 −8
Original line number Diff line number Diff line
@@ -322,10 +322,10 @@ static int pda_power_probe(struct platform_device *pdev)

#ifdef CONFIG_USB_OTG_UTILS
	transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
	if (transceiver && !pdata->is_usb_online) {
	if (!IS_ERR_OR_NULL(transceiver)) {
		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;
	}
#endif
@@ -373,7 +373,7 @@ static int pda_power_probe(struct platform_device *pdev)
	}

#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;
		ret = usb_register_notifier(transceiver, &otg_nb);
		if (ret) {
@@ -408,7 +408,7 @@ static int pda_power_probe(struct platform_device *pdev)
	if (pdata->is_ac_online && ac_irq)
		free_irq(ac_irq->start, &pda_psy_ac);
#ifdef CONFIG_USB_OTG_UTILS
	if (transceiver)
	if (!IS_ERR_OR_NULL(transceiver))
		usb_put_phy(transceiver);
#endif
ac_irq_failed:
@@ -443,7 +443,7 @@ static int pda_power_remove(struct platform_device *pdev)
	if (pdata->is_ac_online)
		power_supply_unregister(&pda_psy_ac);
#ifdef CONFIG_USB_OTG_UTILS
	if (transceiver)
	if (!IS_ERR_OR_NULL(transceiver))
		usb_put_phy(transceiver);
#endif
	if (ac_draw) {
+4 −3
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
#include <linux/i2c/twl.h>
@@ -480,7 +481,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
	INIT_WORK(&bci->work, twl4030_bci_usb_work);

	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;
		usb_register_notifier(bci->transceiver, &bci->usb_nb);
	}
@@ -507,7 +508,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
	return 0;

fail_unmask_interrupts:
	if (bci->transceiver != NULL) {
	if (!IS_ERR_OR_NULL(bci->transceiver)) {
		usb_unregister_notifier(bci->transceiver, &bci->usb_nb);
		usb_put_phy(bci->transceiver);
	}
@@ -538,7 +539,7 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev)
	twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xff,
			 TWL4030_INTERRUPTS_BCIIMR2A);

	if (bci->transceiver != NULL) {
	if (!IS_ERR_OR_NULL(bci->transceiver)) {
		usb_unregister_notifier(bci->transceiver, &bci->usb_nb);
		usb_put_phy(bci->transceiver);
	}
+5 −4
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#include <linux/device.h>
#include <linux/dmapool.h>
#include <linux/dma-mapping.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/module.h>
@@ -1712,7 +1713,7 @@ static int udc_start(struct ci13xxx *udc)
	if (retval)
		goto unreg_device;

	if (udc->transceiver) {
	if (!IS_ERR_OR_NULL(udc->transceiver)) {
		retval = otg_set_peripheral(udc->transceiver->otg,
						&udc->gadget);
		if (retval)
@@ -1729,7 +1730,7 @@ static int udc_start(struct ci13xxx *udc)
	return retval;

remove_trans:
	if (udc->transceiver) {
	if (!IS_ERR_OR_NULL(udc->transceiver)) {
		otg_set_peripheral(udc->transceiver->otg, &udc->gadget);
		usb_put_phy(udc->transceiver);
	}
@@ -1740,7 +1741,7 @@ static int udc_start(struct ci13xxx *udc)
unreg_device:
	device_unregister(&udc->gadget.dev);
put_transceiver:
	if (udc->transceiver)
	if (!IS_ERR_OR_NULL(udc->transceiver))
		usb_put_phy(udc->transceiver);
free_pools:
	dma_pool_destroy(udc->td_pool);
@@ -1772,7 +1773,7 @@ static void udc_stop(struct ci13xxx *udc)
	dma_pool_destroy(udc->td_pool);
	dma_pool_destroy(udc->qh_pool);

	if (udc->transceiver) {
	if (!IS_ERR_OR_NULL(udc->transceiver)) {
		otg_set_peripheral(udc->transceiver->otg, NULL);
		usb_put_phy(udc->transceiver);
	}
Loading