Commit 454dc590 authored by Ajay Singh's avatar Ajay Singh Committed by Greg Kroah-Hartman

staging: wilc1000: return exact error of register_netdev() from wilc_netdev_init()

Refactor wilc_netdev_init() to return the error code received from
register_netdev() during the failure condition.

Earlier discussion link
[1]. https://www.spinics.net/lists/linux-wireless/msg177304.htmlSuggested-by: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: default avatarAjay Singh <ajay.kathat@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ba853fe6
...@@ -1062,7 +1062,8 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, ...@@ -1062,7 +1062,8 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
if (!wl) if (!wl)
return -ENOMEM; return -ENOMEM;
if (wilc_wlan_cfg_init(wl)) ret = wilc_wlan_cfg_init(wl);
if (ret)
goto free_wl; goto free_wl;
*wilc = wl; *wilc = wl;
...@@ -1074,8 +1075,10 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, ...@@ -1074,8 +1075,10 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
INIT_LIST_HEAD(&wl->rxq_head.list); INIT_LIST_HEAD(&wl->rxq_head.list);
wl->hif_workqueue = create_singlethread_workqueue("WILC_wq"); wl->hif_workqueue = create_singlethread_workqueue("WILC_wq");
if (!wl->hif_workqueue) if (!wl->hif_workqueue) {
ret = -ENOMEM;
goto free_cfg; goto free_cfg;
}
register_inetaddr_notifier(&g_dev_notifier); register_inetaddr_notifier(&g_dev_notifier);
...@@ -1083,8 +1086,10 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, ...@@ -1083,8 +1086,10 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
struct wireless_dev *wdev; struct wireless_dev *wdev;
ndev = alloc_etherdev(sizeof(struct wilc_vif)); ndev = alloc_etherdev(sizeof(struct wilc_vif));
if (!ndev) if (!ndev) {
ret = -ENOMEM;
goto free_ndev; goto free_ndev;
}
vif = netdev_priv(ndev); vif = netdev_priv(ndev);
memset(vif, 0, sizeof(struct wilc_vif)); memset(vif, 0, sizeof(struct wilc_vif));
...@@ -1107,6 +1112,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, ...@@ -1107,6 +1112,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
wdev = wilc_create_wiphy(ndev, dev); wdev = wilc_create_wiphy(ndev, dev);
if (!wdev) { if (!wdev) {
netdev_err(ndev, "Can't register WILC Wiphy\n"); netdev_err(ndev, "Can't register WILC Wiphy\n");
ret = -ENOMEM;
goto free_ndev; goto free_ndev;
} }
...@@ -1148,7 +1154,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, ...@@ -1148,7 +1154,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
wilc_wlan_cfg_deinit(wl); wilc_wlan_cfg_deinit(wl);
free_wl: free_wl:
kfree(wl); kfree(wl);
return -ENOMEM; return ret;
} }
EXPORT_SYMBOL_GPL(wilc_netdev_init); EXPORT_SYMBOL_GPL(wilc_netdev_init);
......
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