diff options
| author | alex.bluesman.smirnov@gmail.com <alex.bluesman.smirnov@gmail.com> | 2012-06-25 19:24:51 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2012-06-27 00:06:11 -0400 |
| commit | 66b69d4d7fe3026a4add368b72905b4d7878c320 (patch) | |
| tree | baaa09c385f2c9b21cec02372879c6a383f36dfb /net/mac802154 | |
| parent | 48e44d5057144b4e28615e3e1ce725b2ca887b40 (diff) | |
mac802154: page and channel setter
A new method to set page and channel values for a transceiver
was added to the MIB.
Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mac802154')
| -rw-r--r-- | net/mac802154/mac802154.h | 1 | ||||
| -rw-r--r-- | net/mac802154/mib.c | 44 |
2 files changed, 45 insertions, 0 deletions
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h index 995107203ddc..69678644a5c2 100644 --- a/net/mac802154/mac802154.h +++ b/net/mac802154/mac802154.h | |||
| @@ -112,5 +112,6 @@ void mac802154_dev_set_short_addr(struct net_device *dev, u16 val); | |||
| 112 | void mac802154_dev_set_ieee_addr(struct net_device *dev); | 112 | void mac802154_dev_set_ieee_addr(struct net_device *dev); |
| 113 | u16 mac802154_dev_get_pan_id(const struct net_device *dev); | 113 | u16 mac802154_dev_get_pan_id(const struct net_device *dev); |
| 114 | void mac802154_dev_set_pan_id(struct net_device *dev, u16 val); | 114 | void mac802154_dev_set_pan_id(struct net_device *dev, u16 val); |
| 115 | void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan); | ||
| 115 | 116 | ||
| 116 | #endif /* MAC802154_H */ | 117 | #endif /* MAC802154_H */ |
diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c index d74503b4302f..380829d84600 100644 --- a/net/mac802154/mib.c +++ b/net/mac802154/mib.c | |||
| @@ -28,6 +28,11 @@ | |||
| 28 | 28 | ||
| 29 | #include "mac802154.h" | 29 | #include "mac802154.h" |
| 30 | 30 | ||
| 31 | struct phy_chan_notify_work { | ||
| 32 | struct work_struct work; | ||
| 33 | struct net_device *dev; | ||
| 34 | }; | ||
| 35 | |||
| 31 | struct hw_addr_filt_notify_work { | 36 | struct hw_addr_filt_notify_work { |
| 32 | struct work_struct work; | 37 | struct work_struct work; |
| 33 | struct net_device *dev; | 38 | struct net_device *dev; |
| @@ -139,3 +144,42 @@ void mac802154_dev_set_pan_id(struct net_device *dev, u16 val) | |||
| 139 | set_hw_addr_filt(dev, IEEE802515_AFILT_PANID_CHANGED); | 144 | set_hw_addr_filt(dev, IEEE802515_AFILT_PANID_CHANGED); |
| 140 | } | 145 | } |
| 141 | } | 146 | } |
| 147 | |||
| 148 | static void phy_chan_notify(struct work_struct *work) | ||
| 149 | { | ||
| 150 | struct phy_chan_notify_work *nw = container_of(work, | ||
| 151 | struct phy_chan_notify_work, work); | ||
| 152 | struct mac802154_priv *hw = mac802154_slave_get_priv(nw->dev); | ||
| 153 | struct mac802154_sub_if_data *priv = netdev_priv(nw->dev); | ||
| 154 | int res; | ||
| 155 | |||
| 156 | res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan); | ||
| 157 | if (res) | ||
| 158 | pr_debug("set_channel failed\n"); | ||
| 159 | |||
| 160 | kfree(nw); | ||
| 161 | } | ||
| 162 | |||
| 163 | void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan) | ||
| 164 | { | ||
| 165 | struct mac802154_sub_if_data *priv = netdev_priv(dev); | ||
| 166 | struct phy_chan_notify_work *work; | ||
| 167 | |||
| 168 | BUG_ON(dev->type != ARPHRD_IEEE802154); | ||
| 169 | |||
| 170 | spin_lock_bh(&priv->mib_lock); | ||
| 171 | priv->page = page; | ||
| 172 | priv->chan = chan; | ||
| 173 | spin_unlock_bh(&priv->mib_lock); | ||
| 174 | |||
| 175 | if (priv->hw->phy->current_channel != priv->chan || | ||
| 176 | priv->hw->phy->current_page != priv->page) { | ||
| 177 | work = kzalloc(sizeof(*work), GFP_ATOMIC); | ||
| 178 | if (!work) | ||
| 179 | return; | ||
| 180 | |||
| 181 | INIT_WORK(&work->work, phy_chan_notify); | ||
| 182 | work->dev = dev; | ||
| 183 | queue_work(priv->hw->dev_workqueue, &work->work); | ||
| 184 | } | ||
| 185 | } | ||
