diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2011-06-29 16:41:54 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-07-01 14:27:07 -0700 |
commit | e4fe056ed3a350ec569aa25014a0982883bc03c1 (patch) | |
tree | f687114b484e9e33e12dffbac288352814bc761c /drivers/usb/gadget/net2272.c | |
parent | 7eca4c5a8b73f22ad16ad6e76b901351732355da (diff) | |
download | blackbird-op-linux-e4fe056ed3a350ec569aa25014a0982883bc03c1.tar.gz blackbird-op-linux-e4fe056ed3a350ec569aa25014a0982883bc03c1.zip |
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 = { .remove = __devexit_p(net2272_pci_remove), }; +static int net2272_pci_register(void) +{ + return pci_register_driver(&net2272_pci_driver); +} + +static void net2272_pci_unregister(void) +{ + pci_unregister_driver(&net2272_pci_driver); +} + #else -# define pci_register_driver(x) 1 -# define pci_unregister_driver(x) 1 +static inline int net2272_pci_register(void) { return 0; } +static inline void net2272_pci_unregister(void) { } #endif /*---------------------------------------------------------------------------*/ @@ -2713,14 +2723,25 @@ static struct platform_driver net2272_plat_driver = { static int __init net2272_init(void) { - return pci_register_driver(&net2272_pci_driver) & - platform_driver_register(&net2272_plat_driver); + int ret; + + ret = net2272_pci_register(); + if (ret) + return ret; + ret = platform_driver_register(&net2272_plat_driver); + if (ret) + goto err_pci; + return ret; + +err_pci: + net2272_pci_unregister(); + return ret; } module_init(net2272_init); static void __exit net2272_cleanup(void) { - pci_unregister_driver(&net2272_pci_driver); + net2272_pci_unregister(); platform_driver_unregister(&net2272_plat_driver); } module_exit(net2272_cleanup); |