From patchwork Thu Jun 23 14:57:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9195399 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 343EB6075F for ; Thu, 23 Jun 2016 14:57:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25B7B2843A for ; Thu, 23 Jun 2016 14:57:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1ACB82845B; Thu, 23 Jun 2016 14:57:45 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 B0F612843A for ; Thu, 23 Jun 2016 14:57:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751286AbcFWO5n (ORCPT ); Thu, 23 Jun 2016 10:57:43 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33598 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750960AbcFWO5l (ORCPT ); Thu, 23 Jun 2016 10:57:41 -0400 Received: by mail-wm0-f67.google.com with SMTP id r201so11649419wme.0 for ; Thu, 23 Jun 2016 07:57:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wjFRq3ueBakErca7RhKDL2weQidp+m61Pe4+HrLfE1M=; b=Ff3wZeyp/SaOuDNsTOQZpBX91fOBW5U/HERFZdruVPTBzVIyBKZ9soKv2M09g1iFB4 21bcECMS8K2HzownJPr4HMsLQYEIUU7/GXh9YzQFvsh6+SRBSgi5trBxj5rb/u2B+2L0 k3JgH0Y0xyGFVSDa0Kl+GJ/2ghxGPHqgWXh6V/njXiTKQJ6i/WF0X07Oo6oI3a7+WUlH Z6N+F32HdK6WpzPvi38fHnQ1ZEVBztNQ2UIMNhHqE45Z8E7sFtX94SFQaJFAT/ch9ey7 9la026U1+4o7tlAewuJ0KcEyqZg/JW4CPy0n4wQe8FXZdrlK9464EwPNRIiseNQgVzZU 0ntQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wjFRq3ueBakErca7RhKDL2weQidp+m61Pe4+HrLfE1M=; b=Tpyji4yCfcHQxMGJ3++Q7Sqzzn06M/2ThrEf418fvoXQ5mTGUmT38FCCz3P+oFHZMr 68tcqwIsfdL34RPJmERjjdINaQaQe4bj933Ml1X7Kmdx+dT1IohacLSi4uNBAyNBRf8i +/cJPF0y1t6CIOkNTHama9TbQjZfE6oXTB9YWJBkjU2ReMHZnsCFgNwibEXW7piPazEH 6CPKcEfCpJgqCXPaNU0Pc5Uq6gjWT6YW68O2RB17oFwCCyug/QJwCSGCUaPv85CJiMiq DmDi37gL6NMDM0rz3yBLuFB1N3QvbKSjHZay46uK/b+zXNx8nzboBmVceIZWxUydYiCv IoXg== X-Gm-Message-State: ALyK8tKh0Ll7XNCDA5WEnxLlKAYpkapC1TRK3eyG8EKNMIFqdnF1/RDd4B0ZMpgRnytzng== X-Received: by 10.194.104.134 with SMTP id ge6mr23458742wjb.157.1466693860307; Thu, 23 Jun 2016 07:57:40 -0700 (PDT) Received: from blackbox.darklights.net (p200300DCD3CD1B0478F6703992958538.dip0.t-ipconnect.de. [2003:dc:d3cd:1b04:78f6:7039:9295:8538]) by smtp.googlemail.com with ESMTPSA id yr4sm535503wjc.18.2016.06.23.07.57.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jun 2016 07:57:39 -0700 (PDT) From: Martin Blumenstingl To: ath9k-devel@qca.qualcomm.com, linux-wireless@vger.kernel.org, ath9k-devel@lists.ath9k.org Cc: nbd@nbd.name, Martin Blumenstingl Subject: [PATCH 3/6] ath9k: ath9k_hw_init_macaddr should not overwrite valid MAC addresses Date: Thu, 23 Jun 2016 16:57:11 +0200 Message-Id: <20160623145714.20576-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160623145714.20576-1-martin.blumenstingl@googlemail.com> References: <20160623145714.20576-1-martin.blumenstingl@googlemail.com> 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 Currently setting the MAC address via ath9k_platform_data works only due to the order in which init.c sets common->macaddr, which is done after ath9k_hw_init_macaddr was executed. It would be better if the latter was independent of the order in which it's being called. Signed-off-by: Martin Blumenstingl --- drivers/net/wireless/ath/ath9k/hw.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 4f98ca0..4dd3aca 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -478,21 +478,25 @@ static int ath9k_hw_init_macaddr(struct ath_hw *ah) u16 eeval; static const u32 EEP_MAC[] = { EEP_MAC_LSW, EEP_MAC_MID, EEP_MAC_MSW }; + /* MAC address may already be loaded via ath9k_platform_data */ + if (is_valid_ether_addr(common->macaddr)) + return 0; + for (i = 0; i < 3; i++) { eeval = ah->eep_ops->get_eeprom(ah, EEP_MAC[i]); common->macaddr[2 * i] = eeval >> 8; common->macaddr[2 * i + 1] = eeval & 0xff; } - if (!is_valid_ether_addr(common->macaddr)) { - ath_err(common, - "eeprom contains invalid mac address: %pM\n", - common->macaddr); - random_ether_addr(common->macaddr); - ath_err(common, - "random mac address will be used: %pM\n", - common->macaddr); - } + if (is_valid_ether_addr(common->macaddr)) + return 0; + + ath_err(common, "eeprom contains invalid mac address: %pM\n", + common->macaddr); + + random_ether_addr(common->macaddr); + ath_err(common, "random mac address will be used: %pM\n", + common->macaddr); return 0; }