diff options
author | Miquel Raynal <miquel.raynal@bootlin.com> | 2023-01-03 17:56:41 +0100 |
---|---|---|
committer | Stefan Schmidt <stefan@datenfreihafen.org> | 2023-01-03 19:36:53 +0100 |
commit | d2aaf2a01792ccf214f933d0b1ca2d41788c7b16 (patch) | |
tree | f3b5c28acaa821dbb79595158a8c4a67131c2afc /include/net/cfg802154.h | |
parent | 44def58f5835bbfaf81902c88460fd86a551f4b7 (diff) | |
download | linux-stable-d2aaf2a01792ccf214f933d0b1ca2d41788c7b16.tar.gz linux-stable-d2aaf2a01792ccf214f933d0b1ca2d41788c7b16.tar.bz2 linux-stable-d2aaf2a01792ccf214f933d0b1ca2d41788c7b16.zip |
ieee802154: Introduce a helper to validate a channel
This helper for now only checks if the page member and channel member
are valid (in the specification range) and supported (by checking the
device capabilities). Soon two new parameters will be introduced and
having this helper will let us only modify its content rather than
modifying the logic everywhere else in the subsystem.
There is not functional change.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Alexander Aring <aahringo@redhat.com>
Link: https://lore.kernel.org/r/20230103165644.432209-4-miquel.raynal@bootlin.com
Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
Diffstat (limited to 'include/net/cfg802154.h')
-rw-r--r-- | include/net/cfg802154.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h index 76d4f95e9974..1184b543fba7 100644 --- a/include/net/cfg802154.h +++ b/include/net/cfg802154.h @@ -246,6 +246,17 @@ static inline void wpan_phy_net_set(struct wpan_phy *wpan_phy, struct net *net) write_pnet(&wpan_phy->_net, net); } +static inline bool ieee802154_chan_is_valid(struct wpan_phy *phy, + u8 page, u8 channel) +{ + if (page > IEEE802154_MAX_PAGE || + channel > IEEE802154_MAX_CHANNEL || + !(phy->supported.channels[page] & BIT(channel))) + return false; + + return true; +} + /** * struct ieee802154_addr - IEEE802.15.4 device address * @mode: Address mode from frame header. Can be one of: |