From: Alexander Aring <alex.aring@gmail.com>
To: linux-wpan@vger.kernel.org
Cc: Alexander Aring <alex.aring@gmail.com>
Subject: [PATCH wpan-next 10/12] mac802154: rework open count
Date: Wed, 13 Aug 2014 15:46:33 +0200 [thread overview]
Message-ID: <1407937595-16415-11-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1407937595-16415-1-git-send-email-alex.aring@gmail.com>
Some cleanup to avoid pre- and post-calculation with the open_count
variable.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
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
next prev parent reply other threads:[~2014-08-13 13:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-13 13:46 [PATCH wpan-next 00/12] ieee802154: mac802154: wireless transformation part 2 Alexander Aring
2014-08-13 13:46 ` [PATCH wpan-next 01/12] mac802154: rx: warn if ieee80211_rx call from irq Alexander Aring
2014-08-13 13:46 ` [PATCH wpan-next 02/12] mac802154: move header parse functions to rx.c Alexander Aring
2014-08-13 13:46 ` [PATCH wpan-next 03/12] mac802154: rename sdata slaves and slaves_mtx Alexander Aring
2014-08-13 13:46 ` [PATCH wpan-next 04/12] mac802154: introduce IEEE802154_DEV_TO_SUB_IF Alexander Aring
2014-08-13 13:46 ` [PATCH wpan-next 05/12] mac802154: move slave open/close functions to wpan Alexander Aring
2014-08-13 13:46 ` [PATCH wpan-next 06/12] mac802154: rename wpan.c to iface.c Alexander Aring
2014-08-13 13:46 ` [PATCH wpan-next 07/12] mac802154: rx: use netif_receive_skb Alexander Aring
2014-08-13 13:46 ` [PATCH wpan-next 08/12] mac802154: introduce internal driver-ops header Alexander Aring
2014-08-13 13:46 ` [PATCH wpan-next 09/12] mac802154: remove useless -EBUSY if sdata running Alexander Aring
2014-08-13 15:07 ` Alexander Aring
2014-08-24 6:59 ` Alexander Aring
2014-08-13 13:46 ` Alexander Aring [this message]
2014-08-13 13:46 ` [PATCH wpan-next 11/12] mac802154: remove ieee802154_addr from driver_ops Alexander Aring
2014-08-13 13:46 ` [PATCH wpan-next 12/12] mac802154: rework sdata state change to running Alexander Aring
2014-08-14 8:05 ` Martin Townsend
2014-08-14 8:18 ` Alexander Aring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1407937595-16415-11-git-send-email-alex.aring@gmail.com \
--to=alex.aring@gmail.com \
--cc=linux-wpan@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox