From patchwork Mon Dec 7 14:17:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 553411 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CBB64140BAD for ; Tue, 8 Dec 2015 01:20:26 +1100 (AEDT) Received: from localhost ([::1]:54877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5weO-0004m6-OE for incoming@patchwork.ozlabs.org; Mon, 07 Dec 2015 09:20:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5wcT-0001Ap-M5 for qemu-devel@nongnu.org; Mon, 07 Dec 2015 09:18:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a5wcQ-0001QX-F4 for qemu-devel@nongnu.org; Mon, 07 Dec 2015 09:18:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51181) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5wcQ-0001QM-AE for qemu-devel@nongnu.org; Mon, 07 Dec 2015 09:18:22 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id DAF988EFC2; Mon, 7 Dec 2015 14:18:21 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (vpn1-5-152.pek2.redhat.com [10.72.5.152]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tB7EHK4j032003; Mon, 7 Dec 2015 09:18:13 -0500 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Mon, 7 Dec 2015 22:17:12 +0800 Message-Id: <1449497833-15074-6-git-send-email-jasowang@redhat.com> In-Reply-To: <1449497833-15074-1-git-send-email-jasowang@redhat.com> References: <1449497833-15074-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Jason Wang , Andrew Baumann Subject: [Qemu-devel] [PULL V2 for 2.5 5/6] lan9118: fix emulation of MAC address loaded bit in E2P_CMD register X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Andrew Baumann There appears to have been a longstanding typo in the implementation of the "MAC address loaded" bit in the E2P_CMD (EEPROM command) register. The code was using 0x10, but the controller spec says it should be bit 8 (0x100). Signed-off-by: Andrew Baumann Signed-off-by: Jason Wang --- hw/net/lan9118.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 4f0e840..133fd3d 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -56,6 +56,8 @@ do { fprintf(stderr, "lan9118: error: " fmt , ## __VA_ARGS__);} while (0) #define CSR_E2P_CMD 0xb0 #define CSR_E2P_DATA 0xb4 +#define E2P_CMD_MAC_ADDR_LOADED 0x100 + /* IRQ_CFG */ #define IRQ_INT 0x00001000 #define IRQ_EN 0x00000100 @@ -352,14 +354,14 @@ static void lan9118_reload_eeprom(lan9118_state *s) { int i; if (s->eeprom[0] != 0xa5) { - s->e2p_cmd &= ~0x10; + s->e2p_cmd &= ~E2P_CMD_MAC_ADDR_LOADED; DPRINTF("MACADDR load failed\n"); return; } for (i = 0; i < 6; i++) { s->conf.macaddr.a[i] = s->eeprom[i + 1]; } - s->e2p_cmd |= 0x10; + s->e2p_cmd |= E2P_CMD_MAC_ADDR_LOADED; DPRINTF("MACADDR loaded from eeprom\n"); lan9118_mac_changed(s); } @@ -937,7 +939,7 @@ static uint32_t do_mac_read(lan9118_state *s, int reg) static void lan9118_eeprom_cmd(lan9118_state *s, int cmd, int addr) { - s->e2p_cmd = (s->e2p_cmd & 0x10) | (cmd << 28) | addr; + s->e2p_cmd = (s->e2p_cmd & E2P_CMD_MAC_ADDR_LOADED) | (cmd << 28) | addr; switch (cmd) { case 0: s->e2p_data = s->eeprom[addr];