From patchwork Thu Nov 9 23:38:26 2017 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: 10052093 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 985056032D for ; Thu, 9 Nov 2017 23:40:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B7282B1C6 for ; Thu, 9 Nov 2017 23:40:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8070D2B1BA; Thu, 9 Nov 2017 23:40:11 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 3482C2B1C1 for ; Thu, 9 Nov 2017 23:40:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755404AbdKIXjo (ORCPT ); Thu, 9 Nov 2017 18:39:44 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:54357 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755248AbdKIXiz (ORCPT ); Thu, 9 Nov 2017 18:38:55 -0500 Received: by mail-wr0-f196.google.com with SMTP id l22so7080747wrc.11; Thu, 09 Nov 2017 15:38:54 -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=GZ3+nPWiEwE7z5pJpWRagpAFjjwKra2TbDmsyklJUkw=; b=Pae6lw+tYw+8YF/TCANX5H4SQ0sNIYYDcmJhJv+eB2jSwxy73DqBlLR5KZ+68TxmtF Ony5icWsXMYvx+dP9vDj2DtcJWkDwgPjDq8rwYyHM+NCcthnoZjHeXFPdo7Aazt2E4Yh wlojIy0Y3uAJe73oJgm/9tL4Lo51J0oGI48ytbvPIIVuxbNhwXCbzTuWDpkQJBbCJ8zs 2Twco0FrsgxZ901NeIHOk7AzWQc37ldVZgO9fFKDSwE50Cjwbpp0uFshyie+6ym80b0f FvgpMxEU6ohwOuVPXuUJzWysz2eah5V6Rz5EOD995ewzyMFiQ9C00zrJoqAUrzysfjY0 Ng/A== 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=GZ3+nPWiEwE7z5pJpWRagpAFjjwKra2TbDmsyklJUkw=; b=lhNEUHdR5tFn5gY2AmCWj5WnvaKw1pEGFvDXGwpGliZ9MECe2mqg2zc/tObAfixe1g xqrlQHfOr8asPZQ+pvLlL13V9T26be/E7Sd/y2ZKugdUMj1+cpcBby3K34HyNKxfF7aC KDlahHUCBYr72Su18kVAwxX0WXFuAl5+HNUPbsIjQx8wABKyRnDm8J+zgfy/M767OURr QFHmb/IXhy5hnmktDCJP5gQU5iTxLXhxI1VeyuG99V3dsiudRUeTcf4MFm1WR2x7KKFP SDWMpOKobfwrgSjKVR4OH10OIhr8/VQsbjs8sp27RgQyGKdcIYSXm0WZea8PCC4JZW2k juSQ== X-Gm-Message-State: AJaThX4uvXzKhFQLyJhQPocEzjxIvVKsr4y1vzqGPpFlhG5I9XeAzw/T W2ksFMMftBo4Chl4fJA8MRs= X-Google-Smtp-Source: ABhQp+SSZYoWE97WsPOtd8S/4bu2dbfs0QrbrB9cRgw6RHFv1AYEZDswciQaq4u4ko+dWWAUKGuCKw== X-Received: by 10.223.132.101 with SMTP id 92mr1710105wrf.85.1510270733715; Thu, 09 Nov 2017 15:38:53 -0800 (PST) Received: from Pali-Latitude.lan (pali.kolej.mff.cuni.cz. [78.128.193.202]) by smtp.gmail.com with ESMTPSA id 55sm9578181wrw.60.2017.11.09.15.38.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Nov 2017 15:38:53 -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 v2 4/6] wl1251: Set generated MAC address back to NVS data Date: Fri, 10 Nov 2017 00:38:26 +0100 Message-Id: <1510270708-14377-5-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1510270708-14377-1-git-send-email-pali.rohar@gmail.com> References: <1482598381-16513-1-git-send-email-pali.rohar@gmail.com> <1510270708-14377-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. This should not change any functionality, but it is better to tell wl1251 correct mac address since beginning of chip usage. Signed-off-by: Pali Rohár --- drivers/net/wireless/ti/wl1251/main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/wireless/ti/wl1251/main.c b/drivers/net/wireless/ti/wl1251/main.c index d497ba5..1f423be 100644 --- a/drivers/net/wireless/ti/wl1251/main.c +++ b/drivers/net/wireless/ti/wl1251/main.c @@ -1481,6 +1481,21 @@ static int wl1251_read_nvs_mac(struct wl1251 *wl) return 0; } +static int wl1251_write_nvs_mac(struct wl1251 *wl) +{ + int i, ret; + + ret = wl1251_check_nvs_mac(wl); + if (ret) + return ret; + + /* MAC is stored in reverse order */ + for (i = 0; i < ETH_ALEN; i++) + wl->nvs[NVS_OFF_MAC_DATA + i] = wl->mac_addr[ETH_ALEN - i - 1]; + + return 0; +} + static int wl1251_register_hw(struct wl1251 *wl) { int ret; @@ -1546,6 +1561,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); }