wpan-phy: allow specifying a per-page channel mask
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Tue, 22 Sep 2009 11:26:48 +0000 (15:26 +0400)
committerDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Fri, 6 Nov 2009 11:23:41 +0000 (14:23 +0300)
IEEE 802.15.4-2006 defines channel pages that hold channels (max 32 pages,
27 channels per page). Allow the driver to specify supported channels
on pages, other than the first one.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
drivers/ieee802154/fakehard.c
include/net/wpan-phy.h
net/ieee802154/wpan-class.c

index 96a2959ce877e10905acfcc84cb1897e874d7143..f6f2afefaa177e306ed20f747693d3985ecfa5e9 100644 (file)
@@ -356,7 +356,7 @@ static int __devinit ieee802154fake_probe(struct platform_device *pdev)
                        dev->addr_len);
        memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
 
-       phy->channels_supported = (1 << 27) - 1;
+       phy->channels_supported[0] = (1 << 27) - 1;
        phy->transmit_power = 0xbf;
 
        dev->netdev_ops = &fake_ops;
index 3367dd95cf85da793da737c9630fe6659e232d31..7b7fc581e673219ed7d850164ca49cec8b3a2f39 100644 (file)
@@ -34,7 +34,7 @@ struct wpan_phy {
         */
        u8 current_channel;
        u8 current_page;
-       u32 channels_supported;
+       u32 channels_supported[32];
        u8 transmit_power;
        u8 cca_mode;
 
index 68ccde63155b7a1a1d055b177cce2c5a1edd4414..0c51f85aa59132dbd52244689703bd956bb720e8 100644 (file)
@@ -40,12 +40,30 @@ static ssize_t name ## _show(struct device *dev,                    \
 
 MASTER_SHOW(current_channel, "%d");
 MASTER_SHOW(current_page, "%d");
-MASTER_SHOW(channels_supported, "%#x");
 MASTER_SHOW_COMPLEX(transmit_power, "%d +- %d dB",
        ((signed char) (phy->transmit_power << 2)) >> 2,
        (phy->transmit_power >> 6) ? (phy->transmit_power >> 6) * 3 : 1 );
 MASTER_SHOW(cca_mode, "%d");
 
+static ssize_t channels_supported_show(struct device *dev,
+                           struct device_attribute *attr, char *buf)
+{
+       struct wpan_phy *phy = container_of(dev, struct wpan_phy, dev);
+       int ret;
+       int i, len = 0;
+
+       mutex_lock(&phy->pib_lock);
+       for (i = 0; i < 32; i++) {
+               ret = snprintf(buf + len, PAGE_SIZE - len,
+                               "%#09x\n", phy->channels_supported[i]);
+               if (ret < 0)
+                       break;
+               len += ret;
+       }
+       mutex_unlock(&phy->pib_lock);
+       return len;
+}
+
 static struct device_attribute pmib_attrs[] = {
        __ATTR_RO(current_channel),
        __ATTR_RO(current_page),