gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / net / wireless / mediatek / mt76 / mt76x0 / main.c
blob700ae9c12f1db3c3a4c1a07a357232bd3a72d113
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
4 * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
5 * Copyright (C) 2018 Stanislaw Gruszka <stf_xl@wp.pl>
6 */
8 #include <linux/etherdevice.h>
9 #include "mt76x0.h"
11 static void
12 mt76x0_set_channel(struct mt76x02_dev *dev, struct cfg80211_chan_def *chandef)
14 cancel_delayed_work_sync(&dev->cal_work);
15 mt76x02_pre_tbtt_enable(dev, false);
16 if (mt76_is_mmio(&dev->mt76))
17 tasklet_disable(&dev->dfs_pd.dfs_tasklet);
19 mt76_set_channel(&dev->mphy);
20 mt76x0_phy_set_channel(dev, chandef);
22 mt76x02_mac_cc_reset(dev);
23 mt76x02_edcca_init(dev);
25 if (mt76_is_mmio(&dev->mt76)) {
26 mt76x02_dfs_init_params(dev);
27 tasklet_enable(&dev->dfs_pd.dfs_tasklet);
29 mt76x02_pre_tbtt_enable(dev, true);
31 mt76_txq_schedule_all(&dev->mphy);
34 int mt76x0_config(struct ieee80211_hw *hw, u32 changed)
36 struct mt76x02_dev *dev = hw->priv;
38 mutex_lock(&dev->mt76.mutex);
40 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
41 ieee80211_stop_queues(hw);
42 mt76x0_set_channel(dev, &hw->conf.chandef);
43 ieee80211_wake_queues(hw);
46 if (changed & IEEE80211_CONF_CHANGE_POWER) {
47 dev->txpower_conf = hw->conf.power_level * 2;
49 if (test_bit(MT76_STATE_RUNNING, &dev->mphy.state))
50 mt76x0_phy_set_txpower(dev);
53 if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
54 if (!(hw->conf.flags & IEEE80211_CONF_MONITOR))
55 dev->mt76.rxfilter |= MT_RX_FILTR_CFG_PROMISC;
56 else
57 dev->mt76.rxfilter &= ~MT_RX_FILTR_CFG_PROMISC;
59 mt76_wr(dev, MT_RX_FILTR_CFG, dev->mt76.rxfilter);
62 mutex_unlock(&dev->mt76.mutex);
64 return 0;
66 EXPORT_SYMBOL_GPL(mt76x0_config);