From 6b3b6e9a98df52581e069ea542261d546006f0ad Mon Sep 17 00:00:00 2001 From: tsutsui Date: Tue, 22 Sep 2009 15:25:12 +0000 Subject: [PATCH] Fix possible endian issue. Untested. --- sys/dev/ic/cs89x0.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/dev/ic/cs89x0.c b/sys/dev/ic/cs89x0.c index 55d9f4dc9d21..70d03b708597 100644 --- a/sys/dev/ic/cs89x0.c +++ b/sys/dev/ic/cs89x0.c @@ -1,4 +1,4 @@ -/* $NetBSD: cs89x0.c,v 1.26 2009/09/22 14:55:19 tsutsui Exp $ */ +/* $NetBSD: cs89x0.c,v 1.27 2009/09/22 15:25:12 tsutsui Exp $ */ /* * Copyright (c) 2004 Christopher Gilbert @@ -212,7 +212,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cs89x0.c,v 1.26 2009/09/22 14:55:19 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cs89x0.c,v 1.27 2009/09/22 15:25:12 tsutsui Exp $"); #include "opt_inet.h" @@ -812,7 +812,8 @@ eeprom_bad: int cs_get_enaddr(struct cs_softc *sc) { - u_int16_t *myea; + uint16_t myea[ETHER_ADDR_LEN / sizeof(uint16_t)]; + int i; if (cs_verify_eeprom(sc) == CS_ERROR) { aprint_error_dev(sc->sc_dev, @@ -820,10 +821,7 @@ cs_get_enaddr(struct cs_softc *sc) return (CS_ERROR); } - myea = (u_int16_t *)sc->sc_enaddr; - /* Get Ethernet address from the EEPROM */ - /* XXX this will likely lose on a big-endian machine. -- cgd */ if (sc->sc_cfgflags & CFGFLG_PARSE_EEPROM) { if (cs_read_pktpg_from_eeprom(sc, PKTPG_IND_ADDR, &myea[0]) == CS_ERROR) @@ -843,6 +841,11 @@ cs_get_enaddr(struct cs_softc *sc) goto eeprom_bad; } + for (i = 0; i < __arraycount(myea); i++) { + sc->sc_enaddr[i * 2 + 0] = myea[i]; + sc->sc_enaddr[i * 2 + 1] = myea[i] >> 8; + } + return (CS_OK); eeprom_bad: