From patchwork Thu Feb 8 22:08:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10208071 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 3E906602D8 for ; Thu, 8 Feb 2018 22:08:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28236296B7 for ; Thu, 8 Feb 2018 22:08:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BBD8296BC; Thu, 8 Feb 2018 22:08:29 +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 AD71F296B7 for ; Thu, 8 Feb 2018 22:08:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752394AbeBHWI1 (ORCPT ); Thu, 8 Feb 2018 17:08:27 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:39669 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752322AbeBHWI0 (ORCPT ); Thu, 8 Feb 2018 17:08:26 -0500 Received: by mail-wm0-f66.google.com with SMTP id b21so12790603wme.4 for ; Thu, 08 Feb 2018 14:08:25 -0800 (PST) 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=g72CRLniCuXnug5peDYAQ29Gs7n5QZW01T34yj/kgDY=; b=Zp196ANbMEq/pWqErp1vni3ZAn8kVGGq0LvwdwL/RaFW568GvLH0nJlF5j8jyRHmpB +3l9d2EW3dPCtOXp7+aWBMtKXVnYAsWJzYSiAXpXF2DUPse2qqEpxWhawJbj+N4LGkE5 +QY+3u7kj1Px+SrPy9kGRUnKnT8hY26IvTb7IJPy40vbT8KSnkea/VCHMj3gRqLDn6gF yAEm3Up4lcW2B3GdbLrltW9IkHRBJQauuiCnLwFUNLS4zAY8bSo+65H2WW/5Xr9p0ZKw dvkMyBoTZohn6OMsFRlbgpTrKRukzY4jhXv6ePlKRSAoS1WNQJ82i+jn5pmsmKwY521l s0fQ== X-Gm-Message-State: APf1xPDdHNntjArmJp1WZnBnafxRiFc1/rPHfGzeHWcN1zOfPTDQNwC+ LtLcClvrGVXEy/Rs77y1WE96kA== X-Google-Smtp-Source: AH8x227OLOIH3KZUzykKhTEYwpbKpBYfzvx05gGZB+WzU/0F5AdEoBW61FYATQfaCewMWwxFiL6jew== X-Received: by 10.28.186.66 with SMTP id k63mr335183wmf.156.1518127705148; Thu, 08 Feb 2018 14:08:25 -0800 (PST) Received: from localhost.localdomain.com ([151.66.66.80]) by smtp.gmail.com with ESMTPSA id a18sm1123904wra.56.2018.02.08.14.08.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Feb 2018 14:08:24 -0800 (PST) From: Lorenzo Bianconi To: kubakici@wp.pl Cc: linux-wireless@vger.kernel.org Subject: [PATCH 1/2] mt7601u: move mt7601u_set_macaddr in mac related code Date: Thu, 8 Feb 2018 23:08:08 +0100 Message-Id: <05bb725e26b34bfc88b515110b0fcfb2c6b2303e.1518126991.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 Remove static qualifier from mt7601u_set_macaddr routine and move it in mac related code in order to be used to properly support vif with different mac address respect to the default one Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt7601u/eeprom.c | 24 ++---------------------- drivers/net/wireless/mediatek/mt7601u/mac.c | 16 ++++++++++++++++ drivers/net/wireless/mediatek/mt7601u/mac.h | 1 + 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt7601u/eeprom.c b/drivers/net/wireless/mediatek/mt7601u/eeprom.c index da6faea092d6..05d729be0c65 100644 --- a/drivers/net/wireless/mediatek/mt7601u/eeprom.c +++ b/drivers/net/wireless/mediatek/mt7601u/eeprom.c @@ -19,6 +19,7 @@ #include #include "mt7601u.h" #include "eeprom.h" +#include "mac.h" static bool field_valid(u8 val) @@ -134,27 +135,6 @@ mt7601u_set_chip_cap(struct mt7601u_dev *dev, u8 *eeprom) "Error: device has more than 1 RX/TX stream!\n"); } -static int -mt7601u_set_macaddr(struct mt7601u_dev *dev, const u8 *eeprom) -{ - const void *src = eeprom + MT_EE_MAC_ADDR; - - ether_addr_copy(dev->macaddr, src); - - if (!is_valid_ether_addr(dev->macaddr)) { - eth_random_addr(dev->macaddr); - dev_info(dev->dev, - "Invalid MAC address, using random address %pM\n", - dev->macaddr); - } - - mt76_wr(dev, MT_MAC_ADDR_DW0, get_unaligned_le32(dev->macaddr)); - mt76_wr(dev, MT_MAC_ADDR_DW1, get_unaligned_le16(dev->macaddr + 4) | - FIELD_PREP(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff)); - - return 0; -} - static void mt7601u_set_channel_target_power(struct mt7601u_dev *dev, u8 *eeprom, u8 max_pwr) { @@ -400,7 +380,7 @@ mt7601u_eeprom_init(struct mt7601u_dev *dev) dev_info(dev->dev, "EEPROM ver:%02hhx fae:%02hhx\n", eeprom[MT_EE_VERSION_EE], eeprom[MT_EE_VERSION_FAE]); - mt7601u_set_macaddr(dev, eeprom); + mt7601u_set_macaddr(dev, eeprom + MT_EE_MAC_ADDR); mt7601u_set_chip_cap(dev, eeprom); mt7601u_set_channel_power(dev, eeprom); mt7601u_set_country_reg(dev, eeprom); diff --git a/drivers/net/wireless/mediatek/mt7601u/mac.c b/drivers/net/wireless/mediatek/mt7601u/mac.c index d6dc59bb00df..4d3077941138 100644 --- a/drivers/net/wireless/mediatek/mt7601u/mac.c +++ b/drivers/net/wireless/mediatek/mt7601u/mac.c @@ -16,6 +16,22 @@ #include "trace.h" #include +void mt7601u_set_macaddr(struct mt7601u_dev *dev, const u8 *addr) +{ + ether_addr_copy(dev->macaddr, addr); + + if (!is_valid_ether_addr(dev->macaddr)) { + eth_random_addr(dev->macaddr); + dev_info(dev->dev, + "Invalid MAC address, using random address %pM\n", + dev->macaddr); + } + + mt76_wr(dev, MT_MAC_ADDR_DW0, get_unaligned_le32(dev->macaddr)); + mt76_wr(dev, MT_MAC_ADDR_DW1, get_unaligned_le16(dev->macaddr + 4) | + FIELD_PREP(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff)); +} + static void mt76_mac_process_tx_rate(struct ieee80211_tx_rate *txrate, u16 rate) { diff --git a/drivers/net/wireless/mediatek/mt7601u/mac.h b/drivers/net/wireless/mediatek/mt7601u/mac.h index 2c22d63c63a2..b7aa24656d0e 100644 --- a/drivers/net/wireless/mediatek/mt7601u/mac.h +++ b/drivers/net/wireless/mediatek/mt7601u/mac.h @@ -174,5 +174,6 @@ u16 mt76_mac_tx_rate_val(struct mt7601u_dev *dev, struct mt76_tx_status mt7601u_mac_fetch_tx_status(struct mt7601u_dev *dev); void mt76_send_tx_status(struct mt7601u_dev *dev, struct mt76_tx_status *stat); +void mt7601u_set_macaddr(struct mt7601u_dev *dev, const u8 *addr); #endif