From patchwork Mon Jan 21 13:55:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Holger Brunck X-Patchwork-Id: 214158 X-Patchwork-Delegate: kim.phillips@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 6A5D32C009B for ; Tue, 22 Jan 2013 00:56:47 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 26A3C4A0B3; Mon, 21 Jan 2013 14:56:33 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3r+0YurYjxbj; Mon, 21 Jan 2013 14:56:32 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B00F34A0BA; Mon, 21 Jan 2013 14:56:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2AF674A092 for ; Mon, 21 Jan 2013 14:55:54 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s+EXKIAzZqLb for ; Mon, 21 Jan 2013 14:55:52 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-de.keymile.com (mail-de.keymile.com [195.8.104.1]) by theia.denx.de (Postfix) with SMTP id 44F0B4A0AD for ; Mon, 21 Jan 2013 14:55:42 +0100 (CET) Received: from mailrelay.de.keymile.net ([10.9.1.54]) by eSafe SMTP Relay 1358770333; Mon, 21 Jan 2013 14:55:37 +0100 Received: from pc005093.de.keymile.net.de.keymile.net (pc005093.de.keymile.net.de.keymile.net [172.30.2.67]) by mailrelay.de.keymile.net (8.12.2/8.12.2) with ESMTP id r0LDs03G002358; Mon, 21 Jan 2013 14:54:01 +0100 (MET) From: Holger Brunck To: u-boot@lists.denx.de Date: Mon, 21 Jan 2013 14:55:17 +0100 Message-Id: <1358776528-27254-5-git-send-email-holger.brunck@keymile.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1358776528-27254-1-git-send-email-holger.brunck@keymile.com> References: <1358776528-27254-1-git-send-email-holger.brunck@keymile.com> X-ESAFE-STATUS: [srvhellgate.de.keymile.net] Mail allowed Cc: Kim Phillips , Holger Brunck Subject: [U-Boot] [PATCH v2 05/16] km/common/ivm: rework piggy mac adress offset generation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de For the the kmvect1 board we will also need a functionality to add an offset to the IVMs MAC address, because these board will have two valid ethernet ports for debugging purpose. So move the code to an own function. Signed-off-by: Holger Brunck --- Changes for v2: - new in this serie, needed as preparation for fixes in the next patch as requested on the ML board/keymile/common/ivm.c | 28 +++++++++++++++++----------- 1 files changed, 17 insertions(+), 11 deletions(-) diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c index 607daa6..d568fd9 100644 --- a/board/keymile/common/ivm.c +++ b/board/keymile/common/ivm.c @@ -201,6 +201,22 @@ static int ivm_check_crc(unsigned char *buf, int block) return 0; } +static int calculate_mac_offset(unsigned char *valbuf, unsigned char *buf, + int offset) +{ + unsigned long val = (buf[4] << 16) + (buf[5] << 8) + buf[6]; + + if (offset == 0) + return 0; + + val += offset; + buf[4] = (val >> 16) & 0xff; + buf[5] = (val >> 8) & 0xff; + buf[6] = val & 0xff; + sprintf((char *)valbuf, "%pM", buf + 1); + return 0; +} + static int ivm_analyze_block2(unsigned char *buf, int len) { unsigned char valbuf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN]; @@ -210,17 +226,7 @@ static int ivm_analyze_block2(unsigned char *buf, int len) sprintf((char *)valbuf, "%pM", buf + 1); ivm_set_value("IVM_MacAddress", (char *)valbuf); /* if an offset is defined, add it */ -#if defined(CONFIG_PIGGY_MAC_ADRESS_OFFSET) - if (CONFIG_PIGGY_MAC_ADRESS_OFFSET > 0) { - unsigned long val = (buf[4] << 16) + (buf[5] << 8) + buf[6]; - - val += CONFIG_PIGGY_MAC_ADRESS_OFFSET; - buf[4] = (val >> 16) & 0xff; - buf[5] = (val >> 8) & 0xff; - buf[6] = val & 0xff; - sprintf((char *)valbuf, "%pM", buf + 1); - } -#endif + calculate_mac_offset(buf, valbuf, CONFIG_PIGGY_MAC_ADRESS_OFFSET); #ifdef MACH_TYPE_KM_KIRKWOOD setenv((char *)"ethaddr", (char *)valbuf); #else