All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] ieee802154: use macros to replace hard-coded channel masks
@ 2025-11-25  8:56 Les Boys
  2025-11-25  9:36 ` [PATCH v1 1/2] include: add macros for ieee 802.15.4 " Les Boys
  0 siblings, 1 reply; 6+ messages in thread
From: Les Boys @ 2025-11-25  8:56 UTC (permalink / raw)
  To: linux-wpan@vger.kernel.org
  Cc: linux-kernel@vger.kernel.org, alex.aring@gmail.com,
	stefan@datenfreihafen.org, miquel.raynal@bootlin.com

(Cleanup) It was noticed that in the previous implementation, the channel
masks were hard-coded in the source code. This patch extracts all channel
masks into a header file.

Commits:
 1. include: add macros for ieee 802.15.4 channel masks
 2. net/ieee802154: use channel mask macros replace the hard-coded magic number

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v1 1/2] include: add macros for ieee 802.15.4 channel masks
  2025-11-25  8:56 [PATCH v1 0/2] ieee802154: use macros to replace hard-coded channel masks Les Boys
@ 2025-11-25  9:36 ` Les Boys
  2025-11-25  9:41   ` [PATCH v1 2/2] net/ieee802154: use channel mask macros replace the hard-coded magic number Les Boys
  0 siblings, 1 reply; 6+ messages in thread
From: Les Boys @ 2025-11-25  9:36 UTC (permalink / raw)
  To: linux-wpan@vger.kernel.org
  Cc: linux-kernel@vger.kernel.org, alex.aring@gmail.com,
	stefan@datenfreihafen.org, miquel.raynal@bootlin.com

This commit defined all the 15 possible channel masks in
<linux/ieee802154.h>.

---
 include/linux/ieee802154.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
index 140f61ec0..cd42f28a9 100644
--- a/include/linux/ieee802154.h
+++ b/include/linux/ieee802154.h
@@ -58,6 +58,22 @@
 #define IEEE802154_MAX_CHANNEL         26
 #define IEEE802154_MAX_PAGE            31

+#define IEEE802154_CHAN_750M_O_QPSK        0xf          /* 750 MHz O-QPSK 802.15.4c-2009 */
+#define IEEE802154_CHAN_750M_MPSK          0xf0         /* 750 MHz MPSK 802.15.4c-2009 */
+#define IEEE802154_CHAN_868M_ASK           0x1          /* 868 MHz ASK 802.15.4-2006 */
+#define IEEE802154_CHAN_868M_BPSK          0x1          /* 868 MHz BPSK 802.15.4-2003 */
+#define IEEE802154_CHAN_868M_O_QPSK        0x1          /* 868 MHz O-QPSK 802.15.4-2006 */
+#define IEEE802154_CHAN_915M_ASK           0x7FE        /* 915 MHz ASK 802.15.4-2006 */
+#define IEEE802154_CHAN_915M_BPSK          0x7FE        /* 915 MHz BPSK 802.15.4-2003 */
+#define IEEE802154_CHAN_915M_O_QPSK        0x7FE        /* 915 MHz O-QPSK 802.15.4-2006 */
+#define IEEE802154_CHAN_950M_BPSK          0x3FF        /* 950 MHz BPSK 802.15.4d-2009 */
+#define IEEE802154_CHAN_950M_GFSK          0x3FFC00     /* 950 MHz GFSK 802.15.4d-2009 */
+#define IEEE802154_CHAN_2D4G_O_QPSK        0x7FFF800    /* 2.4 GHz O-QPSK 802.15.4-2003 */
+#define IEEE802154_CHAN_2D4G_CSS           0x3FFF       /* 2.4 GHz CSS 802.15.4a-2007 */
+#define IEEE802154_CHAN_UWB_SUBGIGA        0x1          /* UWB Sub-gigahertz 802.15.4a-2007 */
+#define IEEE802154_CHAN_UWB_LOWBAND        0x1E         /* UWB Low Band 802.15.4a-2007 */
+#define IEEE802154_CHAN_UWB_HIGHBAND       0xFFE0       /* UWB High Band 802.15.4a-2007 */
+
 #define IEEE802154_FC_TYPE_BEACON      0x0     /* Frame is beacon */
 #define        IEEE802154_FC_TYPE_DATA         0x1     /* Frame is data */
 #define IEEE802154_FC_TYPE_ACK         0x2     /* Frame is acknowledgment */
--
2.44.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 2/2] net/ieee802154: use channel mask macros replace the hard-coded magic number
  2025-11-25  9:36 ` [PATCH v1 1/2] include: add macros for ieee 802.15.4 " Les Boys
@ 2025-11-25  9:41   ` Les Boys
  2025-11-25 15:11     ` Miquel Raynal
  0 siblings, 1 reply; 6+ messages in thread
From: Les Boys @ 2025-11-25  9:41 UTC (permalink / raw)
  To: linux-wpan@vger.kernel.org
  Cc: linux-kernel@vger.kernel.org, alex.aring@gmail.com,
	stefan@datenfreihafen.org, miquel.raynal@bootlin.com

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 2/2] net/ieee802154: use channel mask macros replace the hard-coded magic number
  2025-11-25  9:41   ` [PATCH v1 2/2] net/ieee802154: use channel mask macros replace the hard-coded magic number Les Boys
@ 2025-11-25 15:11     ` Miquel Raynal
  2025-11-26  6:14       ` [PATCH v2 1/2] include: add macros for ieee 802.15.4 channel masks Les Boys
  2025-11-26  6:16       ` [PATCH v2 2/2] net/ieee802154: use channel mask macros replace the hard-coded magic number Les Boys
  0 siblings, 2 replies; 6+ messages in thread
