From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754323AbdA0Hyq (ORCPT ); Fri, 27 Jan 2017 02:54:46 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:50438 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754117AbdA0Hyo (ORCPT ); Fri, 27 Jan 2017 02:54:44 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org AA38960912 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: Pali =?utf-8?Q?Roh=C3=A1r?= Cc: Ming Lei , "Luis R. Rodriguez" , Greg Kroah-Hartman , David Gnedt , Michal Kazior , Daniel Wagner , Tony Lindgren , Sebastian Reichel , Pavel Machek , Ivaylo Dimitrov , Aaro Koskinen , Grazvydas Ignotas , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH 5/6] wl1251: Parse and use MAC address from supplied NVS data References: <1482598381-16513-1-git-send-email-pali.rohar@gmail.com> <1482598381-16513-6-git-send-email-pali.rohar@gmail.com> Date: Fri, 27 Jan 2017 09:54:34 +0200 In-Reply-To: <1482598381-16513-6-git-send-email-pali.rohar@gmail.com> ("Pali \=\?utf-8\?Q\?Roh\=C3\=A1r\=22's\?\= message of "Sat, 24 Dec 2016 17:53:00 +0100") Message-ID: <87poj9ndj9.fsf@codeaurora.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v0R7so2r032703 Pali Rohár writes: > This patch implements parsing MAC address from NVS data which are sent to > wl1251 chip. Calibration NVS data could contain valid MAC address and it > will be used instead randomly generated. > > This patch also move code for requesting NVS data from userspace to driver > initialization code to make sure that NVS data will be there at time when > permanent MAC address is needed. > > Calibration NVS data for wl1251 are model specific. Every one device with > wl1251 chip should have been calibrated in factory and needs to provide own > calibration data. > > Default example wl1251-nvs.bin data found in linux-firmware repository and > contains MAC address 00:00:20:07:03:09. So this MAC address is marked as > invalid as it is not real device specific address, just example one. > > Format of calibration NVS data can be found at: > http://notaz.gp2x.de/misc/pnd/wl1251/nvs_map.txt > > Signed-off-by: Pali Rohár [...] > +static int wl1251_read_nvs_mac(struct wl1251 *wl) > +{ > + u8 mac[ETH_ALEN]; > + 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++) > + mac[i] = wl->nvs[0x1c + ETH_ALEN - i - 1]; No magic numbers, please. Replace all nvs offsets with proper defines to make the code more readable. -- Kalle Valo