mt76x0: use bus helper to identify rf access method
authorStanislaw Gruszka <sgruszka@redhat.com>
Thu, 4 Oct 2018 10:04:55 +0000 (12:04 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sat, 13 Oct 2018 15:39:14 +0000 (17:39 +0200)
Use mt76_is_usb() to identify RF access method instead of
MT76_STATE_MCU_RUNNING flag and add warning since MCU has
to be initialized before we can access RF registers via MCU.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76x0/phy.c

index d4483a5ab056505fef62336f6958c54084daeb23..e2b62ce2306b2ac2727aaf2cec6ddf9b92260337 100644 (file)
@@ -111,12 +111,14 @@ out:
 static int
 rf_wr(struct mt76x02_dev *dev, u32 offset, u8 val)
 {
-       if (test_bit(MT76_STATE_MCU_RUNNING, &dev->mt76.state)) {
+       if (mt76_is_usb(dev)) {
                struct mt76_reg_pair pair = {
                        .reg = offset,
                        .value = val,
                };
 
+               WARN_ON_ONCE(!test_bit(MT76_STATE_MCU_RUNNING,
+                            &dev->mt76.state));
                return mt76_wr_rp(dev, MT_MCU_MEMMAP_RF, &pair, 1);
        } else {
                return mt76x0_rf_csr_wr(dev, offset, val);
@@ -129,11 +131,13 @@ rf_rr(struct mt76x02_dev *dev, u32 offset)
        int ret;
        u32 val;
 
-       if (test_bit(MT76_STATE_MCU_RUNNING, &dev->mt76.state)) {
+       if (mt76_is_usb(dev)) {
                struct mt76_reg_pair pair = {
                        .reg = offset,
                };
 
+               WARN_ON_ONCE(!test_bit(MT76_STATE_MCU_RUNNING,
+                            &dev->mt76.state));
                ret = mt76_rd_rp(dev, MT_MCU_MEMMAP_RF, &pair, 1);
                val = pair.value;
        } else {