From: Miquel Raynal @ 2025-11-25 15:11 UTC (permalink / raw)
  To: Les Boys
  Cc: linux-wpan@vger.kernel.org, linux-kernel@vger.kernel.org,
	alex.aring@gmail.com, stefan@datenfreihafen.org

Hello,

On 25/11/2025 at 09:41:30 GMT, Les Boys <lesboyspp43@outlook.com> wrote:

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

Can you please slightly rephrase into "Replace all the..."

Maybe the title can be shortened a little bit as well.

While I'm fine with this addition (I haven't checked all values), we
would need a proper name and Signed-off-by tag.

Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] include: add macros for ieee 802.15.4 channel masks
  2025-11-25 15:11     ` Miquel Raynal
@ 2025-11-26  6:14       ` Les Boys
  2025-11-26  6:16       ` [PATCH v2 2/2] net/ieee802154: use channel mask macros replace the hard-coded magic number Les Boys
  1 sibling, 0 replies; 6+ messages in thread
From: Les Boys @ 2025-11-26  6:14 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: linux-kernel@vger.kernel.org, alex.aring@gmail.com,
	stefan@datenfreihafen.org, Miquel Raynal

Defined all the 15 possible channel masks in
<linux/ieee802154.h>.

Signed-off-by: Les Boys <lesboyspp43@outlook.com>
---
 include/linux/ieee802154.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
index 140f61ec0..cd42f28a9 100644
--- a/include/linux/ieee802154.h
+++ b/include/linux/ieee802154.h
@@ -58,6 +58,22 @@
 #define IEEE802154_MAX_CHANNEL         26
 #define IEEE802154_MAX_PAGE            31

+#define IEEE802154_CHAN_750M_O_QPSK        0xf          /* 750 MHz O-QPSK 802.15.4c-2009 */
+#define IEEE802154_CHAN_750M_MPSK          0xf0         /* 750 MHz MPSK 802.15.4c-2009 */
+#define IEEE802154_CHAN_868M_ASK           0x1          /* 868 MHz ASK 802.15.4-2006 */
+#define IEEE802154_CHAN_868M_BPSK          0x1          /* 868 MHz BPSK 802.15.4-2003 */
+#define IEEE802154_CHAN_868M_O_QPSK        0x1          /* 868 MHz O-QPSK 802.15.4-2006 */
+#define IEEE802154_CHAN_915M_ASK           0x7FE        /* 915 MHz ASK 802.15.4-2006 */
+#define IEEE802154_CHAN_915M_BPSK          0x7FE        /* 915 MHz BPSK 802.15.4-2003 */
+#define IEEE802154_CHAN_915M_O_QPSK        0x7FE        /* 915 MHz O-QPSK 802.15.4-2006 */
+#define IEEE802154_CHAN_950M_BPSK          0x3FF        /* 950 MHz BPSK 802.15.4d-2009 */
+#define IEEE802154_CHAN_950M_GFSK          0x3FFC00     /* 950 MHz GFSK 802.15.4d-2009 */
+#define IEEE802154_CHAN_2D4G_O_QPSK        0x7FFF800    /* 2.4 GHz O-QPSK 802.15.4-2003 */
+#define IEEE802154_CHAN_2D4G_CSS           0x3FFF       /* 2.4 GHz CSS 802.15.4a-2007 */
+#define IEEE802154_CHAN_UWB_SUBGIGA        0x1          /* UWB Sub-gigahertz 802.15.4a-2007 */
+#define IEEE802154_CHAN_UWB_LOWBAND        0x1E         /* UWB Low Band 802.15.4a-2007 */
+#define IEEE802154_CHAN_UWB_HIGHBAND       0xFFE0       /* UWB High Band 802.15.4a-2007 */
+
 #define IEEE802154_FC_TYPE_BEACON      0x0     /* Frame is beacon */
 #define        IEEE802154_FC_TYPE_DATA         0x1     /* Frame is data */
 #define IEEE802154_FC_TYPE_ACK         0x2     /* Frame is acknowledgment */
--
2.44.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] net/ieee802154: use channel mask macros replace the hard-coded magic number
  2025-11-25 15:11     ` Miquel Raynal
  2025-11-26  6:14       ` [PATCH v2 1/2] include: add macros for ieee 802.15.4 channel masks Les Boys
@ 2025-11-26  6:16       ` Les Boys
  1 sibling, 0 replies; 6+ messages in thread
From: Les Boys @ 2025-11-26  6:16 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: linux-kernel@vger.kernel.org, alex.aring@gmail.com,
	stefan@datenfreihafen.org, Miquel Raynal

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

Signed-off-by: Les Boys <lesboyspp43@outlook.com>
---
 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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-26  6:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-25  8:56 [PATCH v1 0/2] ieee802154: use macros to replace hard-coded channel masks Les Boys
2025-11-25  9:36 ` [PATCH v1 1/2] include: add macros for ieee 802.15.4 " Les Boys
2025-11-25  9:41   ` [PATCH v1 2/2] net/ieee802154: use channel mask macros replace the hard-coded magic number Les Boys
2025-11-25 15:11     ` Miquel Raynal
2025-11-26  6:14       ` [PATCH v2 1/2] include: add macros for ieee 802.15.4 channel masks Les Boys
2025-11-26  6:16       ` [PATCH v2 2/2] net/ieee802154: use channel mask macros replace the hard-coded magic number Les Boys

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.