Module Name: src
Committed By: tsutsui
Date: Tue Sep 22 15:25:12 UTC 2009
Modified Files:
src/sys/dev/ic: cs89x0.c
Log Message:
Fix possible endian issue. Untested.
To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/ic/cs89x0.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ic/cs89x0.c
diff -u src/sys/dev/ic/cs89x0.c:1.26 src/sys/dev/ic/cs89x0.c:1.27
--- src/sys/dev/ic/cs89x0.c:1.26 Tue Sep 22 14:55:19 2009
+++ src/sys/dev/ic/cs89x0.c Tue Sep 22 15:25:12 2009
@@ -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 <sys/cdefs.h>
-__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 @@
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 @@
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 @@
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: