Commit 0ea3da64 authored by Alexander Aring's avatar Alexander Aring Committed by Marcel Holtmann

mac802154: rework sdata state change to running

This patch reworks the handling for setting the state like mac80211. We
use bit's instead a bool variable. The mutex is not needed because it use
test and set bits which are atomic operations.
Signed-off-by: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent a543c598
...@@ -67,6 +67,10 @@ enum { ...@@ -67,6 +67,10 @@ enum {
IEEE802154_RX_MSG = 1, IEEE802154_RX_MSG = 1,
}; };
enum ieee802154_sdata_state_bits {
SDATA_STATE_RUNNING,
};
/* Slave interface definition. /* Slave interface definition.
* *
* Slaves represent typical network interfaces available from userspace. * Slaves represent typical network interfaces available from userspace.
...@@ -80,7 +84,7 @@ struct ieee802154_sub_if_data { ...@@ -80,7 +84,7 @@ struct ieee802154_sub_if_data {
struct net_device *dev; struct net_device *dev;
int type; int type;
bool running; unsigned long state;
spinlock_t mib_lock; spinlock_t mib_lock;
...@@ -120,6 +124,12 @@ IEEE802154_DEV_TO_SUB_IF(const struct net_device *dev) ...@@ -120,6 +124,12 @@ IEEE802154_DEV_TO_SUB_IF(const struct net_device *dev)
return netdev_priv(dev); return netdev_priv(dev);
} }
static inline bool
ieee802154_sdata_running(struct ieee802154_sub_if_data *sdata)
{
return test_bit(SDATA_STATE_RUNNING, &sdata->state);
}
extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced; extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
extern struct ieee802154_mlme_ops mac802154_mlme_wpan; extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
......
...@@ -156,7 +156,7 @@ static int mac802154_slave_open(struct net_device *dev) ...@@ -156,7 +156,7 @@ static int mac802154_slave_open(struct net_device *dev)
mutex_lock(&sdata->local->iflist_mtx); mutex_lock(&sdata->local->iflist_mtx);
list_for_each_entry(subif, &sdata->local->interfaces, list) { list_for_each_entry(subif, &sdata->local->interfaces, list) {
if (subif != sdata && subif->type == sdata->type && if (subif != sdata && subif->type == sdata->type &&
subif->running) { ieee802154_sdata_running(subif)) {
mutex_unlock(&sdata->local->iflist_mtx); mutex_unlock(&sdata->local->iflist_mtx);
return -EBUSY; return -EBUSY;
} }
...@@ -164,9 +164,7 @@ static int mac802154_slave_open(struct net_device *dev) ...@@ -164,9 +164,7 @@ static int mac802154_slave_open(struct net_device *dev)
mutex_unlock(&sdata->local->iflist_mtx); mutex_unlock(&sdata->local->iflist_mtx);
} }
mutex_lock(&sdata->local->iflist_mtx); set_bit(SDATA_STATE_RUNNING, &sdata->state);
sdata->running = true;
mutex_unlock(&sdata->local->iflist_mtx);
if (local->open_count++ == 0) { if (local->open_count++ == 0) {
res = drv_start(local); res = drv_start(local);
...@@ -178,6 +176,8 @@ static int mac802154_slave_open(struct net_device *dev) ...@@ -178,6 +176,8 @@ static int mac802154_slave_open(struct net_device *dev)
netif_start_queue(dev); netif_start_queue(dev);
return 0; return 0;
err: err:
/* might already be clear but that doesn't matter */
clear_bit(SDATA_STATE_RUNNING, &sdata->state);
sdata->local->open_count--; sdata->local->open_count--;
return res; return res;
...@@ -253,9 +253,7 @@ static int mac802154_slave_close(struct net_device *dev) ...@@ -253,9 +253,7 @@ static int mac802154_slave_close(struct net_device *dev)
netif_stop_queue(dev); netif_stop_queue(dev);
mutex_lock(&sdata->local->iflist_mtx); clear_bit(SDATA_STATE_RUNNING, &sdata->state);
sdata->running = false;
mutex_unlock(&sdata->local->iflist_mtx);
if (!--local->open_count) if (!--local->open_count)
drv_stop(local); drv_stop(local);
......
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