net/ieee802154: Verify in L2 the Sub-Ghz channel value
Depending on device's band, the upper channel limit can vary a lot in Sub-Ghz. Thus verifying it directly in L2 before requesting it to the device. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
9aa2f45d23
commit
6fa3d0fa3e
@ -389,6 +389,10 @@ static int ieee802154_set_parameters(u32_t mgmt_request,
|
||||
|
||||
if (mgmt_request == NET_REQUEST_IEEE802154_SET_CHANNEL) {
|
||||
if (ctx->channel != value) {
|
||||
if (!ieee802154_verify_channel(iface->dev, value)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = radio->set_channel(iface->dev, value);
|
||||
if (!ret) {
|
||||
ctx->channel = value;
|
||||
|
||||
@ -68,4 +68,19 @@ static inline void ieee802154_filter_pan_id(struct net_if *iface,
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool ieee802154_verify_channel(struct device *dev, u16_t channel)
|
||||
{
|
||||
#ifdef CONFIG_NET_L2_IEEE802154_SUB_GHZ
|
||||
const struct ieee802154_radio_api *radio = dev->driver_api;
|
||||
|
||||
if (radio->get_capabilities(dev) & IEEE802154_HW_SUB_GHZ) {
|
||||
if (channel > radio->get_subg_channel_count(dev)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_NET_L2_IEEE802154_SUB_GHZ */
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /* __IEEE802154_UTILS_H__ */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user