Some cleanup to avoid pre- and post-calculation with the open_count variable. Signed-off-by: Alexander Aring <alex.aring@xxxxxxxxx> --- net/mac802154/iface.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c index ab23246..c1e5096 100644 --- a/net/mac802154/iface.c +++ b/net/mac802154/iface.c @@ -40,17 +40,17 @@ static int mac802154_slave_open(struct net_device *dev) ASSERT_RTNL(); - mutex_lock(&sdata->local->iflist_mtx); - sdata->running = true; - mutex_unlock(&sdata->local->iflist_mtx); - - if (local->open_count++ == 0) { + if (!local->open_count) { res = drv_start(local); WARN_ON(res); if (res) goto err; } + mutex_lock(&sdata->local->iflist_mtx); + sdata->running = true; + mutex_unlock(&sdata->local->iflist_mtx); + if (local->ops->ieee_addr) { __le64 addr = ieee802154_devaddr_from_raw(dev->dev_addr); @@ -61,11 +61,12 @@ static int mac802154_slave_open(struct net_device *dev) mac802154_dev_set_ieee_addr(dev); } + local->open_count++; + netif_start_queue(dev); + return 0; err: - sdata->local->open_count--; - return res; } @@ -78,11 +79,13 @@ static int mac802154_slave_close(struct net_device *dev) netif_stop_queue(dev); + local->open_count--; + mutex_lock(&sdata->local->iflist_mtx); sdata->running = false; mutex_unlock(&sdata->local->iflist_mtx); - if (!--local->open_count) + if (!local->open_count) drv_stop(local); return 0; -- 2.0.3 -- To unsubscribe from this list: send the line "unsubscribe linux-wpan" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html