Skip to content

Commit b7e4eca

Browse files
committed
Use ether_getaddr().
1 parent 6fced3c commit b7e4eca

2 files changed

Lines changed: 10 additions & 20 deletions

File tree

sys/arch/mips/adm5120/dev/if_admsw.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: if_admsw.c,v 1.31 2024/02/10 09:30:05 andvar Exp $ */
1+
/* $NetBSD: if_admsw.c,v 1.32 2025/10/15 01:31:27 thorpej Exp $ */
22

33
/*-
44
* Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -76,7 +76,7 @@
7676
*/
7777

7878
#include <sys/cdefs.h>
79-
__KERNEL_RCSID(0, "$NetBSD: if_admsw.c,v 1.31 2024/02/10 09:30:05 andvar Exp $");
79+
__KERNEL_RCSID(0, "$NetBSD: if_admsw.c,v 1.32 2025/10/15 01:31:27 thorpej Exp $");
8080

8181

8282
#include <sys/param.h>
@@ -323,32 +323,27 @@ admsw_reset(struct admsw_softc *sc)
323323
static void
324324
admsw_attach(device_t parent, device_t self, void *aux)
325325
{
326-
uint8_t enaddr[ETHER_ADDR_LEN];
327326
struct admsw_softc *sc = device_private(self);
328327
struct obio_attach_args *aa = aux;
329328
struct ifnet *ifp;
330329
bus_dma_segment_t seg;
331330
int error, i, rseg;
332-
prop_data_t pd;
331+
uint8_t enaddr[ETHER_ADDR_LEN];
333332

334333
printf(": ADM5120 Switch Engine, %d ports\n", SW_DEVS);
335334

336335
sc->sc_dev = self;
337336
sc->sc_dmat = aa->oba_dt;
338337
sc->sc_st = aa->oba_st;
339338

340-
pd = prop_dictionary_get(device_properties(self), "mac-address");
341-
342-
if (pd == NULL) {
339+
if (! ether_getaddr(self, enaddr)) {
343340
enaddr[0] = 0x02;
344341
enaddr[1] = 0xaa;
345342
enaddr[2] = 0xbb;
346343
enaddr[3] = 0xcc;
347344
enaddr[4] = 0xdd;
348345
enaddr[5] = 0xee;
349-
} else
350-
memcpy(enaddr, prop_data_data_nocopy(pd), sizeof(enaddr));
351-
346+
}
352347
memcpy(sc->sc_enaddr, enaddr, sizeof(sc->sc_enaddr));
353348

354349
printf("%s: base Ethernet address %s\n", device_xname(sc->sc_dev),

sys/arch/mips/alchemy/dev/if_aumac.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: if_aumac.c,v 1.53 2024/06/29 12:11:11 riastradh Exp $ */
1+
/* $NetBSD: if_aumac.c,v 1.54 2025/10/15 01:32:44 thorpej Exp $ */
22

33
/*
44
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -46,7 +46,7 @@
4646
*/
4747

4848
#include <sys/cdefs.h>
49-
__KERNEL_RCSID(0, "$NetBSD: if_aumac.c,v 1.53 2024/06/29 12:11:11 riastradh Exp $");
49+
__KERNEL_RCSID(0, "$NetBSD: if_aumac.c,v 1.54 2025/10/15 01:32:44 thorpej Exp $");
5050

5151

5252

@@ -214,8 +214,6 @@ aumac_match(device_t parent, struct cfdata *cf, void *aux)
214214
static void
215215
aumac_attach(device_t parent, device_t self, void *aux)
216216
{
217-
const uint8_t *enaddr;
218-
prop_data_t ea;
219217
struct aumac_softc *sc = device_private(self);
220218
struct aubus_attach_args *aa = aux;
221219
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
@@ -224,6 +222,7 @@ aumac_attach(device_t parent, device_t self, void *aux)
224222
paddr_t bufaddr;
225223
vaddr_t vbufaddr;
226224
int i;
225+
uint8_t enaddr[ETHER_ADDR_LEN];
227226

228227
callout_init(&sc->sc_tick_ch, 0);
229228

@@ -234,14 +233,10 @@ aumac_attach(device_t parent, device_t self, void *aux)
234233
sc->sc_st = aa->aa_st;
235234

236235
/* Get the MAC address. */
237-
ea = prop_dictionary_get(device_properties(self), "mac-address");
238-
if (ea == NULL) {
239-
aprint_error_dev(self, "unable to get mac-addr property\n");
236+
if (! ether_getaddr(self, enaddr)) {
237+
aprint_error_dev(self, "unable to get MAC address\n");
240238
return;
241239
}
242-
KASSERT(prop_object_type(ea) == PROP_TYPE_DATA);
243-
KASSERT(prop_data_size(ea) == ETHER_ADDR_LEN);
244-
enaddr = prop_data_data_nocopy(ea);
245240

246241
aprint_normal_dev(self, "Ethernet address %s\n", ether_sprintf(enaddr));
247242

0 commit comments

Comments
 (0)