lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <SA2PR10MB44609D98484539F0A5948C8DA6D1A@SA2PR10MB4460.namprd10.prod.outlook.com>
Date: Tue, 25 Nov 2025 09:41:30 +0000
From: Les Boys <lesboyspp43@...look.com>
To: "linux-wpan@...r.kernel.org" <linux-wpan@...r.kernel.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"alex.aring@...il.com" <alex.aring@...il.com>, "stefan@...enfreihafen.org"
	<stefan@...enfreihafen.org>, "miquel.raynal@...tlin.com"
	<miquel.raynal@...tlin.com>
Subject: [PATCH v1 2/2] net/ieee802154: use channel mask macros replace the
 hard-coded magic number

This commit replaced all the hard-coded magic numbers to macros defined in
previous commit.

---
 drivers/net/ieee802154/adf7242.c         |  2 +-
 drivers/net/ieee802154/at86rf230.c       |  4 +-
 drivers/net/ieee802154/atusb.c           |  5 ++-
 drivers/net/ieee802154/cc2520.c          |  2 +-
 drivers/net/ieee802154/fakelb.c          | 47 +++++++++---------------
 drivers/net/ieee802154/mac802154_hwsim.c | 46 ++++++++---------------
 6 files changed, 40 insertions(+), 66 deletions(-)

diff --git a/drivers/net/ieee802154/adf7242.c b/drivers/net/ieee802154/adf7242.c
index cc7ddc400..cc6324dfe 100644
--- a/drivers/net/ieee802154/adf7242.c
+++ b/drivers/net/ieee802154/adf7242.c
@@ -1212,7 +1212,7 @@ static int adf7242_probe(struct spi_device *spi)
        hw->extra_tx_headroom = 0;

        /* We support only 2.4 Ghz */
-       hw->phy->supported.channels[0] = 0x7FFF800;
+       hw->phy->supported.channels[0] = IEEE802154_CHAN_2D4G_O_QPSK;

        hw->flags = IEEE802154_HW_OMIT_CKSUM |
                    IEEE802154_HW_CSMA_PARAMS |
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index fd91f8a45..145a2ef0f 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -1470,7 +1470,7 @@ at86rf230_detect_device(struct at86rf230_local *lp)
        case 3:
                chip = "at86rf231";
                lp->data = &at86rf231_data;
-               lp->hw->phy->supported.channels[0] = 0x7FFF800;
+               lp->hw->phy->supported.channels[0] = IEEE802154_CHAN_2D4G_O_QPSK;
                lp->hw->phy->current_channel = 11;
                lp->hw->phy->supported.tx_powers = at86rf231_powers;
                lp->hw->phy->supported.tx_powers_size = ARRAY_SIZE(at86rf231_powers);
@@ -1493,7 +1493,7 @@ at86rf230_detect_device(struct at86rf230_local *lp)
        case 11:
                chip = "at86rf233";
                lp->data = &at86rf233_data;
-               lp->hw->phy->supported.channels[0] = 0x7FFF800;
+               lp->hw->phy->supported.channels[0] = IEEE802154_CHAN_2D4G_O_QPSK;
                lp->hw->phy->current_channel = 13;
                lp->hw->phy->supported.tx_powers = at86rf233_powers;
                lp->hw->phy->supported.tx_powers_size = ARRAY_SIZE(at86rf233_powers);
diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
index 95a4a3cdc..4724bd534 100644
--- a/drivers/net/ieee802154/atusb.c
+++ b/drivers/net/ieee802154/atusb.c
@@ -29,6 +29,7 @@
 #include <linux/jiffies.h>
 #include <linux/usb.h>
 #include <linux/skbuff.h>
+#include <linux/ieee802154.h>

 #include <net/cfg802154.h>
 #include <net/mac802154.h>
