Make sure the channel is pushed down to the PHY driver.
This allows packets to be received on an defined channel before the first 
packet is sent.


Signed-off-by: Michael Hennerich <[email protected]>
---

net/mac802154/mib.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c
index 074db95..544a6e0 100644
--- a/net/mac802154/mib.c
+++ b/net/mac802154/mib.c
@@ -28,6 +28,28 @@
 #include "mac802154.h"
 #include "mib.h"
 
+struct phy_chan_notify_work {
+       struct work_struct work;
+       struct net_device *dev;
+};
+
+static void phy_chan_notify(struct work_struct *work)
+{
+       struct phy_chan_notify_work *nw = container_of(work,
+                       struct phy_chan_notify_work, work);
+       struct ieee802154_priv *hw = ieee802154_slave_get_priv(nw->dev);
+       struct ieee802154_sub_if_data *priv = netdev_priv(nw->dev);
+       int res;
+
+       res = hw->ops->set_channel(&hw->hw, priv->chan);
+       if (res)
+               pr_debug("set_channel failed\n");
+
+       kfree(nw);
+
+       return;
+}
+
 u16 ieee802154_dev_get_pan_id(const struct net_device *dev)
 {
        struct ieee802154_sub_if_data *priv = netdev_priv(dev);
@@ -81,12 +103,23 @@ void ieee802154_dev_set_short_addr(struct net_device *dev, 
u16 val)
 void ieee802154_dev_set_channel(struct net_device *dev, u8 val)
 {
        struct ieee802154_sub_if_data *priv = netdev_priv(dev);
+       struct phy_chan_notify_work *work;
 
        BUG_ON(dev->type != ARPHRD_IEEE802154);
 
        write_lock_bh(&priv->mib_lock);
        priv->chan = val;
        write_unlock_bh(&priv->mib_lock);
+
+       if (priv->hw->phy->current_channel != priv->chan) {
+               work = kzalloc(sizeof(*work), GFP_ATOMIC);
+               if (!work)
+                       return;
+
+               INIT_WORK(&work->work, phy_chan_notify);
+               work->dev = dev;
+               queue_work(priv->hw->dev_workqueue, &work->work);
+       }
 }
 
 void ieee802154_dev_set_page(struct net_device *dev, u8 page)



------------------------------------------------------------------
********* Analog Devices GmbH              Open Platform Solutions        
**  *****                                  
**     ** Wilhelm-Wagenfeld-Strasse 6       
**  ***** D-80807 Munich
********* Germany
Registergericht München HRB 40368,  Geschäftsführer: Thomas Wessel, William A. 
Martin, Margaret K. Seif


------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Linux-zigbee-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

Reply via email to