diff options
author | Alan Ott <alan@signal11.us> | 2013-04-05 15:03:10 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-04-08 18:09:18 +0200 |
commit | 9f7f78b479ae06279a85451d456040bbe4eae013 (patch) | |
tree | c0e7c127eceffbcab6640a41766b6817157798ef /net/mac802154/mib.c | |
parent | mrf24j40: Enable link-layer acknowledgement and retry (diff) | |
download | linux-9f7f78b479ae06279a85451d456040bbe4eae013.tar.xz linux-9f7f78b479ae06279a85451d456040bbe4eae013.zip |
mac802154: Keep track of the channel when changed
Two sections checked whether the current channel != the new channel
without ever setting the current channel variables.
1. net/mac802154/tx.c: Prevent set_channel() from getting called every
time a packet is sent.
2. net/mac802154/mib.c: Lock (pib_lock) accesses to current_channel and
current_page and make sure they are updated when the channel has been
changed.
Signed-off-by: Alan Ott <alan@signal11.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mac802154/mib.c')
-rw-r--r-- | net/mac802154/mib.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c index f03e55f2ebf0..8ded97cf1c33 100644 --- a/net/mac802154/mib.c +++ b/net/mac802154/mib.c @@ -176,9 +176,15 @@ static void phy_chan_notify(struct work_struct *work) struct mac802154_sub_if_data *priv = netdev_priv(nw->dev); int res; + mutex_lock(&priv->hw->phy->pib_lock); res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan); if (res) pr_debug("set_channel failed\n"); + else { + priv->hw->phy->current_channel = priv->chan; + priv->hw->phy->current_page = priv->page; + } + mutex_unlock(&priv->hw->phy->pib_lock); kfree(nw); } @@ -195,8 +201,11 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan) priv->chan = chan; spin_unlock_bh(&priv->mib_lock); + mutex_lock(&priv->hw->phy->pib_lock); if (priv->hw->phy->current_channel != priv->chan || priv->hw->phy->current_page != priv->page) { + mutex_unlock(&priv->hw->phy->pib_lock); + work = kzalloc(sizeof(*work), GFP_ATOMIC); if (!work) return; @@ -204,5 +213,6 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan) INIT_WORK(&work->work, phy_chan_notify); work->dev = dev; queue_work(priv->hw->dev_workqueue, &work->work); - } + } else + mutex_unlock(&priv->hw->phy->pib_lock); } |