Skip to content

Commit 9f7f78b

Browse files
signal11davem330
authored andcommitted
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>
1 parent cbde812 commit 9f7f78b

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎net/mac802154/mib.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,15 @@ static void phy_chan_notify(struct work_struct *work)
176176
struct mac802154_sub_if_data *priv = netdev_priv(nw->dev);
177177
int res;
178178

179+
mutex_lock(&priv->hw->phy->pib_lock);
179180
res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan);
180181
if (res)
181182
pr_debug("set_channel failed\n");
183+
else {
184+
priv->hw->phy->current_channel = priv->chan;
185+
priv->hw->phy->current_page = priv->page;
186+
}
187+
mutex_unlock(&priv->hw->phy->pib_lock);
182188

183189
kfree(nw);
184190
}
@@ -195,14 +201,18 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
195201
priv->chan = chan;
196202
spin_unlock_bh(&priv->mib_lock);
197203

204+
mutex_lock(&priv->hw->phy->pib_lock);
198205
if (priv->hw->phy->current_channel != priv->chan ||
199206
priv->hw->phy->current_page != priv->page) {
207+
mutex_unlock(&priv->hw->phy->pib_lock);
208+
200209
work = kzalloc(sizeof(*work), GFP_ATOMIC);
201210
if (!work)
202211
return;
203212

204213
INIT_WORK(&work->work, phy_chan_notify);
205214
work->dev = dev;
206215
queue_work(priv->hw->dev_workqueue, &work->work);
207-
}
216+
} else
217+
mutex_unlock(&priv->hw->phy->pib_lock);
208218
}

‎net/mac802154/tx.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ static void mac802154_xmit_worker(struct work_struct *work)
5858
pr_debug("set_channel failed\n");
5959
goto out;
6060
}
61+
62+
xw->priv->phy->current_channel = xw->chan;
63+
xw->priv->phy->current_page = xw->page;
6164
}
6265

6366
res = xw->priv->ops->xmit(&xw->priv->hw, xw->skb);

0 commit comments

Comments
 (0)