mt76: use mt76_poll_msec routine in mt76pci_load_firmware()
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Thu, 15 Mar 2018 17:24:20 +0000 (18:24 +0100)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 27 Mar 2018 09:10:02 +0000 (12:10 +0300)
Use mt76_poll_msec() in mt76pci_load_firmware to check if the firmware
has been started instead of explicitly poll MCU running register

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c

index 15820b1..dfd36d7 100644 (file)
@@ -187,7 +187,7 @@ mt76pci_load_firmware(struct mt76x2_dev *dev)
 {
        const struct firmware *fw;
        const struct mt76x2_fw_header *hdr;
-       int i, len, ret;
+       int len, ret;
        __le32 *cur;
        u32 offset, val;
 
@@ -240,16 +240,7 @@ mt76pci_load_firmware(struct mt76x2_dev *dev)
 
        /* trigger firmware */
        mt76_wr(dev, MT_MCU_INT_LEVEL, 2);
-       for (i = 200; i > 0; i--) {
-               val = mt76_rr(dev, MT_MCU_COM_REG0);
-
-               if (val & 1)
-                       break;
-
-               msleep(10);
-       }
-
-       if (!i) {
+       if (!mt76_poll_msec(dev, MT_MCU_COM_REG0, 1, 1, 200)) {
                dev_err(dev->mt76.dev, "Firmware failed to start\n");
                release_firmware(fw);
                return -ETIMEDOUT;