aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
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/power
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/power')
-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
4 files changed, 14 insertions, 13 deletions
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index 6bd6f1c4196..d4f0c98428c 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 090e5f9e72c..122911978da 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 7602d49e4d8..8dbcd53c5e6 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 13f9db2e853..7cacbaa68ef 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 }