On 2021-01-08 18:34, Lorenzo Bianconi wrote: > Update mcu country code running mt7615_mcu_set_channel_domain routine in > mt7615_regd_notifier(). > Filter out disabled channels in mt7615_mcu_set_channel_domain(). > > Signed-off-by: Lorenzo Bianconi <lorenzo@xxxxxxxxxx> > --- > drivers/net/wireless/mediatek/mt76/mt76.h | 1 + > .../net/wireless/mediatek/mt76/mt7615/init.c | 10 +++-- > .../net/wireless/mediatek/mt76/mt7615/mcu.c | 43 +++++++++++++------ > .../wireless/mediatek/mt76/mt7615/mt7615.h | 3 ++ > 4 files changed, 40 insertions(+), 17 deletions(-) > > diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h > index 10034c21f812..5c86ade0aa1e 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt76.h > +++ b/drivers/net/wireless/mediatek/mt76/mt76.h > @@ -647,6 +647,7 @@ struct mt76_dev { > > struct mt76_rate_power rate_power; > > + char alpha2[3]; > enum nl80211_dfs_regions region; > > u32 debugfs_reg; > diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/init.c b/drivers/net/wireless/mediatek/mt76/mt7615/init.c > index a73b76e57c7f..635b94de1021 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt7615/init.c > +++ b/drivers/net/wireless/mediatek/mt76/mt7615/init.c > @@ -296,13 +296,15 @@ mt7615_regd_notifier(struct wiphy *wiphy, > struct mt7615_phy *phy = mphy->priv; > struct cfg80211_chan_def *chandef = &mphy->chandef; > > + memcpy(dev->mt76.alpha2, request->alpha2, sizeof(dev->mt76.alpha2)); > dev->mt76.region = request->dfs_region; > > - if (!(chandef->chan->flags & IEEE80211_CHAN_RADAR)) > - return; > - > mt7615_mutex_acquire(dev); > - mt7615_dfs_init_radar_detector(phy); > + > + if (chandef->chan->flags & IEEE80211_CHAN_RADAR) > + mt7615_dfs_init_radar_detector(phy); > + mt7615_mcu_set_channel_domain(phy); > + > mt7615_mutex_release(dev); > } > > diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c > index c49e9041006f..715423c325e1 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c > +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c > @@ -2981,6 +2981,7 @@ int mt7615_mcu_set_channel_domain(struct mt7615_phy *phy) > { > struct mt76_phy *mphy = phy->mt76; > struct mt7615_dev *dev = phy->dev; > + u32 country_code = MT76_ALPHA2_TO_CC(dev->mt76.alpha2); > struct mt7615_mcu_channel_domain { > __le32 country_code; /* regulatory_request.alpha2 */ > u8 bw_2g; /* BW_20_40M 0 > @@ -2995,45 +2996,61 @@ int mt7615_mcu_set_channel_domain(struct mt7615_phy *phy) > u8 n_5ch; > __le16 pad2; > } __packed hdr = { > + .country_code = cpu_to_le32(country_code), Instead of converting alpha2 to a cpu-endian u32 and then turning it back into LE, you should be able to simply add u8 country_code[4] and memcpy the request alpha2 to it without any order swapping. - Felix