From patchwork Sat Dec 24 16:53:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 9488101 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 B38BC62AAF for ; Sat, 24 Dec 2016 17:02:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A225E2074F for ; Sat, 24 Dec 2016 17:02:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96F3521050; Sat, 24 Dec 2016 17:02:49 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 47F30209CF for ; Sat, 24 Dec 2016 17:02:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755746AbcLXRCX (ORCPT ); Sat, 24 Dec 2016 12:02:23 -0500 Received: from mail-wj0-f196.google.com ([209.85.210.196]:35755 "EHLO mail-wj0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755530AbcLXRCU (ORCPT ); Sat, 24 Dec 2016 12:02:20 -0500 Received: by mail-wj0-f196.google.com with SMTP id hb5so10979150wjc.2; Sat, 24 Dec 2016 09:02:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FdqZcYHkIKBkFRvzcyxwRzPbQ1xjuTD+3aQB16mW0Qo=; b=EY7t7+s8/09PHgCNvqWR/SALEfZL2UEJec8PWozgMjjVbOTYtojQvb5cUwlUj4vFvr kUgl5Wcq6f+aOnQ+siglG72wF/pFEYZputeEfLA1OO05RfW6qofvQBoFmZEIfNijlwgV 0RV1E26ZZwS5cHOXBYW3cAE+GofAI0sDOWTJDtdR3JmBrbAgX7oZnAGB0yANU7UAeOCD FsCXmOMeONhog/S/H41YXW+D1ba2d4AywAD6eQnQI8xZ0xVUT3iPoObp1VtxCRtdEkwb DVAmG6wO8XV0yoq+ByrNQGC0SA5zQ6iORCW8GnXTgnUCmuPiz3/7BSDFfZpctBkk/bYw 57Qg== 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:mime-version:content-transfer-encoding; bh=FdqZcYHkIKBkFRvzcyxwRzPbQ1xjuTD+3aQB16mW0Qo=; b=LzguO6bzZFPjGOdxtqcTJskTa8IqF99OqN13Iwz87d4SdzTGVN5giCrbkra0VNglRW Em7gb5yzeCosBFLWD9Ctnn4vbnh5JK7WWvcWUAQD2XEMQ6l6O3yPVST2a2llBOFS5bG8 GIdK5zGTvULKQmy8R4nB8GOnKNS8SU3R6PLo2iIj6L/FmLZu0sOreNIFZRgdD9GoBBpQ d4Lo9JYuR06aNPH2NzWRg1w+xaPrgqNtUKYJhlbrGgi6e42or9+CgtWjDZ01XMy6om2J euhKD9BN315XEQDSq/jz9W3TY90xQ2zDGGfx3+bWdc2D0/hPlha1GYnKyW9KUd1RDzcJ ByXA== X-Gm-Message-State: AIkVDXKdUKIIDHfBSzE6syKHI5qiGvy/noQtdDjWcU0KNP/40GD0pwDKh22LrDKh9D4BXg== X-Received: by 10.194.41.228 with SMTP id i4mr17518523wjl.223.1482598454508; Sat, 24 Dec 2016 08:54:14 -0800 (PST) Received: from localhost.localdomain (ip-88-212-34-237.antik.sk. [88.212.34.237]) by smtp.gmail.com with ESMTPSA id b15sm42736940wma.5.2016.12.24.08.54.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Dec 2016 08:54:13 -0800 (PST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Ming Lei , "Luis R. Rodriguez" , Greg Kroah-Hartman , Kalle Valo , David Gnedt , Michal Kazior , Daniel Wagner , Tony Lindgren , Sebastian Reichel , Pavel Machek , Ivaylo Dimitrov , Aaro Koskinen , Grazvydas Ignotas Cc: linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH 6/6] wl1251: Set generated MAC address back to NVS data Date: Sat, 24 Dec 2016 17:53:01 +0100 Message-Id: <1482598381-16513-7-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1482598381-16513-1-git-send-email-pali.rohar@gmail.com> References: <1482598381-16513-1-git-send-email-pali.rohar@gmail.com> 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 In case there is no valid MAC address kernel generates random one. This patch propagate this generated MAC address back to NVS data which will be uploaded to wl1251 chip. So HW would have same MAC address as linux kernel uses. Signed-off-by: Pali Rohár --- drivers/net/wireless/ti/wl1251/main.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/net/wireless/ti/wl1251/main.c b/drivers/net/wireless/ti/wl1251/main.c index 1454ba2..895ae05 100644 --- a/drivers/net/wireless/ti/wl1251/main.c +++ b/drivers/net/wireless/ti/wl1251/main.c @@ -1555,6 +1555,24 @@ static int wl1251_read_nvs_mac(struct wl1251 *wl) return 0; } +static int wl1251_write_nvs_mac(struct wl1251 *wl) +{ + int i; + + if (wl->nvs_len < 0x24) + return -ENODATA; + + /* length is 2 and data address is 0x546c (mask is 0xfffe) */ + if (wl->nvs[0x19] != 2 || wl->nvs[0x1a] != 0x6d || wl->nvs[0x1b] != 0x54) + return -EINVAL; + + /* MAC is stored in reverse order */ + for (i = 0; i < ETH_ALEN; i++) + wl->nvs[0x1c + i] = wl->mac_addr[ETH_ALEN - i - 1]; + + return 0; +} + static int wl1251_register_hw(struct wl1251 *wl) { int ret; @@ -1620,6 +1638,8 @@ int wl1251_init_ieee80211(struct wl1251 *wl) static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf}; memcpy(wl->mac_addr, nokia_oui, 3); get_random_bytes(wl->mac_addr + 3, 3); + if (!wl->use_eeprom) + wl1251_write_nvs_mac(wl); wl1251_warning("MAC address in eeprom or nvs data is not valid"); wl1251_warning("Setting random MAC address: %pM", wl->mac_addr); }