From patchwork Fri Aug 10 23:39:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10563221 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-2.web.codeaurora.org (Postfix) with ESMTP id 6E4DF1804 for ; Fri, 10 Aug 2018 23:40:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 613BA2B25E for ; Fri, 10 Aug 2018 23:40:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5587A2B2B9; Fri, 10 Aug 2018 23:40:21 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 007B92B25E for ; Fri, 10 Aug 2018 23:40:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727139AbeHKCLz (ORCPT ); Fri, 10 Aug 2018 22:11:55 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:38035 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726747AbeHKCLz (ORCPT ); Fri, 10 Aug 2018 22:11:55 -0400 Received: by mail-pl0-f66.google.com with SMTP id u11-v6so4636406plq.5 for ; Fri, 10 Aug 2018 16:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SHkDb6qaKxPT3RKCwWTlK162HxGfwzC3DwW8Inu+HKk=; b=QyQ+jWboymP+kH1M8h+mDOk+EuHT0IQANJmMmzwTKJaJ3fxH9ag4EqOiXcQTc7aSbR pi46WirGbtb8a+6eOORZ5bcUys6xC0xqbUMxfGT6grh8RhSrAvUR6QdfLUEB+ysUrOk/ QPU9J+NCJ3jnXpAOuEqa2FbRfolJCNTcIsZmQ= 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:mime-version :content-transfer-encoding; bh=SHkDb6qaKxPT3RKCwWTlK162HxGfwzC3DwW8Inu+HKk=; b=oUI99buiDrCpb/tEb/ElTf2BLCWQ68wV8r4li7PFWSYIV+RvAU1eEhrT9QfIDhJMRV ZDAG3XTpK5jhQgkXUxIlvOKMnC8O+r+yxM/UB0lkQMHwMhR5KFp9mdt+YPdjLUN4ytZ0 Q0jU5lhWbsPOzt3EQ2vrXPuhTff7XnURtwoc2Lua5O13TR9TcljOIUXOlxOBSJMjSHHj t7unFzJHy9ZGqzFxa93FlvHvpXZixUeB9iTgPXlb9HmEEejXOhersS5PwsNGVWWqewv7 sUrl3jnWH32GH4/T+6+VpTjCwzN1FaJgJlFAZW7Zp6vt8dPxGlHG4xM6sfa7MJhFAtWA 5jDg== X-Gm-Message-State: AOUpUlHxWsRTvhwuMbb/k7T7kw/CGA94BO7syhMUZIO38vqCelhw42aU ZO5XgswIFS8Zob0dpWk9ZGyQZA== X-Google-Smtp-Source: AA+uWPwIebREHfzipAAji/gNIqAwhcDRpKSeN9BR7Bf1oFbAPKC7VCriFDmtKbBqJiG23KAhpKnAMg== X-Received: by 2002:a17:902:e85:: with SMTP id 5-v6mr7798101plx.73.1533944393185; Fri, 10 Aug 2018 16:39:53 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:299d:6b87:5478:d28a]) by smtp.gmail.com with ESMTPSA id 75-v6sm20985577pfr.115.2018.08.10.16.39.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Aug 2018 16:39:51 -0700 (PDT) From: Brian Norris To: Kalle Valo Cc: ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, Govind Singh , , Brian Norris Subject: [PATCH] ath10k: retrieve MAC address from firmware if provided Date: Fri, 10 Aug 2018 16:39:48 -0700 Message-Id: <20180810233948.144792-1-briannorris@chromium.org> X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-goog MIME-Version: 1.0 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 Devices may provide their own MAC address via system firmware (e.g., device tree), especially in the case where the device doesn't have a useful EEPROM on which to store its MAC address (e.g., for integrated Wifi). Use the generic device helper to retrieve the MAC address, and (if present) honor it above the MAC address advertised by the card. Signed-off-by: Brian Norris --- drivers/net/wireless/ath/ath10k/core.c | 3 +++ drivers/net/wireless/ath/ath10k/wmi.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index c40cd129afe7..840c1f039098 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -2602,6 +2603,8 @@ static int ath10k_core_probe_fw(struct ath10k *ar) ath10k_debug_print_board_info(ar); } + device_get_mac_address(ar->dev, ar->mac_addr, sizeof(ar->mac_addr)); + ret = ath10k_core_init_firmware_features(ar); if (ret) { ath10k_err(ar, "fatal problem with firmware features: %d\n", diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c index fd612d2905b0..3cfd98de8ad2 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c @@ -5449,7 +5449,8 @@ int ath10k_wmi_event_ready(struct ath10k *ar, struct sk_buff *skb) arg.mac_addr, __le32_to_cpu(arg.status)); - ether_addr_copy(ar->mac_addr, arg.mac_addr); + if (is_zero_ether_addr(ar->mac_addr)) + ether_addr_copy(ar->mac_addr, arg.mac_addr); complete(&ar->wmi.unified_ready); return 0; }