OSDN Git Service

mt76x2: use common helpers for mcu_alloc_msg()/mcu_send_msg()
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Sun, 9 Sep 2018 21:58:00 +0000 (23:58 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 19 Sep 2018 10:31:37 +0000 (12:31 +0200)
Use mcu common helpers instead of mt76x2 specific routines for
mcu_alloc_msg()/mcu_send_msg(). This is a preliminary patch to
unify mt76e and mt76u mcu code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c

index 0c5a0f8..d067ad4 100644 (file)
@@ -255,8 +255,8 @@ mt76x2_mcu_function_select(struct mt76x2_dev *dev, enum mcu_function func,
            .value = cpu_to_le32(val),
        };
 
-       skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg));
-       return mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_FUN_SET_OP, true);
+       skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
+       return mt76_mcu_send_msg(dev, skb, CMD_FUN_SET_OP, true);
 }
 
 int mt76x2_mcu_load_cr(struct mt76x2_dev *dev, u8 type, u8 temp_level,
@@ -283,8 +283,8 @@ int mt76x2_mcu_load_cr(struct mt76x2_dev *dev, u8 type, u8 temp_level,
        msg.cfg = cpu_to_le32(val);
 
        /* first set the channel without the extension channel info */
-       skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg));
-       return mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_LOAD_CR, true);
+       skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
+       return mt76_mcu_send_msg(dev, skb, CMD_LOAD_CR, true);
 }
 
 int mt76x2_mcu_set_channel(struct mt76x2_dev *dev, u8 channel, u8 bw,
@@ -309,15 +309,14 @@ int mt76x2_mcu_set_channel(struct mt76x2_dev *dev, u8 channel, u8 bw,
        };
 
        /* first set the channel without the extension channel info */
-       skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg));
-       mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_SWITCH_CHANNEL_OP, true);
+       skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
+       mt76_mcu_send_msg(dev, skb, CMD_SWITCH_CHANNEL_OP, true);
 
        usleep_range(5000, 10000);
 
        msg.ext_chan = 0xe0 + bw_index;
-       skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg));
-       return mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_SWITCH_CHANNEL_OP,
-                                  true);
+       skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
+       return mt76_mcu_send_msg(dev, skb, CMD_SWITCH_CHANNEL_OP, true);
 }
 
 int mt76x2_mcu_set_radio_state(struct mt76x2_dev *dev, bool on)
@@ -331,9 +330,8 @@ int mt76x2_mcu_set_radio_state(struct mt76x2_dev *dev, bool on)
                .level = cpu_to_le32(0),
        };
 
-       skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg));
-       return mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_POWER_SAVING_OP,
-                                  true);
+       skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
+       return mt76_mcu_send_msg(dev, skb, CMD_POWER_SAVING_OP, true);
 }
 
 int mt76x2_mcu_calibrate(struct mt76x2_dev *dev, enum mcu_calibration type,
@@ -351,9 +349,8 @@ int mt76x2_mcu_calibrate(struct mt76x2_dev *dev, enum mcu_calibration type,
 
        mt76_clear(dev, MT_MCU_COM_REG0, BIT(31));
 
-       skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg));
-       ret = mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_CALIBRATION_OP,
-                                 true);
+       skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
+       ret = mt76_mcu_send_msg(dev, skb, CMD_CALIBRATION_OP, true);
        if (ret)
                return ret;
 
@@ -376,9 +373,8 @@ int mt76x2_mcu_tssi_comp(struct mt76x2_dev *dev,
                .data = *tssi_data,
        };
 
-       skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg));
-       return mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_CALIBRATION_OP,
-                                  true);
+       skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
+       return mt76_mcu_send_msg(dev, skb, CMD_CALIBRATION_OP, true);
 }
 
 int mt76x2_mcu_init_gain(struct mt76x2_dev *dev, u8 channel, u32 gain,
@@ -396,15 +392,20 @@ int mt76x2_mcu_init_gain(struct mt76x2_dev *dev, u8 channel, u32 gain,
        if (force)
                msg.channel |= cpu_to_le32(BIT(31));
 
-       skb = mt76x2_mcu_msg_alloc(&msg, sizeof(msg));
-       return mt76x2_mcu_msg_send(&dev->mt76, skb, CMD_INIT_GAIN_OP,
-                                  true);
+       skb = mt76_mcu_msg_alloc(dev, &msg, sizeof(msg));
+       return mt76_mcu_send_msg(dev, skb, CMD_INIT_GAIN_OP, true);
 }
 
 int mt76x2_mcu_init(struct mt76x2_dev *dev)
 {
+       static const struct mt76_mcu_ops mt76x2_mcu_ops = {
+               .mcu_msg_alloc = mt76x2_mcu_msg_alloc,
+               .mcu_send_msg = mt76x2_mcu_msg_send,
+       };
        int ret;
 
+       dev->mt76.mcu_ops = &mt76x2_mcu_ops;
+
        ret = mt76pci_load_rom_patch(dev);
        if (ret)
                return ret;