diff options
author | Bob Copeland <me@bobcopeland.com> | 2013-03-29 09:38:39 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-04-08 03:16:59 -0400 |
commit | ae76eef027f75fadd8a8eda55ee07707f077aacb (patch) | |
tree | 996060a0166128480ad5e55244438cd16448fb99 /net/mac80211/cfg.c | |
parent | 0f71651f935d05557eac5862ff68dd2335b0ce0e (diff) |
mac80211: return new mpath from mesh_path_add()
Most times that mesh_path_add() is called, it is followed by
a lookup to get the just-added mpath. We can instead just
return the new mpath in the case that we allocated one (or the
existing one if already there), so do that. Also, reorder the
code in mesh_path_add a bit so that we don't need to allocate
in the pre-existing case.
Signed-off-by: Bob Copeland <bob@cozybit.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/cfg.c')
-rw-r--r-- | net/mac80211/cfg.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 6e43feb49a76..edca2a288abd 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -1540,7 +1540,6 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, | |||
1540 | struct ieee80211_sub_if_data *sdata; | 1540 | struct ieee80211_sub_if_data *sdata; |
1541 | struct mesh_path *mpath; | 1541 | struct mesh_path *mpath; |
1542 | struct sta_info *sta; | 1542 | struct sta_info *sta; |
1543 | int err; | ||
1544 | 1543 | ||
1545 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1544 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1546 | 1545 | ||
@@ -1551,17 +1550,12 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, | |||
1551 | return -ENOENT; | 1550 | return -ENOENT; |
1552 | } | 1551 | } |
1553 | 1552 | ||
1554 | err = mesh_path_add(sdata, dst); | 1553 | mpath = mesh_path_add(sdata, dst); |
1555 | if (err) { | 1554 | if (IS_ERR(mpath)) { |
1556 | rcu_read_unlock(); | 1555 | rcu_read_unlock(); |
1557 | return err; | 1556 | return PTR_ERR(mpath); |
1558 | } | 1557 | } |
1559 | 1558 | ||
1560 | mpath = mesh_path_lookup(sdata, dst); | ||
1561 | if (!mpath) { | ||
1562 | rcu_read_unlock(); | ||
1563 | return -ENXIO; | ||
1564 | } | ||
1565 | mesh_path_fix_nexthop(mpath, sta); | 1559 | mesh_path_fix_nexthop(mpath, sta); |
1566 | 1560 | ||
1567 | rcu_read_unlock(); | 1561 | rcu_read_unlock(); |