Commit e4fe056e authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Greg Kroah-Hartman

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: default avatarMike Frysinger <vapier@gentoo.org>
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7eca4c5a
...@@ -2611,9 +2611,19 @@ static struct pci_driver net2272_pci_driver = { ...@@ -2611,9 +2611,19 @@ static struct pci_driver net2272_pci_driver = {
.remove = __devexit_p(net2272_pci_remove), .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 #else
# define pci_register_driver(x) 1 static inline int net2272_pci_register(void) { return 0; }
# define pci_unregister_driver(x) 1 static inline void net2272_pci_unregister(void) { }
#endif #endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
...@@ -2713,14 +2723,25 @@ static struct platform_driver net2272_plat_driver = { ...@@ -2713,14 +2723,25 @@ static struct platform_driver net2272_plat_driver = {
static int __init net2272_init(void) static int __init net2272_init(void)
{ {
return pci_register_driver(&net2272_pci_driver) & int ret;
platform_driver_register(&net2272_plat_driver);
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); module_init(net2272_init);
static void __exit net2272_cleanup(void) static void __exit net2272_cleanup(void)
{ {
pci_unregister_driver(&net2272_pci_driver); net2272_pci_unregister();
platform_driver_unregister(&net2272_plat_driver); platform_driver_unregister(&net2272_plat_driver);
} }
module_exit(net2272_cleanup); module_exit(net2272_cleanup);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment