aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/main.c
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2012-05-05 07:27:28 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-06-18 12:01:03 -0400
commit5346c35ebfbdb1727e60079456dd8071cb888059 (patch)
tree90bba36cd5e27b1a248cf78d4a4859b6d7275092 /net/batman-adv/main.c
parente0f5211f9bbfaa66d27cda6b0dc86466c7dcb206 (diff)
batman-adv: Return error codes instead of -1 on failures
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/main.c')
-rw-r--r--net/batman-adv/main.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 8610b5caa178..46ba302d2d01 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -92,6 +92,7 @@ static void __exit batman_exit(void)
92int mesh_init(struct net_device *soft_iface) 92int mesh_init(struct net_device *soft_iface)
93{ 93{
94 struct bat_priv *bat_priv = netdev_priv(soft_iface); 94 struct bat_priv *bat_priv = netdev_priv(soft_iface);
95 int ret;
95 96
96 spin_lock_init(&bat_priv->forw_bat_list_lock); 97 spin_lock_init(&bat_priv->forw_bat_list_lock);
97 spin_lock_init(&bat_priv->forw_bcast_list_lock); 98 spin_lock_init(&bat_priv->forw_bcast_list_lock);
@@ -110,30 +111,32 @@ int mesh_init(struct net_device *soft_iface)
110 INIT_LIST_HEAD(&bat_priv->tt_req_list); 111 INIT_LIST_HEAD(&bat_priv->tt_req_list);
111 INIT_LIST_HEAD(&bat_priv->tt_roam_list); 112 INIT_LIST_HEAD(&bat_priv->tt_roam_list);
112 113
113 if (originator_init(bat_priv) < 1) 114 ret = originator_init(bat_priv);
115 if (ret < 0)
114 goto err; 116 goto err;
115 117
116 if (tt_init(bat_priv) < 1) 118 ret = tt_init(bat_priv);
119 if (ret < 0)
117 goto err; 120 goto err;
118 121
119 tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX); 122 tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX);
120 123
121 if (vis_init(bat_priv) < 1) 124 ret = vis_init(bat_priv);
125 if (ret < 0)
122 goto err; 126 goto err;
123 127
124 if (bla_init(bat_priv) < 1) 128 ret = bla_init(bat_priv);
129 if (ret < 0)
125 goto err; 130 goto err;
126 131
127 atomic_set(&bat_priv->gw_reselect, 0); 132 atomic_set(&bat_priv->gw_reselect, 0);
128 atomic_set(&bat_priv->mesh_state, MESH_ACTIVE); 133 atomic_set(&bat_priv->mesh_state, MESH_ACTIVE);
129 goto end; 134
135 return 0;
130 136
131err: 137err:
132 mesh_free(soft_iface); 138 mesh_free(soft_iface);
133 return -1; 139 return ret;
134
135end:
136 return 0;
137} 140}
138 141
139void mesh_free(struct net_device *soft_iface) 142void mesh_free(struct net_device *soft_iface)
@@ -319,12 +322,13 @@ static struct bat_algo_ops *bat_algo_get(char *name)
319int bat_algo_register(struct bat_algo_ops *bat_algo_ops) 322int bat_algo_register(struct bat_algo_ops *bat_algo_ops)
320{ 323{
321 struct bat_algo_ops *bat_algo_ops_tmp; 324 struct bat_algo_ops *bat_algo_ops_tmp;
322 int ret = -1; 325 int ret;
323 326
324 bat_algo_ops_tmp = bat_algo_get(bat_algo_ops->name); 327 bat_algo_ops_tmp = bat_algo_get(bat_algo_ops->name);
325 if (bat_algo_ops_tmp) { 328 if (bat_algo_ops_tmp) {
326 pr_info("Trying to register already registered routing algorithm: %s\n", 329 pr_info("Trying to register already registered routing algorithm: %s\n",
327 bat_algo_ops->name); 330 bat_algo_ops->name);
331 ret = -EEXIST;
328 goto out; 332 goto out;
329 } 333 }
330 334
@@ -337,6 +341,7 @@ int bat_algo_register(struct bat_algo_ops *bat_algo_ops)
337 !bat_algo_ops->bat_ogm_emit) { 341 !bat_algo_ops->bat_ogm_emit) {
338 pr_info("Routing algo '%s' does not implement required ops\n", 342 pr_info("Routing algo '%s' does not implement required ops\n",
339 bat_algo_ops->name); 343 bat_algo_ops->name);
344 ret = -EINVAL;
340 goto out; 345 goto out;
341 } 346 }
342 347
@@ -351,7 +356,7 @@ out:
351int bat_algo_select(struct bat_priv *bat_priv, char *name) 356int bat_algo_select(struct bat_priv *bat_priv, char *name)
352{ 357{
353 struct bat_algo_ops *bat_algo_ops; 358 struct bat_algo_ops *bat_algo_ops;
354 int ret = -1; 359 int ret = -EINVAL;
355 360
356 bat_algo_ops = bat_algo_get(name); 361 bat_algo_ops = bat_algo_get(name);
357 if (!bat_algo_ops) 362 if (!bat_algo_ops)