@@ -858,7 +859,7 @@ static int atusb_get_and_conf_chip(struct atusb *atusb)
        switch (part_num) {
        case 2:
                chip = "AT86RF230";
-               atusb->hw->phy->supported.channels[0] = 0x7FFF800;
+               atusb->hw->phy->supported.channels[0] = IEEE802154_CHAN_2D4G_O_QPSK;
                atusb->hw->phy->current_channel = 11;   /* reset default */
                atusb->hw->phy->supported.tx_powers = atusb_powers;
                atusb->hw->phy->supported.tx_powers_size = ARRAY_SIZE(atusb_powers);
@@ -867,7 +868,7 @@ static int atusb_get_and_conf_chip(struct atusb *atusb)
                break;
        case 3:
                chip = "AT86RF231";
-               atusb->hw->phy->supported.channels[0] = 0x7FFF800;
+               atusb->hw->phy->supported.channels[0] = IEEE802154_CHAN_2D4G_O_QPSK;
                atusb->hw->phy->current_channel = 11;   /* reset default */
                atusb->hw->phy->supported.tx_powers = atusb_powers;
                atusb->hw->phy->supported.tx_powers_size = ARRAY_SIZE(atusb_powers);
diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
index 2b7034193..7d8b08cc1 100644
--- a/drivers/net/ieee802154/cc2520.c
+++ b/drivers/net/ieee802154/cc2520.c
@@ -836,7 +836,7 @@ static int cc2520_register(struct cc2520_private *priv)
        ieee802154_random_extended_addr(&priv->hw->phy->perm_extended_addr);

        /* We do support only 2.4 Ghz */
-       priv->hw->phy->supported.channels[0] = 0x7FFF800;
+       priv->hw->phy->supported.channels[0] = IEEE802154_CHAN_2D4G_O_QPSK;
        priv->hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT |
                          IEEE802154_HW_PROMISCUOUS;

diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c
index e11d8eda8..f672186ca 100644
--- a/drivers/net/ieee802154/fakelb.c
+++ b/drivers/net/ieee802154/fakelb.c
@@ -16,6 +16,7 @@
 #include <linux/netdevice.h>
 #include <linux/device.h>
 #include <linux/spinlock.h>
+#include <linux/ieee802154.h>
 #include <net/mac802154.h>
 #include <net/cfg802154.h>

@@ -137,36 +138,22 @@ static int fakelb_add_one(struct device *dev)
        phy = hw->priv;
        phy->hw = hw;

-       /* 868 MHz BPSK 802.15.4-2003 */
-       hw->phy->supported.channels[0] |= 1;
-       /* 915 MHz BPSK 802.15.4-2003 */
-       hw->phy->supported.channels[0] |= 0x7fe;
-       /* 2.4 GHz O-QPSK 802.15.4-2003 */
-       hw->phy->supported.channels[0] |= 0x7FFF800;
-       /* 868 MHz ASK 802.15.4-2006 */
-       hw->phy->supported.channels[1] |= 1;
-       /* 915 MHz ASK 802.15.4-2006 */
-       hw->phy->supported.channels[1] |= 0x7fe;
-       /* 868 MHz O-QPSK 802.15.4-2006 */
-       hw->phy->supported.channels[2] |= 1;
-       /* 915 MHz O-QPSK 802.15.4-2006 */
-       hw->phy->supported.channels[2] |= 0x7fe;
-       /* 2.4 GHz CSS 802.15.4a-2007 */
-       hw->phy->supported.channels[3] |= 0x3fff;
-       /* UWB Sub-gigahertz 802.15.4a-2007 */
-       hw->phy->supported.channels[4] |= 1;
-       /* UWB Low band 802.15.4a-2007 */
-       hw->phy->supported.channels[4] |= 0x1e;
-       /* UWB High band 802.15.4a-2007 */
-       hw->phy->supported.channels[4] |= 0xffe0;
-       /* 750 MHz O-QPSK 802.15.4c-2009 */
-       hw->phy->supported.channels[5] |= 0xf;
-       /* 750 MHz MPSK 802.15.4c-2009 */
-       hw->phy->supported.channels[5] |= 0xf0;
-       /* 950 MHz BPSK 802.15.4d-2009 */
-       hw->phy->supported.channels[6] |= 0x3ff;
-       /* 950 MHz GFSK 802.15.4d-2009 */
-       hw->phy->supported.channels[6] |= 0x3ffc00;
+
+       hw->phy->supported.channels[0] |= IEEE802154_CHAN_868M_BPSK;
+       hw->phy->supported.channels[0] |= IEEE802154_CHAN_915M_BPSK;
+       hw->phy->supported.channels[0] |= IEEE802154_CHAN_2D4G_O_QPSK;
+       hw->phy->supported.channels[1] |= IEEE802154_CHAN_868M_ASK;
+       hw->phy->supported.channels[1] |= IEEE802154_CHAN_915M_ASK;
+       hw->phy->supported.channels[2] |= IEEE802154_CHAN_868M_O_QPSK;
+       hw->phy->supported.channels[2] |= IEEE802154_CHAN_915M_O_QPSK;
+       hw->phy->supported.channels[3] |= IEEE802154_CHAN_2D4G_CSS;
+       hw->phy->supported.channels[4] |= IEEE802154_CHAN_UWB_SUBGIGA;
+       hw->phy->supported.channels[4] |= IEEE802154_CHAN_UWB_LOWBAND;
+       hw->phy->supported.channels[4] |= IEEE802154_CHAN_UWB_HIGHBAND;
+       hw->phy->supported.channels[5] |= IEEE802154_CHAN_750M_O_QPSK;
+       hw->phy->supported.channels[5] |= IEEE802154_CHAN_750M_MPSK;
+       hw->phy->supported.channels[6] |= IEEE802154_CHAN_950M_BPSK;
+       hw->phy->supported.channels[6] |= IEEE802154_CHAN_950M_GFSK;

        ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
        /* fake phy channel 13 as default */
diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c
index 1cab20b5a..d89396592 100644
--- a/drivers/net/ieee802154/mac802154_hwsim.c
+++ b/drivers/net/ieee802154/mac802154_hwsim.c
@@ -18,6 +18,7 @@
 #include <linux/netdevice.h>
 #include <linux/device.h>
 #include <linux/spinlock.h>
+#include <linux/ieee802154.h>
 #include <net/ieee802154_netdev.h>
 #include <net/mac802154.h>
 #include <net/cfg802154.h>
@@ -911,36 +912,21 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
        phy = hw->priv;
        phy->hw = hw;

-       /* 868 MHz BPSK 802.15.4-2003 */
-       hw->phy->supported.channels[0] |= 1;
-       /* 915 MHz BPSK 802.15.4-2003 */
-       hw->phy->supported.channels[0] |= 0x7fe;
-       /* 2.4 GHz O-QPSK 802.15.4-2003 */
-       hw->phy->supported.channels[0] |= 0x7FFF800;
-       /* 868 MHz ASK 802.15.4-2006 */
-       hw->phy->supported.channels[1] |= 1;
-       /* 915 MHz ASK 802.15.4-2006 */
-       hw->phy->supported.channels[1] |= 0x7fe;
-       /* 868 MHz O-QPSK 802.15.4-2006 */
-       hw->phy->supported.channels[2] |= 1;
-       /* 915 MHz O-QPSK 802.15.4-2006 */
-       hw->phy->supported.channels[2] |= 0x7fe;
-       /* 2.4 GHz CSS 802.15.4a-2007 */
-       hw->phy->supported.channels[3] |= 0x3fff;
-       /* UWB Sub-gigahertz 802.15.4a-2007 */
-       hw->phy->supported.channels[4] |= 1;
-       /* UWB Low band 802.15.4a-2007 */
-       hw->phy->supported.channels[4] |= 0x1e;
-       /* UWB High band 802.15.4a-2007 */
-       hw->phy->supported.channels[4] |= 0xffe0;
-       /* 750 MHz O-QPSK 802.15.4c-2009 */
-       hw->phy->supported.channels[5] |= 0xf;
-       /* 750 MHz MPSK 802.15.4c-2009 */
-       hw->phy->supported.channels[5] |= 0xf0;
-       /* 950 MHz BPSK 802.15.4d-2009 */
-       hw->phy->supported.channels[6] |= 0x3ff;
-       /* 950 MHz GFSK 802.15.4d-2009 */
-       hw->phy->supported.channels[6] |= 0x3ffc00;
+       hw->phy->supported.channels[0] |= IEEE802154_CHAN_868M_BPSK;
+       hw->phy->supported.channels[0] |= IEEE802154_CHAN_915M_BPSK;
+       hw->phy->supported.channels[0] |= IEEE802154_CHAN_2D4G_O_QPSK;
+       hw->phy->supported.channels[1] |= IEEE802154_CHAN_868M_ASK;
+       hw->phy->supported.channels[1] |= IEEE802154_CHAN_915M_ASK;
+       hw->phy->supported.channels[2] |= IEEE802154_CHAN_868M_O_QPSK;
+       hw->phy->supported.channels[2] |= IEEE802154_CHAN_915M_O_QPSK;
+       hw->phy->supported.channels[3] |= IEEE802154_CHAN_2D4G_CSS;
+       hw->phy->supported.channels[4] |= IEEE802154_CHAN_UWB_SUBGIGA;
+       hw->phy->supported.channels[4] |= IEEE802154_CHAN_UWB_LOWBAND;
+       hw->phy->supported.channels[4] |= IEEE802154_CHAN_UWB_HIGHBAND;
+       hw->phy->supported.channels[5] |= IEEE802154_CHAN_750M_O_QPSK;
+       hw->phy->supported.channels[5] |= IEEE802154_CHAN_750M_MPSK;
+       hw->phy->supported.channels[6] |= IEEE802154_CHAN_950M_BPSK;
+       hw->phy->supported.channels[6] |= IEEE802154_CHAN_950M_GFSK;

        ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);

--
2.44.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