Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sgimips Use ether_aton_r() in sys/net/if_ethersubr....
details: https://anonhg.NetBSD.org/src/rev/7116a1d64e35
branches: trunk
changeset: 760656:7116a1d64e35
user: tsutsui <tsutsui%NetBSD.org@localhost>
date: Mon Jan 10 13:29:29 2011 +0000
description:
Use ether_aton_r() in sys/net/if_ethersubr.c instead of home grown copies.
Hint from ryo@. Tested on IP32 mec(4).
diffstat:
sys/arch/sgimips/hpc/if_sq.c | 34 +++-------------------------------
sys/arch/sgimips/ioc/if_le_oioc.c | 36 ++++--------------------------------
sys/arch/sgimips/mace/if_mec.c | 38 +++-----------------------------------
3 files changed, 10 insertions(+), 98 deletions(-)
diffs (214 lines):
diff -r c23b0cbf1e6d -r 7116a1d64e35 sys/arch/sgimips/hpc/if_sq.c
--- a/sys/arch/sgimips/hpc/if_sq.c Mon Jan 10 12:23:21 2011 +0000
+++ b/sys/arch/sgimips/hpc/if_sq.c Mon Jan 10 13:29:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_sq.c,v 1.36 2010/04/05 07:19:31 joerg Exp $ */
+/* $NetBSD: if_sq.c,v 1.37 2011/01/10 13:29:29 tsutsui Exp $ */
/*
* Copyright (c) 2001 Rafal K. Boni
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sq.c,v 1.36 2010/04/05 07:19:31 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sq.c,v 1.37 2011/01/10 13:29:29 tsutsui Exp $");
#include <sys/param.h>
@@ -118,8 +118,6 @@
static void sq_dump_buffer(paddr_t addr, psize_t len);
static void sq_trace_dump(struct sq_softc *);
-static void enaddr_aton(const char*, u_int8_t*);
-
CFATTACH_DECL(sq, sizeof(struct sq_softc),
sq_match, sq_attach, NULL, NULL);
@@ -282,7 +280,7 @@
printf(": unable to get MAC address!\n");
goto fail_6;
}
- enaddr_aton(macaddr, sc->sc_enaddr);
+ ether_aton_r(sc->sc_enaddr, sizeof(sc->sc_enaddr), macaddr);
}
evcnt_attach_dynamic(&sc->sq_intrcnt, EVCNT_TYPE_INTR, NULL,
@@ -1332,29 +1330,3 @@
printf("\n");
}
-
-void
-enaddr_aton(const char* str, u_int8_t* eaddr)
-{
- int i;
- char c;
-
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- if (*str == ':')
- str++;
-
- c = *str++;
- if (isdigit(c)) {
- eaddr[i] = (c - '0');
- } else if (isxdigit(c)) {
- eaddr[i] = (toupper(c) + 10 - 'A');
- }
-
- c = *str++;
- if (isdigit(c)) {
- eaddr[i] = (eaddr[i] << 4) | (c - '0');
- } else if (isxdigit(c)) {
- eaddr[i] = (eaddr[i] << 4) | (toupper(c) + 10 - 'A');
- }
- }
-}
diff -r c23b0cbf1e6d -r 7116a1d64e35 sys/arch/sgimips/ioc/if_le_oioc.c
--- a/sys/arch/sgimips/ioc/if_le_oioc.c Mon Jan 10 12:23:21 2011 +0000
+++ b/sys/arch/sgimips/ioc/if_le_oioc.c Mon Jan 10 13:29:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_oioc.c,v 1.2 2010/01/19 22:06:22 pooka Exp $ */
+/* $NetBSD: if_le_oioc.c,v 1.3 2011/01/10 13:29:29 tsutsui Exp $ */
/*
* Copyright (c) 2009 Stephen M. Rumble
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_oioc.c,v 1.2 2010/01/19 22:06:22 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_oioc.c,v 1.3 2011/01/10 13:29:29 tsutsui Exp $");
#include "opt_inet.h"
@@ -113,7 +113,6 @@
static void lewrcsr(struct lance_softc *, uint16_t, uint16_t);
static uint16_t lerdcsr(struct lance_softc *, uint16_t);
-static void enaddr_aton(const char *, u_int8_t *);
static void
lewrcsr(struct lance_softc *sc, uint16_t port, uint16_t val)
@@ -158,7 +157,7 @@
struct oioc_attach_args *oa = aux;
struct pglist mlist;
const char *enaddrstr;
- char enaddr[6];
+ char enaddr[ETHER_ADDR_LEN];
char pbuf[9];
int i, error;
@@ -211,7 +210,7 @@
sc->sc_addr = 0;
sc->sc_conf3 = LE_C3_BSWP;
- enaddr_aton(enaddrstr, enaddr);
+ ether_aton_r(enaddr, sizeof(enaddr), enaddrstr);
memcpy(sc->sc_enaddr, enaddr, sizeof(sc->sc_enaddr));
if (cpu_intr_establish(oa->oa_irq, IPL_NET, am7990_intr, sc) == NULL) {
@@ -248,30 +247,3 @@
fail_0:
return;
}
-
-/* stolen from sgimips/hpc/if_sq.c */
-static void
-enaddr_aton(const char *str, u_int8_t *eaddr)
-{
- int i;
- char c;
-
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- if (*str == ':')
- str++;
-
- c = *str++;
- if (isdigit(c)) {
- eaddr[i] = (c - '0');
- } else if (isxdigit(c)) {
- eaddr[i] = (toupper(c) + 10 - 'A');
- }
-
- c = *str++;
- if (isdigit(c)) {
- eaddr[i] = (eaddr[i] << 4) | (c - '0');
- } else if (isxdigit(c)) {
- eaddr[i] = (eaddr[i] << 4) | (toupper(c) + 10 - 'A');
- }
- }
-}
diff -r c23b0cbf1e6d -r 7116a1d64e35 sys/arch/sgimips/mace/if_mec.c
--- a/sys/arch/sgimips/mace/if_mec.c Mon Jan 10 12:23:21 2011 +0000
+++ b/sys/arch/sgimips/mace/if_mec.c Mon Jan 10 13:29:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_mec.c,v 1.43 2010/04/05 07:19:32 joerg Exp $ */
+/* $NetBSD: if_mec.c,v 1.44 2011/01/10 13:29:29 tsutsui Exp $ */
/*-
* Copyright (c) 2004, 2008 Izumi Tsutsui. All rights reserved.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mec.c,v 1.43 2010/04/05 07:19:32 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mec.c,v 1.44 2011/01/10 13:29:29 tsutsui Exp $");
#include "opt_ddb.h"
#include "rnd.h"
@@ -397,8 +397,6 @@
static int mec_mii_wait(struct mec_softc *);
static void mec_statchg(device_t);
-static void enaddr_aton(const char *, uint8_t *);
-
static int mec_init(struct ifnet * ifp);
static void mec_start(struct ifnet *);
static void mec_watchdog(struct ifnet *);
@@ -551,7 +549,7 @@
memcpy(sc->sc_enaddr+3, ((uint8_t *)&ui)+1, 3);
}
if (!mac_is_fake)
- enaddr_aton(macaddr, sc->sc_enaddr);
+ ether_aton_r(sc->sc_enaddr, sizeof(sc->sc_enaddr), macaddr);
/* set the Ethernet address */
address = 0;
@@ -854,36 +852,6 @@
bus_space_write_8(st, sh, MEC_MAC_CONTROL, control);
}
-/*
- * XXX
- * maybe this function should be moved to common part
- * (sgimips/machdep.c or elsewhere) for all on-board network devices.
- */
-static void
-enaddr_aton(const char *str, uint8_t *eaddr)
-{
- int i;
- char c;
-
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- if (*str == ':')
- str++;
-
- c = *str++;
- if (isdigit(c)) {
- eaddr[i] = (c - '0');
- } else if (isxdigit(c)) {
- eaddr[i] = (toupper(c) + 10 - 'A');
- }
- c = *str++;
- if (isdigit(c)) {
- eaddr[i] = (eaddr[i] << 4) | (c - '0');
- } else if (isxdigit(c)) {
- eaddr[i] = (eaddr[i] << 4) | (toupper(c) + 10 - 'A');
- }
- }
-}
-
static int
mec_init(struct ifnet *ifp)
{
Home |
Main Index |
Thread Index |
Old Index