diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2011-06-29 09:41:54 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-07-01 17:27:07 -0400 |
commit | e4fe056ed3a350ec569aa25014a0982883bc03c1 (patch) | |
tree | f687114b484e9e33e12dffbac288352814bc761c /drivers/usb/gadget/net2272.c | |
parent | 7eca4c5a8b73f22ad16ad6e76b901351732355da (diff) |
usb: gadget: net2272: cleanup pci_register_driver() error path
In case pci_register_driver() fails it error will be 0 in case
platform_driver_register() was fine. Also without PCI
pci_register_driver() evaluates to 1 which is well, special. If
platform_driver_register() returns EINVAL or EBUSY we end up with 0.
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/net2272.c')
-rw-r--r-- | drivers/usb/gadget/net2272.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/drivers/usb/gadget/net2272.c b/drivers/usb/gadget/net2272.c index 7f1219e239a3..739f564f2523 100644 --- a/drivers/usb/gadget/net2272.c +++ b/drivers/usb/gadget/net2272.c | |||
@@ -2611,9 +2611,19 @@ static struct pci_driver net2272_pci_driver = { | |||
2611 | .remove = __devexit_p(net2272_pci_remove), | 2611 | .remove = __devexit_p(net2272_pci_remove), |
2612 | }; | 2612 | }; |
2613 | 2613 | ||
2614 | static int net2272_pci_register(void) | ||
2615 | { | ||
2616 | return pci_register_driver(&net2272_pci_driver); | ||
2617 | } | ||
2618 | |||
2619 | static void net2272_pci_unregister(void) | ||
2620 | { | ||
2621 | pci_unregister_driver(&net2272_pci_driver); | ||
2622 | } | ||
2623 | |||
2614 | #else | 2624 | #else |
2615 | # define pci_register_driver(x) 1 | 2625 | static inline int net2272_pci_register(void) { return 0; } |
2616 | # define pci_unregister_driver(x) 1 | 2626 | static inline void net2272_pci_unregister(void) { } |
2617 | #endif | 2627 | #endif |
2618 | 2628 | ||
2619 | /*---------------------------------------------------------------------------*/ | 2629 | /*---------------------------------------------------------------------------*/ |
@@ -2713,14 +2723,25 @@ static struct platform_driver net2272_plat_driver = { | |||
2713 | 2723 | ||
2714 | static int __init net2272_init(void) | 2724 | static int __init net2272_init(void) |
2715 | { | 2725 | { |
2716 | return pci_register_driver(&net2272_pci_driver) & | 2726 | int ret; |
2717 | platform_driver_register(&net2272_plat_driver); | 2727 | |
2728 | ret = net2272_pci_register(); | ||
2729 | if (ret) | ||
2730 | return ret; | ||
2731 | ret = platform_driver_register(&net2272_plat_driver); | ||
2732 | if (ret) | ||
2733 | goto err_pci; | ||
2734 | return ret; | ||
2735 | |||
2736 | err_pci: | ||
2737 | net2272_pci_unregister(); | ||
2738 | return ret; | ||
2718 | } | 2739 | } |
2719 | module_init(net2272_init); | 2740 | module_init(net2272_init); |
2720 | 2741 | ||
2721 | static void __exit net2272_cleanup(void) | 2742 | static void __exit net2272_cleanup(void) |
2722 | { | 2743 | { |
2723 | pci_unregister_driver(&net2272_pci_driver); | 2744 | net2272_pci_unregister(); |
2724 | platform_driver_unregister(&net2272_plat_driver); | 2745 | platform_driver_unregister(&net2272_plat_driver); |
2725 | } | 2746 | } |
2726 | module_exit(net2272_cleanup); | 2747 | module_exit(net2272_cleanup); |