From patchwork Wed Apr 4 08:23:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10322203 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74AA0602C8 for ; Wed, 4 Apr 2018 08:23:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6384C28DEE for ; Wed, 4 Apr 2018 08:23:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 588EF28DF0; Wed, 4 Apr 2018 08:23:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00E2428DEE for ; Wed, 4 Apr 2018 08:23:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751313AbeDDIXz (ORCPT ); Wed, 4 Apr 2018 04:23:55 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:37957 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751167AbeDDIXx (ORCPT ); Wed, 4 Apr 2018 04:23:53 -0400 Received: by mail-wr0-f193.google.com with SMTP id m13so21161466wrj.5 for ; Wed, 04 Apr 2018 01:23:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qHImQCpHWTCXVQNwza2U2BSTjiQ6gRUzsoizEzqQ0Qg=; b=ke2ylJQozie/8TeykwTZDhsgptxNBU2+acxDpC9vHtfOsO70cS8mcH+BLtStv4ZfKI Cz+k8qoSddWpudtQxTUxe2C/8vfKLFmi6iqzAJhb7Sj8wMvQvGxnAjZdEn5qsUlaSk4k fTh4SbOlKi+s3Ea9xVATF2tZAQqZ4AaUkcAsaWnzC42cU+D93n3TBMsA5x5fyYb2LDNT bQTX8cymMVaJTNFPIIe/dpiQMusNtvpjQEC6jpYCDThosgLAC+pjCaqoMF15b/jkdHws ZMmb3MGs8d/V61+VdpUgQiRlyWcmhX7z4VtZLEN7GEaUGHtdGNshNYZWCVYiL6j6PmJN +Slw== X-Gm-Message-State: AElRT7FrH2J4sJumBokR5yofyaxXDa/s0aQWXxrJiQ82gEnHDuwDZaE8 6StpF6mgaJcRmwvT+ntipLcxMM5mOW0= X-Google-Smtp-Source: AIpwx4+7ANjRd7arqrZOCiizUsxgTYplCBvI5ModBnggQTaAv4KL/5jJ+pgsvfCPlzJphKjmVM6m3A== X-Received: by 10.223.172.45 with SMTP id v42mr12945536wrc.2.1522830232234; Wed, 04 Apr 2018 01:23:52 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id 11sm4491357wmd.1.2018.04.04.01.23.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Apr 2018 01:23:51 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org Subject: [PATCH] mt76x2: fix tx_alc_enabled check Date: Wed, 4 Apr 2018 10:23:46 +0200 Message-Id: <8143b57af86d4bdd5764f86cf53a0cfdcbfe9bea.1522828102.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix mt76x2_temp_tx_alc_enabled routine since in order to enable tx_alc temperature compensation it necessary to take into account BIT(15) of MT_EE_TX_POWER_EXT_PA_5G eeprom info Fixes: 7bc04215a66b ("mt76: add driver code for MT76x2e") Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c | 6 +----- drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c index 5bb50027c1e8..95d5f7d888f0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c @@ -609,17 +609,13 @@ int mt76x2_get_temp_comp(struct mt76x2_dev *dev, struct mt76x2_temp_comp *t) memset(t, 0, sizeof(*t)); - val = mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_1); - if (!(val & MT_EE_NIC_CONF_1_TEMP_TX_ALC)) + if (!mt76x2_temp_tx_alc_enabled(dev)) return -EINVAL; if (!mt76x2_ext_pa_enabled(dev, band)) return -EINVAL; val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_EXT_PA_5G) >> 8; - if (!(val & BIT(7))) - return -EINVAL; - t->temp_25_ref = val & 0x7f; if (band == NL80211_BAND_5GHZ) { slope = mt76x2_eeprom_get(dev, MT_EE_RF_TEMP_COMP_SLOPE_5G); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h index d79122728dca..aa0b0c040375 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h @@ -159,6 +159,12 @@ void mt76x2_read_rx_gain(struct mt76x2_dev *dev); static inline bool mt76x2_temp_tx_alc_enabled(struct mt76x2_dev *dev) { + u16 val; + + val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_EXT_PA_5G); + if (!(val & BIT(15))) + return false; + return mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_1) & MT_EE_NIC_CONF_1_TEMP_TX_ALC; }