Linux IEEE 802.15.4 and 6LoWPAN development
 help / color / mirror / Atom feed
From: Martin Townsend <martin.townsend@xsilon.com>
To: Alexander Aring <alex.aring@gmail.com>, linux-wpan@vger.kernel.org
Subject: Re: [PATCH wpan-next 12/12] mac802154: rework sdata state change to running
Date: Thu, 14 Aug 2014 09:05:37 +0100	[thread overview]
Message-ID: <53EC6DD1.7010306@xsilon.com> (raw)
In-Reply-To: <1407937595-16415-13-git-send-email-alex.aring@gmail.com>

Looks good, I would think that the mutex is not needed as set_bit and clear_bit are atomic operations??

- Martin.

On 13/08/14 14:46, Alexander Aring wrote:
> 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's
> locked by rtnl lock.
>
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
>  net/mac802154/ieee802154_i.h |  6 +++++-
>  net/mac802154/iface.c        | 10 ++++------
>  2 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
> index c20fbc9..5bfdec0 100644
> --- a/net/mac802154/ieee802154_i.h
> +++ b/net/mac802154/ieee802154_i.h
> @@ -31,6 +31,10 @@ enum {
>  	IEEE802154_RX_MSG        = 1,
>  };
>  
> +enum ieee802154_sdata_state_bits {
> +	SDATA_STATE_RUNNING,
> +};
> +
>  /* Slave interface definition.
>   *
>   * Slaves represent typical network interfaces available from userspace.
> @@ -44,7 +48,7 @@ struct ieee802154_sub_if_data {
>  	struct net_device *dev;
>  
>  	int type;
> -	bool running;
> +	unsigned long state;
>  
>  	spinlock_t mib_lock;
>  
> diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
> index 4655be5..d221562 100644
> --- a/net/mac802154/iface.c
> +++ b/net/mac802154/iface.c
> @@ -47,9 +47,7 @@ static int mac802154_slave_open(struct net_device *dev)
>  			goto err;
>  	}
>  
> -	mutex_lock(&sdata->local->iflist_mtx);
> -	sdata->running = true;
> -	mutex_unlock(&sdata->local->iflist_mtx);
> +	set_bit(SDATA_STATE_RUNNING, &sdata->state);
>  
>  	local->open_count++;
>  
> @@ -57,6 +55,8 @@ static int mac802154_slave_open(struct net_device *dev)
>  
>  	return 0;
>  err:
> +	/* might already be clear but that doesn't matter */
> +	clear_bit(SDATA_STATE_RUNNING, &sdata->state);
>  	return res;
>  }
>  
> @@ -71,9 +71,7 @@ static int mac802154_slave_close(struct net_device *dev)
>  
>  	local->open_count--;
>  
> -	mutex_lock(&sdata->local->iflist_mtx);
> -	sdata->running = false;
> -	mutex_unlock(&sdata->local->iflist_mtx);
> +	clear_bit(SDATA_STATE_RUNNING, &sdata->state);
>  
>  	if (!local->open_count)
>  		drv_stop(local);


  reply	other threads:[~2014-08-14  8:05 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 ` [PATCH wpan-next 10/12] mac802154: rework open count Alexander Aring
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 [this message]
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=53EC6DD1.7010306@xsilon.com \
    --to=martin.townsend@xsilon.com \
    --cc=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