summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/acorn32/eb7500atx/if_cs.c52
-rw-r--r--sys/arch/acorn32/podulebus/if_ne_pbus.c94
-rw-r--r--sys/arch/hppa/gsc/if_ie_gsc.c54
-rw-r--r--sys/arch/macppc/dev/if_mc.c54
-rw-r--r--sys/arch/sparc/dev/if_ie_obio.c48
-rw-r--r--sys/arch/sparc/dev/if_le_obio.c33
-rw-r--r--sys/arch/sun2/dev/if_ie_mbmem.c82
-rw-r--r--sys/arch/sun2/dev/if_ie_obio.c62
-rw-r--r--sys/dev/ic/cs89x0.c516
-rw-r--r--sys/dev/ic/rtl80x9.c33
-rw-r--r--sys/dev/ic/smc91cxx.c286
-rw-r--r--sys/dev/isa/if_ef.c28
-rw-r--r--sys/dev/isa/if_ix.c34
-rw-r--r--sys/dev/pci/if_le_pci.c54
-rw-r--r--sys/dev/vme/if_ie_vme.c101
15 files changed, 700 insertions, 831 deletions
diff --git a/sys/arch/acorn32/eb7500atx/if_cs.c b/sys/arch/acorn32/eb7500atx/if_cs.c
index cdad6328369..a6d9a5582bb 100644
--- a/sys/arch/acorn32/eb7500atx/if_cs.c
+++ b/sys/arch/acorn32/eb7500atx/if_cs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_cs.c,v 1.10 2015/04/13 21:18:40 riastradh Exp $ */
+/* $NetBSD: if_cs.c,v 1.11 2019/04/25 10:08:45 msaitoh Exp $ */
/*
* Copyright (c) 2004 Christopher Gilbert
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cs.c,v 1.10 2015/04/13 21:18:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cs.c,v 1.11 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -86,14 +86,14 @@ __KERNEL_RCSID(0, "$NetBSD: if_cs.c,v 1.10 2015/04/13 21:18:40 riastradh Exp $")
*
* IRQ is mapped as:
* CS8920 IRQ 3 INT5
- *
+ *
* It must be configured as the following:
* The CS8920 PNP address should be configured for ISA base at 0x300
- * to achieve the default register mapping as specified.
+ * to achieve the default register mapping as specified.
* Note memory addresses are all have bit 23 tied high in hardware.
* This only effects the value programmed into the CS8920 memory offset
- * registers.
- *
+ * registers.
+ *
* Just to add to the fun the I/O registers are layed out as:
* xxxxR1R0
* xxxxR3R2
@@ -102,8 +102,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_cs.c,v 1.10 2015/04/13 21:18:40 riastradh Exp $")
* This works fine for 16bit accesses, but it makes access to single
* register hard (which does happen on a reset, as we've got to toggle
* the chip into 16bit mode)
- *
- * Network DRQ is connected to DRQ5
+ *
+ * Network DRQ is connected to DRQ5
*/
/*
@@ -121,18 +121,18 @@ CFATTACH_DECL_NEW(cs_rsbus, sizeof(struct cs_softc),
/* Available media */
int cs_rbus_media [] = {
- IFM_ETHER|IFM_10_T|IFM_FDX,
- IFM_ETHER|IFM_10_T
+ IFM_ETHER | IFM_10_T | IFM_FDX,
+ IFM_ETHER | IFM_10_T
};
-int
+int
cs_rsbus_probe(device_t parent, cfdata_t cf, void *aux)
{
- /* for now it'll always attach */
+ /* For now it'll always attach */
return 1;
}
-void
+void
cs_rsbus_attach(device_t parent, device_t self, void *aux)
{
struct cs_softc *sc = device_private(self);
@@ -141,12 +141,12 @@ cs_rsbus_attach(device_t parent, device_t self, void *aux)
sc->sc_dev = self;
- /* member copy */
+ /* Member copy */
cs_rsbus_bs_tag = *rs->sa_iot;
-
- /* registers are normally accessed in pairs, on a 4 byte aligned */
+
+ /* Registers are normally accessed in pairs, on a 4 byte aligned */
cs_rsbus_bs_tag.bs_cookie = (void *) 1;
-
+
sc->sc_iot = sc->sc_memt = &cs_rsbus_bs_tag;
#if 0 /* Do DMA later */
@@ -156,14 +156,12 @@ cs_rsbus_attach(device_t parent, device_t self, void *aux)
isc->sc_drq = -1;
#endif
- /* device always interrupts on 3 but that routes to IRQ 5 */
+ /* Device always interrupts on 3 but that routes to IRQ 5 */
sc->sc_irq = 3;
printf("\n");
- /*
- * Map the device.
- */
+ /* Map the device. */
iobase = 0x03010600;
if (bus_space_map(sc->sc_iot, iobase, CS8900_IOSIZE * 4,
0, &sc->sc_ioh)) {
@@ -178,7 +176,7 @@ cs_rsbus_attach(device_t parent, device_t self, void *aux)
} else {
sc->sc_cfgflags |= CFGFLG_MEM_MODE | CFGFLG_USE_SA;
sc->sc_pktpgaddr = 1<<23;
- //(0x4000 >> 1) | (1<<23);
+ //(0x4000 >> 1) | (1<<23);
}
#endif
sc->sc_ih = intr_claim(IRQ_INT5, IPL_NET, "cs", cs_intr, sc);
@@ -196,12 +194,12 @@ cs_rsbus_attach(device_t parent, device_t self, void *aux)
sc->sc_cfgflags |= CFGFLG_PARSE_EEPROM;
sc->sc_io_read_1 = cs_rbus_read_1;
- /*
+ /*
* also provide media, otherwise it attempts to read the media from
* the EEPROM, which again fails
*/
- cs_attach(sc, NULL, cs_rbus_media, sizeof(cs_rbus_media) / sizeof(cs_rbus_media[0]),
- IFM_ETHER|IFM_10_T|IFM_FDX);
+ cs_attach(sc, NULL, cs_rbus_media, __arraycount(cs_rbus_media),
+ IFM_ETHER |IFM_10_T | IFM_FDX);
}
/*
@@ -212,14 +210,14 @@ static uint8_t
cs_rbus_read_1(struct cs_softc *sc, bus_size_t a)
{
bus_size_t offset;
- /*
+ /*
* if it's an even address then just use the bus_space_read_1
*/
if ((a & 1) == 0)
{
return bus_space_read_1(sc->sc_iot, sc->sc_ioh, a);
}
- /*
+ /*
* otherwise we've get to work out the aligned address and then add
* one
*/
diff --git a/sys/arch/acorn32/podulebus/if_ne_pbus.c b/sys/arch/acorn32/podulebus/if_ne_pbus.c
index 862fc80fc26..1570d78910b 100644
--- a/sys/arch/acorn32/podulebus/if_ne_pbus.c
+++ b/sys/arch/acorn32/podulebus/if_ne_pbus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ne_pbus.c,v 1.18 2014/01/21 19:30:46 christos Exp $ */
+/* $NetBSD: if_ne_pbus.c,v 1.19 2019/04/25 10:08:45 msaitoh Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ne_pbus.c,v 1.18 2014/01/21 19:30:46 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ne_pbus.c,v 1.19 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -211,16 +211,16 @@ struct ne_clone {
static int
ne_pbus_probe(device_t parent, cfdata_t cf, void *aux)
{
- struct podule_attach_args *pa = (void *) aux;
+ struct podule_attach_args *pa = (void *)aux;
int loop;
/* Scan the list of known interfaces looking for a match */
for (loop = 0; loop < sizeof(ne_clones) / sizeof(struct ne_clone);
++loop) {
if (pa->pa_product == ne_clones[loop].product)
- return(1);
+ return 1;
}
- return(0);
+ return 0;
}
/*
@@ -358,7 +358,7 @@ ne_pbus_attach(device_t parent, device_t self, void *aux)
if (ne->preattach)
ne->preattach(npsc);
- /* if the interface has media support initialise it */
+ /* If the interface has media support initialise it */
if (ne->init_media) {
dsc->sc_mediachange = ne->mediachange;
dsc->sc_mediastatus = ne->mediastatus;
@@ -389,7 +389,7 @@ ne_pbus_attach(device_t parent, device_t self, void *aux)
case NE2000_TYPE_DL10019:
aprint_normal("DL10019");
break;
- case NE2000_TYPE_DL10022:
+ case NE2000_TYPE_DL10022:
aprint_normal("DL10022");
break;
default:
@@ -409,7 +409,7 @@ ne_pbus_attach(device_t parent, device_t self, void *aux)
if (npsc->sc_ih == NULL)
panic("%s: Cannot install interrupt handler",
device_xname(self));
- /* this feels wrong to do this here */
+ /* This feels wrong to do this here */
npsc->sc_ih->ih_maskaddr = npsc->sc_podule->irq_addr;
npsc->sc_ih->ih_maskbits = npsc->sc_podule->irq_mask;
}
@@ -430,7 +430,7 @@ em_ea(struct ne_pbus_softc *sc, uint8_t *buffer)
*/
netslot_ea(buffer);
- return(buffer);
+ return buffer;
}
/*
@@ -479,8 +479,8 @@ em_postattach(struct ne_pbus_softc *sc)
/*
* eh600_preattach()
*
- * pre-initialise the AT/Lantic chipset so that the card probes and
- * detects properly.
+ * pre-initialise the AT/Lantic chipset so that the card probes and
+ * detects properly.
*/
static void
eh600_preattach(struct ne_pbus_softc *sc)
@@ -490,22 +490,22 @@ eh600_preattach(struct ne_pbus_softc *sc)
struct dp8390_softc *dsc = &nsc->sc_dp8390;
bus_space_tag_t nict = dsc->sc_regt;
bus_space_handle_t nich = dsc->sc_regh;
-
- /* initialise EH600 config register */
+
+ /* Initialise EH600 config register */
bus_space_read_1(nict, nich, DP83905_MCRA);
bus_space_write_1(nict, nich, DP83905_MCRA, DP83905_MCRA_INT3);
- /* enable interrupts for the card */
- tmp = bus_space_read_1(&sc->sc_tag,sc->sc_extrah,0);
+ /* Enable interrupts for the card */
+ tmp = bus_space_read_1(&sc->sc_tag,sc->sc_extrah,0);
tmp |= EH_INTR_MASK;
- bus_space_write_1(&sc->sc_tag,sc->sc_extrah,0,tmp);
+ bus_space_write_1(&sc->sc_tag,sc->sc_extrah,0,tmp);
}
/*
* eh600_postattach()
*
- * Etherlan 600 has 32k of buffer memory as it runs the AT/Lantic
- * DP8390 clone in IO non-compatible mode. We need to adjust the memory
+ * Etherlan 600 has 32k of buffer memory as it runs the AT/Lantic
+ * DP8390 clone in IO non-compatible mode. We need to adjust the memory
* description set up by dp8390.c and ne2000.c to reflect this.
*/
static void
@@ -513,24 +513,25 @@ eh600_postattach(struct ne_pbus_softc *sc)
{
struct ne2000_softc *nsc = &sc->sc_ne2000;
struct dp8390_softc *dsc = &nsc->sc_dp8390;
- /* first page is mapped to the PROM. so start at 2nd page */
+
+ /* First page is mapped to the PROM. so start at 2nd page */
dsc->mem_start = EH600_MEM_START;
dsc->mem_size = EH600_MEM_END - EH600_MEM_START;
dsc->mem_end = EH600_MEM_END;
dsc->txb_cnt = 3; /* >16k of ram setup 3 tx buffers */
- /* recompute the mem ring (taken straight from the ne2000 init code) */
- dsc->mem_ring =
- dsc->mem_start +
+ /* Recompute the mem ring (taken straight from the ne2000 init code) */
+ dsc->mem_ring =
+ dsc->mem_start +
(((dsc->txb_cnt + 1) * ED_TXBUF_SIZE ) <<
ED_PAGE_SHIFT);
- /* recompute the dp8390 register values. (from dp8390 init code) */
+ /* Recompute the dp8390 register values. (from dp8390 init code) */
dsc->tx_page_start = dsc->mem_start >> ED_PAGE_SHIFT;
- dsc->rec_page_start = dsc->tx_page_start +
+ dsc->rec_page_start = dsc->tx_page_start +
(dsc->txb_cnt + 1) * ED_TXBUF_SIZE;
- dsc->rec_page_stop = dsc->tx_page_start +
+ dsc->rec_page_stop = dsc->tx_page_start +
(dsc->mem_size >> ED_PAGE_SHIFT);
aprint_normal_dev(dsc->sc_dev, "32KB buffer memory\n");
}
@@ -540,13 +541,12 @@ eh600_postattach(struct ne_pbus_softc *sc)
void eh600_init_media(struct dp8390_softc *sc)
{
static int eh600_media[] = {
- IFM_ETHER|IFM_AUTO,
- IFM_ETHER|IFM_10_T,
- IFM_ETHER|IFM_10_2,
+ IFM_ETHER | IFM_AUTO,
+ IFM_ETHER | IFM_10_T,
+ IFM_ETHER | IFM_10_2,
};
- int i, defmedia = IFM_ETHER|IFM_AUTO;
- static const int eh600_nmedia =
- sizeof(eh600_media) / sizeof(eh600_media[0]);
+ int i, defmedia = IFM_ETHER | IFM_AUTO;
+ static const int eh600_nmedia = __arraycount(eh600_media);
aprint_normal_dev(sc->sc_dev,
"10base2, 10baseT, auto, default auto\n");
@@ -555,7 +555,6 @@ void eh600_init_media(struct dp8390_softc *sc)
for (i = 0; i < eh600_nmedia; i++)
ifmedia_add(&sc->sc_media, eh600_media[i], 0, NULL);
ifmedia_set(&sc->sc_media, defmedia);
-
}
@@ -575,6 +574,7 @@ en_init_media(struct dp8390_softc *sc)
static int en_media[] = {
IFM_ETHER|IFM_10_T
};
+
aprint_normal_dev(sc->sc_dev, "10baseT, default 10baseT\n");
ifmedia_init(&sc->sc_media, 0, dp8390_mediachange, dp8390_mediastatus);
@@ -583,12 +583,12 @@ en_init_media(struct dp8390_softc *sc)
}
-/*
+/*
* extracts the station address from the Podule description string.
- * The description has to be re-read here since the podule description
+ * The description has to be re-read here since the podule description
* string is not always long enough to contain the full address.
*
- * If for any reason we cannot extract the address this routine will
+ * If for any reason we cannot extract the address this routine will
* use netslot_ea() to return the generic address for the network slot.
*/
@@ -605,21 +605,21 @@ eh600_ea(struct ne_pbus_softc *sc, uint8_t *buffer)
address = 0x40;
memset(buffer, 0, 6);
- /* read chunks from the podule */
+ /* Read chunks from the podule */
do {
id = POD_READ(address);
- /* check for description chunk. */
+ /* Check for description chunk. */
if (id == 0xf5) {
u_int size;
u_int pod_addr;
int loop;
- /* read the size */
+ /* Read the size */
size = POD_READ(address + 4);
size |= (POD_READ(address + 8) << 8);
size |= (POD_READ(address + 12) << 16);
- /* read address of description */
+ /* Read address of description */
pod_addr = POD_READ(address + 16);
pod_addr |= (POD_READ(address + 20) << 8);
pod_addr |= (POD_READ(address + 24) << 16);
@@ -631,33 +631,33 @@ eh600_ea(struct ne_pbus_softc *sc, uint8_t *buffer)
int found_ether = 0;
/*
- * start scanning for ethernet address
+ * Start scanning for ethernet address
* which starts with a '('
*/
for (loop = 0; loop < size; ++loop) {
if (found_ether) {
- /* we have found a '(' so start decoding the address */
+ /* We have found a '(' so start decoding the address */
tmp = POD_READ((pod_addr + loop) * 4);
if (tmp >= '0' && tmp <= '9') {
buffer[addr_index >> 1] |= (tmp - '0') << ((addr_index & 1) ? 0 : 4);
++addr_index;
}
- else if (tmp >= 'a' && tmp <= 'f'){
+ else if (tmp >= 'a' && tmp <= 'f'){
buffer[addr_index >> 1] |= (10 + (tmp - 'a')) << ((addr_index & 1) ? 0 : 4);
++addr_index;
}
- else if (tmp >= 'A' && tmp <= 'F'){
+ else if (tmp >= 'A' && tmp <= 'F'){
buffer[addr_index >> 1] |= (10 + (tmp - 'A')) << ((addr_index & 1) ? 0 : 4);
++addr_index;
}
else if (tmp == ')') {
- /* we have read the whole address so we can stop scanning
+ /* We have read the whole address so we can stop scanning
* the podule description */
break;
}
}
/*
- * we have found the start of the ethernet address (decode begins
+ * We have found the start of the ethernet address (decode begins
* on the next run round the loop. */
if (POD_READ((pod_addr + loop) * 4) == '(') {
found_ether = 1;
@@ -669,7 +669,7 @@ eh600_ea(struct ne_pbus_softc *sc, uint8_t *buffer)
*/
if (!found_ether)
netslot_ea(buffer);
- return(buffer);
+ return buffer;
}
}
address += 32;
@@ -680,5 +680,5 @@ eh600_ea(struct ne_pbus_softc *sc, uint8_t *buffer)
* In this case the best solution is to go with the netslot addrness
*/
netslot_ea(buffer);
- return(buffer);
+ return buffer;
}
diff --git a/sys/arch/hppa/gsc/if_ie_gsc.c b/sys/arch/hppa/gsc/if_ie_gsc.c
index a88f4678d3c..154e8b47cb7 100644
--- a/sys/arch/hppa/gsc/if_ie_gsc.c
+++ b/sys/arch/hppa/gsc/if_ie_gsc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ie_gsc.c,v 1.3 2019/04/16 12:22:13 skrll Exp $ */
+/* $NetBSD: if_ie_gsc.c,v 1.4 2019/04/25 10:08:45 msaitoh Exp $ */
/* $OpenBSD: if_ie_gsc.c,v 1.6 2001/01/12 22:57:04 mickey Exp $ */
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ie_gsc.c,v 1.3 2019/04/16 12:22:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ie_gsc.c,v 1.4 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -120,7 +120,7 @@ CFATTACH_DECL_NEW(ie_gsc, sizeof(struct ie_gsc_softc),
static int ie_gsc_media[] = {
IFM_ETHER | IFM_10_2,
};
-#define IE_NMEDIA (sizeof(ie_gsc_media) / sizeof(ie_gsc_media[0]))
+#define IE_NMEDIA __arraycount(ie_gsc_media)
void ie_gsc_reset(struct ie_softc *, int);
void ie_gsc_attend(struct ie_softc *, int);
@@ -137,7 +137,7 @@ void ie_gsc_memcopyout(struct ie_softc *, const void *, int, size_t);
void
ie_gsc_reset(struct ie_softc *sc, int what)
{
- struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
+ struct ie_gsc_softc *gsc = (struct ie_gsc_softc *)sc;
int i;
switch (what) {
@@ -149,14 +149,14 @@ ie_gsc_reset(struct ie_softc *sc, int what)
bus_space_write_4(gsc->iot, gsc->ioh, IE_GSC_REG_RESET, 0);
/*
- * per [2] 4.6.2.1
+ * Per [2] 4.6.2.1
* delay for 10 system clocks + 5 transmit clocks,
* NB: works for system clocks over 10MHz
*/
DELAY(1000);
/*
- * after the hardware reset:
+ * After the hardware reset:
* inform i825[89]6 about new SCP address,
* which must be at least 16-byte aligned
*/
@@ -165,7 +165,8 @@ ie_gsc_reset(struct ie_softc *sc, int what)
for (i = 9000; i-- && ie_gsc_read16(sc, IE_ISCP_BUSY(sc->iscp));
DELAY(100))
- pdcache(0, (vaddr_t)sc->sc_maddr + sc->iscp, IE_ISCP_SZ);
+ pdcache(0, (vaddr_t)sc->sc_maddr + sc->iscp,
+ IE_ISCP_SZ);
#if I82596_DEBUG
if (i < 0) {
@@ -183,7 +184,7 @@ ie_gsc_reset(struct ie_softc *sc, int what)
void
ie_gsc_attend(struct ie_softc *sc, int why)
{
- struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
+ struct ie_gsc_softc *gsc = (struct ie_gsc_softc *)sc;
bus_space_write_4(gsc->iot, gsc->ioh, IE_GSC_REG_ATTN, 0);
}
@@ -198,7 +199,7 @@ ie_gsc_run(struct ie_softc *sc)
void
ie_gsc_port(struct ie_softc *sc, u_int cmd)
{
- struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
+ struct ie_gsc_softc *gsc = (struct ie_gsc_softc *)sc;
switch (cmd) {
case IE_PORT_RESET:
@@ -239,7 +240,7 @@ ie_gsc_read16(struct ie_softc *sc, int offset)
" fdc %%r0(%1) \n"
: "=&r" (val)
: "r" ((char *)sc->sc_maddr + offset));
- return (val);
+ return val;
}
void
@@ -277,7 +278,7 @@ ie_gsc_write24(struct ie_softc *sc, int offset, int addr)
void
ie_gsc_memcopyin(struct ie_softc *sc, void *p, int offset, size_t size)
{
- struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
+ struct ie_gsc_softc *gsc = (struct ie_gsc_softc *)sc;
if (size == 0)
return;
@@ -291,7 +292,7 @@ ie_gsc_memcopyin(struct ie_softc *sc, void *p, int offset, size_t size)
void
ie_gsc_memcopyout(struct ie_softc *sc, const void *p, int offset, size_t size)
{
- struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
+ struct ie_gsc_softc *gsc = (struct ie_gsc_softc *)sc;
if (size == 0)
return;
@@ -309,7 +310,7 @@ int i82596_probe(struct ie_softc *);
int
i82596_probe(struct ie_softc *sc)
{
- struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
+ struct ie_gsc_softc *gsc = (struct ie_gsc_softc *)sc;
int i;
/* Set up the SCP. */
@@ -342,9 +343,7 @@ i82596_probe(struct ie_softc *sc)
bus_dmamap_sync(gsc->iemt, sc->sc_dmamap, 0, sc->sc_msize,
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
ie_gsc_port(sc, IE_PORT_SELF_TEST);
- for (i = 9000; i-- &&
- sc->ie_bus_read16(sc, 4);
- DELAY(100))
+ for (i = 9000; i-- && sc->ie_bus_read16(sc, 4); DELAY(100))
pdcache(0, (vaddr_t)sc->sc_maddr, sc->sc_msize);
#if I82596_DEBUG
@@ -388,9 +387,7 @@ ie_gsc_attach(device_t parent, device_t self, void *aux)
if (ga->ga_type.iodc_sv_model == HPPA_FIO_GLAN)
gsc->flags |= IEGSC_GECKO;
- /*
- * Map the GSC registers.
- */
+ /* Map the GSC registers. */
if (bus_space_map(ga->ga_iot, ga->ga_hpa,
IE_GSC_BANK_SZ, 0, &gsc->ioh)) {
printf(": can't map i/o space\n");
@@ -417,9 +414,7 @@ ie_gsc_attach(device_t parent, device_t self, void *aux)
return;
}
- /*
- * Map that physical memory into kernel virtual space.
- */
+ /* Map that physical memory into kernel virtual space. */
if (bus_dmamem_map(gsc->iemt, &seg, rseg, sc->sc_msize,
(void **)&sc->sc_maddr, BUS_DMA_NOWAIT)) {
printf (": can't map DMA memory\n");
@@ -427,9 +422,7 @@ ie_gsc_attach(device_t parent, device_t self, void *aux)
return;
}
- /*
- * Create a DMA map for the memory.
- */
+ /* Create a DMA map for the memory. */
if (bus_dmamap_create(gsc->iemt, sc->sc_msize, rseg, sc->sc_msize,
0, BUS_DMA_NOWAIT, &sc->sc_dmamap)) {
printf(": can't create DMA map\n");
@@ -439,12 +432,9 @@ ie_gsc_attach(device_t parent, device_t self, void *aux)
return;
}
- /*
- * Load the mapped DMA memory into the DMA map.
- */
- if (bus_dmamap_load(gsc->iemt, sc->sc_dmamap,
- sc->sc_maddr, sc->sc_msize,
- NULL, BUS_DMA_NOWAIT)) {
+ /* Load the mapped DMA memory into the DMA map. */
+ if (bus_dmamap_load(gsc->iemt, sc->sc_dmamap, sc->sc_maddr,
+ sc->sc_msize, NULL, BUS_DMA_NOWAIT)) {
printf(": can't load DMA map\n");
bus_dmamap_destroy(gsc->iemt, sc->sc_dmamap);
bus_dmamem_unmap(gsc->iemt,
@@ -455,7 +445,7 @@ ie_gsc_attach(device_t parent, device_t self, void *aux)
#if 1
/* XXX - this should go away. */
- sc->bh = (bus_space_handle_t) sc->sc_maddr;
+ sc->bh = (bus_space_handle_t)sc->sc_maddr;
#endif
#if I82596_DEBUG
diff --git a/sys/arch/macppc/dev/if_mc.c b/sys/arch/macppc/dev/if_mc.c
index 22e6fe49581..e7bc9cc787e 100644
--- a/sys/arch/macppc/dev/if_mc.c
+++ b/sys/arch/macppc/dev/if_mc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_mc.c,v 1.23 2016/07/15 22:10:47 macallan Exp $ */
+/* $NetBSD: if_mc.c,v 1.24 2019/04/25 10:08:45 msaitoh Exp $ */
/*-
* Copyright (c) 1997 David Huang <khym@bga.com>
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.23 2016/07/15 22:10:47 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.24 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -61,15 +61,15 @@ __KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.23 2016/07/15 22:10:47 macallan Exp $");
hide int mc_match(device_t, cfdata_t, void *);
hide void mc_attach(device_t, device_t, void *);
-hide void mc_init(struct mc_softc *sc);
-hide void mc_putpacket(struct mc_softc *sc, u_int len);
-hide int mc_dmaintr(void *arg);
-hide void mc_reset_rxdma(struct mc_softc *sc);
-hide void mc_reset_txdma(struct mc_softc *sc);
-hide void mc_select_utp(struct mc_softc *sc);
-hide void mc_select_aui(struct mc_softc *sc);
-hide int mc_mediachange(struct mc_softc *sc);
-hide void mc_mediastatus(struct mc_softc *sc, struct ifmediareq *);
+hide void mc_init(struct mc_softc *);
+hide void mc_putpacket(struct mc_softc *, u_int);
+hide int mc_dmaintr(void *);
+hide void mc_reset_rxdma(struct mc_softc *);
+hide void mc_reset_txdma(struct mc_softc *);
+hide void mc_select_utp(struct mc_softc *);
+hide void mc_select_aui(struct mc_softc *);
+hide int mc_mediachange(struct mc_softc *);
+hide void mc_mediastatus(struct mc_softc *, struct ifmediareq *);
int mc_supmedia[] = {
IFM_ETHER | IFM_10_T,
@@ -77,7 +77,7 @@ int mc_supmedia[] = {
/*IFM_ETHER | IFM_AUTO,*/
};
-#define N_SUPMEDIA (sizeof(mc_supmedia) / sizeof(int));
+#define N_SUPMEDIA __arraycount(mc_supmedia)
CFATTACH_DECL_NEW(mc, sizeof(struct mc_softc),
mc_match, mc_attach, NULL, NULL);
@@ -106,7 +106,7 @@ mc_attach(device_t parent, device_t self, void *aux)
{
struct confargs *ca = aux;
struct mc_softc *sc = device_private(self);
- u_int8_t myaddr[ETHER_ADDR_LEN];
+ uint8_t myaddr[ETHER_ADDR_LEN];
u_int *reg;
sc->sc_dev = self;
@@ -137,13 +137,13 @@ mc_attach(device_t parent, device_t self, void *aux)
return;
}
- /* allocate memory for transmit buffer and mark it non-cacheable */
+ /* Allocate memory for transmit buffer and mark it non-cacheable */
sc->sc_txbuf = malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK);
sc->sc_txbuf_phys = kvtop(sc->sc_txbuf);
memset(sc->sc_txbuf, 0, PAGE_SIZE);
/*
- * allocate memory for receive buffer and mark it non-cacheable
+ * Allocate memory for receive buffer and mark it non-cacheable
* XXX This should use the bus_dma interface, since the buffer
* needs to be physically contiguous. However, it seems that
* at least on my system, malloc() does allocate contiguous
@@ -162,14 +162,13 @@ mc_attach(device_t parent, device_t self, void *aux)
sc->sc_bus_init = mc_init;
sc->sc_putpacket = mc_putpacket;
-
- /* disable receive DMA */
+ /* Disable receive DMA */
dbdma_reset(sc->sc_rxdma);
- /* disable transmit DMA */
+ /* Disable transmit DMA */
dbdma_reset(sc->sc_txdma);
- /* install interrupt handlers */
+ /* Install interrupt handlers */
/*intr_establish(ca->ca_intr[1], IST_EDGE, IPL_NET, mc_dmaintr, sc);*/
intr_establish(ca->ca_intr[2], IST_EDGE, IPL_NET, mc_dmaintr, sc);
intr_establish(ca->ca_intr[0], IST_EDGE, IPL_NET, mcintr, sc);
@@ -266,9 +265,9 @@ mc_dmaintr(void *arg)
sc->sc_rxframe.rx_rcvcnt = sc->sc_rxbuf[statoff + 0];
sc->sc_rxframe.rx_rcvsts = sc->sc_rxbuf[statoff + 1];
- sc->sc_rxframe.rx_rntpc = sc->sc_rxbuf[statoff + 2];
- sc->sc_rxframe.rx_rcvcc = sc->sc_rxbuf[statoff + 3];
- sc->sc_rxframe.rx_frame = sc->sc_rxbuf + offset;
+ sc->sc_rxframe.rx_rntpc = sc->sc_rxbuf[statoff + 2];
+ sc->sc_rxframe.rx_rcvcc = sc->sc_rxbuf[statoff + 3];
+ sc->sc_rxframe.rx_frame = sc->sc_rxbuf + offset;
mc_rint(sc);
@@ -292,7 +291,7 @@ mc_reset_rxdma(struct mc_softc *sc)
dbdma_command_t *cmd = sc->sc_rxdmacmd;
dbdma_regmap_t *dmareg = sc->sc_rxdma;
int i;
- u_int8_t maccc;
+ uint8_t maccc;
/* Disable receiver, reset the DMA channels */
maccc = NIC_GET(sc, MACE_MACCC);
@@ -325,9 +324,9 @@ mc_reset_txdma(struct mc_softc *sc)
{
dbdma_command_t *cmd = sc->sc_txdmacmd;
dbdma_regmap_t *dmareg = sc->sc_txdma;
- u_int8_t maccc;
+ uint8_t maccc;
- /* disable transmitter */
+ /* Disable transmitter */
maccc = NIC_GET(sc, MACE_MACCC);
NIC_PUT(sc, MACE_MACCC, maccc & ~ENXMT);
@@ -342,19 +341,21 @@ mc_reset_txdma(struct mc_softc *sc)
out32rb(&dmareg->d_cmdptrhi, 0);
out32rb(&dmareg->d_cmdptrlo, kvtop((void *)sc->sc_txdmacmd));
- /* restore old value */
+ /* Restore old value */
NIC_PUT(sc, MACE_MACCC, maccc);
}
void
mc_select_utp(struct mc_softc *sc)
{
+
sc->sc_plscc = PORTSEL_GPSI | ENPLSIO;
}
void
mc_select_aui(struct mc_softc *sc)
{
+
sc->sc_plscc = PORTSEL_AUI;
}
@@ -386,6 +387,7 @@ mc_mediachange(struct mc_softc *sc)
void
mc_mediastatus(struct mc_softc *sc, struct ifmediareq *ifmr)
{
+
if (sc->sc_plscc == PORTSEL_AUI)
ifmr->ifm_active = IFM_ETHER | IFM_10_5;
else
diff --git a/sys/arch/sparc/dev/if_ie_obio.c b/sys/arch/sparc/dev/if_ie_obio.c
index 6c9299225b6..b31bda332be 100644
--- a/sys/arch/sparc/dev/if_ie_obio.c
+++ b/sys/arch/sparc/dev/if_ie_obio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ie_obio.c,v 1.41 2013/10/19 19:40:23 mrg Exp $ */
+/* $NetBSD: if_ie_obio.c,v 1.42 2019/04/25 10:08:45 msaitoh Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.41 2013/10/19 19:40:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.42 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -130,7 +130,7 @@ CFATTACH_DECL_NEW(ie_obio, sizeof(struct ie_softc),
static int media[] = {
IFM_ETHER | IFM_10_2,
};
-#define NMEDIA (sizeof(media) / sizeof(media[0]))
+#define NMEDIA __arraycount(media)
/*
@@ -188,9 +188,9 @@ ie_obio_memcopyout(struct ie_softc *sc, const void *p, int offset, size_t size)
wcopy(p, addr, size);
}
-/* read a 16-bit value at BH offset */
+/* Read a 16-bit value at BH offset */
uint16_t ie_obio_read16(struct ie_softc *, int);
-/* write a 16-bit value at BH offset */
+/* Write a 16-bit value at BH offset */
void ie_obio_write16(struct ie_softc *, int, uint16_t);
void ie_obio_write24(struct ie_softc *, int, int);
@@ -205,6 +205,7 @@ ie_obio_read16(struct ie_softc *sc, int offset)
void
ie_obio_write16(struct ie_softc *sc, int offset, uint16_t v)
{
+
v = (((v&0xff)<<8) | ((v>>8)&0xff));
bus_space_write_2(sc->bt, sc->bh, offset, v);
}
@@ -232,14 +233,14 @@ ie_obio_match(device_t parent, cfdata_t cf, void *aux)
struct obio4_attach_args *oba;
if (uoba->uoba_isobio4 == 0)
- return (0);
+ return 0;
oba = &uoba->uoba_oba4;
- return (bus_space_probe(oba->oba_bustag, oba->oba_paddr,
+ return bus_space_probe(oba->oba_bustag, oba->oba_paddr,
1, /* probe size */
0, /* offset */
0, /* flags */
- NULL, NULL));
+ NULL, NULL);
}
void
@@ -274,27 +275,21 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
sc->sc_msize = memsize = 65536; /* XXX */
if (bus_space_map(oba->oba_bustag, oba->oba_paddr,
- sizeof(struct ieob),
- BUS_SPACE_MAP_LINEAR,
- &bh) != 0) {
+ sizeof(struct ieob), BUS_SPACE_MAP_LINEAR, &bh) != 0) {
printf("%s: cannot map registers\n", device_xname(self));
return;
}
sc->sc_reg = (void *)bh;
- /*
- * Allocate control & buffer memory.
- */
+ /* Allocate control & buffer memory. */
if ((error = bus_dmamap_create(dmatag, memsize, 1, memsize, 0,
- BUS_DMA_NOWAIT|BUS_DMA_24BIT,
- &sc->sc_dmamap)) != 0) {
+ BUS_DMA_NOWAIT|BUS_DMA_24BIT, &sc->sc_dmamap)) != 0) {
printf("%s: DMA map create error %d\n",
device_xname(self), error);
return;
}
- if ((error = bus_dmamem_alloc(dmatag, memsize, 64*1024, 0,
- &seg, 1, &rseg,
- BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
+ if ((error = bus_dmamem_alloc(dmatag, memsize, 64*1024, 0, &seg, 1,
+ &rseg, BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
printf("%s: DMA memory allocation error %d\n",
device_xname(self), error);
return;
@@ -302,8 +297,7 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
/* Map DMA buffer in CPU addressable space */
if ((error = bus_dmamem_map(dmatag, &seg, rseg, memsize,
- (void **)&sc->sc_maddr,
- BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
+ (void **)&sc->sc_maddr, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
printf("%s: DMA buffer map error %d\n",
device_xname(self), error);
bus_dmamem_free(dmatag, &seg, rseg);
@@ -311,9 +305,8 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
}
/* Load the segment */
- if ((error = bus_dmamap_load(dmatag, sc->sc_dmamap,
- sc->sc_maddr, memsize, NULL,
- BUS_DMA_NOWAIT)) != 0) {
+ if ((error = bus_dmamap_load(dmatag, sc->sc_dmamap, sc->sc_maddr,
+ memsize, NULL, BUS_DMA_NOWAIT)) != 0) {
printf("%s: DMA buffer map load error %d\n",
device_xname(self), error);
bus_dmamem_unmap(dmatag, sc->sc_maddr, memsize);
@@ -337,7 +330,7 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
* SCP; the actual buffers start at maddr+PAGE_SIZE.
*
* In a picture:
-
+
|---//--- ISCP-SCB-----scp-|--//- buffers -//-|... |iscp-scb-----SCP-|
| | | | | | |
| |<---PAGE_SIZE-->| | |<--PAGE_SIZE-+-->|
@@ -391,7 +384,6 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
i82586_attach(sc, "onboard", myaddr, media, NMEDIA, media[0]);
/* Establish interrupt channel */
- (void)bus_intr_establish(oba->oba_bustag,
- oba->oba_pri, IPL_NET,
- i82586_intr, sc);
+ (void)bus_intr_establish(oba->oba_bustag, oba->oba_pri, IPL_NET,
+ i82586_intr, sc);
}
diff --git a/sys/arch/sparc/dev/if_le_obio.c b/sys/arch/sparc/dev/if_le_obio.c
index 7b64ad9fbc7..4ea42377c5f 100644
--- a/sys/arch/sparc/dev/if_le_obio.c
+++ b/sys/arch/sparc/dev/if_le_obio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_obio.c,v 1.27 2011/07/01 18:50:41 dyoung Exp $ */
+/* $NetBSD: if_le_obio.c,v 1.28 2019/04/25 10:08:45 msaitoh Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_obio.c,v 1.27 2011/07/01 18:50:41 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_obio.c,v 1.28 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -72,9 +72,9 @@ struct le_softc {
* Media types supported.
*/
static int lemedia[] = {
- IFM_ETHER|IFM_10_T,
+ IFM_ETHER | IFM_10_T,
};
-#define NLEMEDIA (sizeof(lemedia) / sizeof(lemedia[0]))
+#define NLEMEDIA __arraycount(lemedia)
static int lematch_obio(device_t, cfdata_t, void *);
static void leattach_obio(device_t, device_t, void *);
@@ -105,7 +105,7 @@ lerdcsr(struct lance_softc *sc, uint16_t port)
bus_space_handle_t h = lesc->sc_reg;
bus_space_write_2(t, h, LEREG1_RAP, port);
- return (bus_space_read_2(t, h, LEREG1_RDP));
+ return bus_space_read_2(t, h, LEREG1_RDP);
}
static int
@@ -115,14 +115,14 @@ lematch_obio(device_t parent, cfdata_t cf, void *aux)
struct obio4_attach_args *oba;
if (uoba->uoba_isobio4 == 0)
- return (0);
+ return 0;
oba = &uoba->uoba_oba4;
- return (bus_space_probe(oba->oba_bustag, oba->oba_paddr,
+ return bus_space_probe(oba->oba_bustag, oba->oba_paddr,
2, /* probe size */
0, /* offset */
0, /* flags */
- NULL, NULL));
+ NULL, NULL);
}
static void
@@ -142,39 +142,34 @@ leattach_obio(device_t parent, device_t self, void *aux)
lesc->sc_dmatag = dmatag = oba->oba_dmatag;
if (bus_space_map(oba->oba_bustag, oba->oba_paddr,
- 2 * sizeof(uint16_t),
- 0, &lesc->sc_reg) != 0) {
+ 2 * sizeof(uint16_t), 0, &lesc->sc_reg) != 0) {
aprint_error(": cannot map registers\n");
return;
}
/* Get a DMA handle */
if ((error = bus_dmamap_create(dmatag, MEMSIZE, 1, MEMSIZE, 0,
- BUS_DMA_NOWAIT|BUS_DMA_24BIT,
- &lesc->sc_dmamap)) != 0) {
+ BUS_DMA_NOWAIT|BUS_DMA_24BIT, &lesc->sc_dmamap)) != 0) {
aprint_error(": DMA map create error %d\n", error);
return;
}
/* Allocate DMA buffer */
if ((error = bus_dmamem_alloc(dmatag, MEMSIZE, PAGE_SIZE, 0,
- &seg, 1, &rseg,
- BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
+ &seg, 1, &rseg, BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
aprint_error(": DMA memory allocation error %d\n", error);
return;
}
/* Map DMA buffer into kernel space */
if ((error = bus_dmamem_map(dmatag, &seg, rseg, MEMSIZE,
- (void **)&sc->sc_mem,
- BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
+ (void **)&sc->sc_mem, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
aprint_error(": DMA memory map error %d\n", error);
bus_dmamem_free(lesc->sc_dmatag, &seg, rseg);
return;
}
/* Load DMA buffer */
if ((error = bus_dmamap_load(dmatag, lesc->sc_dmamap,
- sc->sc_mem, MEMSIZE, NULL,
- BUS_DMA_NOWAIT)) != 0) {
+ sc->sc_mem, MEMSIZE, NULL, BUS_DMA_NOWAIT)) != 0) {
aprint_error(": DMA buffer map load error %d\n", error);
bus_dmamem_unmap(dmatag, (void *)sc->sc_mem, MEMSIZE);
bus_dmamem_free(dmatag, &seg, rseg);
@@ -204,5 +199,5 @@ leattach_obio(device_t parent, device_t self, void *aux)
/* Install interrupt */
(void)bus_intr_establish(lesc->sc_bustag, oba->oba_pri, IPL_NET,
- am7990_intr, sc);
+ am7990_intr, sc);
}
diff --git a/sys/arch/sun2/dev/if_ie_mbmem.c b/sys/arch/sun2/dev/if_ie_mbmem.c
index 4fba9f7cec6..c4266f61a0b 100644
--- a/sys/arch/sun2/dev/if_ie_mbmem.c
+++ b/sys/arch/sun2/dev/if_ie_mbmem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ie_mbmem.c,v 1.11 2011/06/03 16:28:40 tsutsui Exp $ */
+/* $NetBSD: if_ie_mbmem.c,v 1.12 2019/04/25 10:08:45 msaitoh Exp $ */
/*
* Copyright (c) 1995 Charles D. Cranor
@@ -111,7 +111,7 @@
*
* The page map to control where ram appears in the address space.
* We choose to have RAM start at 0 in the 24 bit address space.
- *
+ *
* to get the phyiscal address of the board's RAM you must take the
* top 12 bits of the physical address of the register address and
* or in the 4 bits from the status word as bits 17-20 (remember that
@@ -140,7 +140,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ie_mbmem.c,v 1.11 2011/06/03 16:28:40 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ie_mbmem.c,v 1.12 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -171,8 +171,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_ie_mbmem.c,v 1.11 2011/06/03 16:28:40 tsutsui Exp
*/
#define IEMBMEM_PAGESIZE 1024 /* bytes */
#define IEMBMEM_PAGSHIFT 10 /* bits */
-#define IEMBMEM_NPAGES 256 /* number of pages on chip */
-#define IEMBMEM_MAPSZ 1024 /* number of entries in the map */
+#define IEMBMEM_NPAGES 256 /* number of pages on chip */
+#define IEMBMEM_MAPSZ 1024 /* number of entries in the map */
/*
* PTE for the page map
@@ -219,8 +219,8 @@ struct iembmem {
/* Supported media */
static int media[] = {
IFM_ETHER | IFM_10_2,
-};
-#define NMEDIA (sizeof(media) / sizeof(media[0]))
+};
+#define NMEDIA __arraycount(media)
/*
* the 3E board not supported (yet?)
@@ -252,7 +252,7 @@ CFATTACH_DECL_NEW(ie_mbmem, sizeof(struct ie_mbmem_softc),
/*
* MULTIBUS support routines
*/
-void
+void
ie_mbmemreset(struct ie_softc *sc, int what)
{
struct ie_mbmem_softc *vsc = (struct ie_mbmem_softc *)sc;
@@ -261,18 +261,18 @@ ie_mbmemreset(struct ie_softc *sc, int what)
write_iev(vsc, status, 0);
}
-void
+void
ie_mbmemattend(struct ie_softc *sc, int why)
{
struct ie_mbmem_softc *vsc = (struct ie_mbmem_softc *)sc;
- /* flag! */
+ /* Flag! */
write_iev(vsc, status, read_iev(vsc, status) | IEMBMEM_ATTEN);
- /* down. */
+ /* Down. */
write_iev(vsc, status, read_iev(vsc, status) & ~IEMBMEM_ATTEN);
}
-void
+void
ie_mbmemrun(struct ie_softc *sc)
{
struct ie_mbmem_softc *vsc = (struct ie_mbmem_softc *)sc;
@@ -281,17 +281,15 @@ ie_mbmemrun(struct ie_softc *sc)
| IEMBMEM_ONAIR | IEMBMEM_IENAB | IEMBMEM_PEINT);
}
-int
+int
ie_mbmemintr(struct ie_softc *sc, int where)
{
struct ie_mbmem_softc *vsc = (struct ie_mbmem_softc *)sc;
if (where != INTR_ENTER)
- return (0);
+ return 0;
- /*
- * check for parity error
- */
+ /* check for parity error */
if (read_iev(vsc, status) & IEMBMEM_PERR) {
printf("%s: parity error (ctrl 0x%x @ 0x%02x%04x)\n",
device_xname(sc->sc_dev), read_iev(vsc, pectrl),
@@ -299,7 +297,7 @@ ie_mbmemintr(struct ie_softc *sc, int where)
read_iev(vsc, peaddr));
write_iev(vsc, pectrl, read_iev(vsc, pectrl) | IEMBMEM_PARACK);
}
- return (0);
+ return 0;
}
void ie_mbmemcopyin(struct ie_softc *, void *, int, size_t);
@@ -308,28 +306,30 @@ void ie_mbmemcopyout(struct ie_softc *, const void *, int, size_t);
/*
* Copy board memory to kernel.
*/
-void
+void
ie_mbmemcopyin(struct ie_softc *sc, void *p, int offset, size_t size)
{
+
bus_space_copyin(sc->bt, sc->bh, offset, p, size);
}
/*
* Copy from kernel space to board memory.
*/
-void
+void
ie_mbmemcopyout(struct ie_softc *sc, const void *p, int offset, size_t size)
{
+
bus_space_copyout(sc->bt, sc->bh, offset, p, size);
}
-/* read a 16-bit value at BH offset */
+/* Read a 16-bit value at BH offset */
uint16_t ie_mbmem_read16(struct ie_softc *, int offset);
-/* write a 16-bit value at BH offset */
+/* Write a 16-bit value at BH offset */
void ie_mbmem_write16(struct ie_softc *, int offset, uint16_t value);
void ie_mbmem_write24(struct ie_softc *, int offset, int addr);
-uint16_t
+uint16_t
ie_mbmem_read16(struct ie_softc *sc, int offset)
{
uint16_t v;
@@ -339,7 +339,7 @@ ie_mbmem_read16(struct ie_softc *sc, int offset)
return (((v&0xff)<<8) | ((v>>8)&0xff));
}
-void
+void
ie_mbmem_write16(struct ie_softc *sc, int offset, uint16_t v)
{
int v0 = ((((v)&0xff)<<8) | (((v)>>8)&0xff));
@@ -348,7 +348,7 @@ ie_mbmem_write16(struct ie_softc *sc, int offset, uint16_t v)
bus_space_barrier(sc->bt, sc->bh, offset, 2, BUS_SPACE_BARRIER_WRITE);
}
-void
+void
ie_mbmem_write24(struct ie_softc *sc, int offset, int addr)
{
u_char *f = (u_char *)&addr;
@@ -366,7 +366,7 @@ ie_mbmem_write24(struct ie_softc *sc, int offset, int addr)
bus_space_barrier(sc->bt, sc->bh, offset, 4, BUS_SPACE_BARRIER_WRITE);
}
-int
+int
ie_mbmem_match(device_t parent, cfdata_t cf, void *aux)
{
struct mbmem_attach_args *mbma = aux;
@@ -375,25 +375,25 @@ ie_mbmem_match(device_t parent, cfdata_t cf, void *aux)
/* No default Multibus address. */
if (mbma->mbma_paddr == -1)
- return(0);
+ return 0;
/* Make sure there is something there... */
- if (bus_space_map(mbma->mbma_bustag, mbma->mbma_paddr, sizeof(struct iembmem),
- 0, &bh))
- return (0);
+ if (bus_space_map(mbma->mbma_bustag, mbma->mbma_paddr,
+ sizeof(struct iembmem), 0, &bh))
+ return 0;
matched = (bus_space_peek_2(mbma->mbma_bustag, bh, 0, NULL) == 0);
bus_space_unmap(mbma->mbma_bustag, bh, sizeof(struct iembmem));
if (!matched)
- return (0);
+ return 0;
/* Default interrupt priority. */
if (mbma->mbma_pri == -1)
mbma->mbma_pri = 3;
- return (1);
+ return 1;
}
-void
+void
ie_mbmem_attach(device_t parent, device_t self, void *aux)
{
uint8_t myaddr[ETHER_ADDR_LEN];
@@ -427,8 +427,8 @@ ie_mbmem_attach(device_t parent, device_t self, void *aux)
/* Map in the board control regs. */
vsc->ievt = mbma->mbma_bustag;
- if (bus_space_map(mbma->mbma_bustag, mbma->mbma_paddr, sizeof(struct iembmem),
- 0, &vsc->ievh))
+ if (bus_space_map(mbma->mbma_bustag, mbma->mbma_paddr,
+ sizeof(struct iembmem), 0, &vsc->ievh))
panic("ie_mbmem_attach: can't map regs");
/*
@@ -449,8 +449,10 @@ ie_mbmem_attach(device_t parent, device_t self, void *aux)
* which is mapped at zero and at high address (for scp)
*/
for (lcv = 0; lcv < IEMBMEM_MAPSZ - 1; lcv++)
- write_iev(vsc, pgmap[lcv], IEMBMEM_SBORDR | IEMBMEM_OBMEM | lcv);
- write_iev(vsc, pgmap[IEMBMEM_MAPSZ - 1], IEMBMEM_SBORDR | IEMBMEM_OBMEM | 0);
+ write_iev(vsc, pgmap[lcv],
+ IEMBMEM_SBORDR | IEMBMEM_OBMEM | lcv);
+ write_iev(vsc, pgmap[IEMBMEM_MAPSZ - 1],
+ IEMBMEM_SBORDR | IEMBMEM_OBMEM | 0);
/* Clear all ram */
bus_space_set_region_2(sc->bt, sc->bh, 0, 0, memsize/2);
@@ -479,9 +481,7 @@ ie_mbmem_attach(device_t parent, device_t self, void *aux)
return;
}
- /*
- * Rest of first page is unused; rest of ram for buffers.
- */
+ /* Rest of first page is unused; rest of ram for buffers. */
sc->buf_area = IEMBMEM_PAGESIZE;
sc->buf_area_sz = memsize - IEMBMEM_PAGESIZE;
@@ -495,5 +495,5 @@ ie_mbmem_attach(device_t parent, device_t self, void *aux)
i82586_attach(sc, "multibus", myaddr, media, NMEDIA, media[0]);
bus_intr_establish(mbma->mbma_bustag, mbma->mbma_pri, IPL_NET, 0,
- i82586_intr, sc);
+ i82586_intr, sc);
}
diff --git a/sys/arch/sun2/dev/if_ie_obio.c b/sys/arch/sun2/dev/if_ie_obio.c
index 92b948767ef..5c0b14cc2a1 100644
--- a/sys/arch/sun2/dev/if_ie_obio.c
+++ b/sys/arch/sun2/dev/if_ie_obio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ie_obio.c,v 1.16 2014/03/24 18:50:31 christos Exp $ */
+/* $NetBSD: if_ie_obio.c,v 1.17 2019/04/25 10:08:45 msaitoh Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.16 2014/03/24 18:50:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.17 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -103,7 +103,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.16 2014/03/24 18:50:31 christos Exp
* the on-board interface
*/
struct ieob {
- u_char obctrl;
+ u_char obctrl;
};
#define IEOB_NORSET 0x80 /* don't reset the board */
#define IEOB_ONAIR 0x40 /* put us on the air */
@@ -130,14 +130,14 @@ CFATTACH_DECL_NEW(ie_obio, sizeof(struct ie_softc),
/* Supported media */
static int media[] = {
IFM_ETHER | IFM_10_2,
-};
-#define NMEDIA (sizeof(media) / sizeof(media[0]))
+};
+#define NMEDIA __arraycount(media)
/*
* OBIO ie support routines
*/
-void
+void
ie_obreset(struct ie_softc *sc, int what)
{
volatile struct ieob *ieo = (struct ieob *) sc->sc_reg;
@@ -145,7 +145,7 @@ ie_obreset(struct ie_softc *sc, int what)
delay(100); /* XXX could be shorter? */
ieo->obctrl = IEOB_NORSET;
}
-void
+void
ie_obattend(struct ie_softc *sc, int why)
{
volatile struct ieob *ieo = (struct ieob *) sc->sc_reg;
@@ -154,7 +154,7 @@ ie_obattend(struct ie_softc *sc, int why)
ieo->obctrl &= ~IEOB_ATTEN; /* down. */
}
-void
+void
ie_obrun(struct ie_softc *sc)
{
volatile struct ieob *ieo = (struct ieob *) sc->sc_reg;
@@ -168,18 +168,20 @@ void ie_obio_memcopyout(struct ie_softc *, const void *, int, size_t);
/*
* Copy board memory to kernel.
*/
-void
+void
ie_obio_memcopyin(struct ie_softc *sc, void *p, int offset, size_t size)
{
+
bus_space_copyin(sc->bt, sc->bh, offset, p, size);
}
/*
* Copy from kernel space to naord memory.
*/
-void
+void
ie_obio_memcopyout(struct ie_softc *sc, const void *p, int offset, size_t size)
{
+
bus_space_copyout(sc->bt, sc->bh, offset, p, size);
}
@@ -189,21 +191,23 @@ uint16_t ie_obio_read16(struct ie_softc *, int);
void ie_obio_write16(struct ie_softc *, int, uint16_t);
void ie_obio_write24(struct ie_softc *, int, int);
-uint16_t
+uint16_t
ie_obio_read16(struct ie_softc *sc, int offset)
{
uint16_t v = bus_space_read_2(sc->bt, sc->bh, offset);
+
return (((v&0xff)<<8) | ((v>>8)&0xff));
}
-void
+void
ie_obio_write16(struct ie_softc *sc, int offset, uint16_t v)
{
+
v = (((v&0xff)<<8) | ((v>>8)&0xff));
bus_space_write_2(sc->bt, sc->bh, offset, v);
}
-void
+void
ie_obio_write24(struct ie_softc *sc, int offset, int addr)
{
u_char *f = (u_char *)&addr;
@@ -219,7 +223,7 @@ ie_obio_write24(struct ie_softc *sc, int offset, int addr)
bus_space_write_2(sc->bt, sc->bh, offset+2, v1);
}
-int
+int
ie_obio_match(device_t parent, cfdata_t cf, void *aux)
{
struct obio_attach_args *oba = aux;
@@ -229,27 +233,27 @@ ie_obio_match(device_t parent, cfdata_t cf, void *aux)
/* No default obio address. */
if (oba->oba_paddr == -1)
- return(0);
-
+ return 0;
+
/* Make sure there is something there... */
- if (bus_space_map(oba->oba_bustag, oba->oba_paddr, sizeof(struct ieob),
- 0, &bh))
- return (0);
+ if (bus_space_map(oba->oba_bustag, oba->oba_paddr,
+ sizeof(struct ieob), 0, &bh))
+ return 0;
matched = (!bus_space_poke_1(oba->oba_bustag, bh, 0, IEOB_NORSET) &&
!bus_space_peek_1(oba->oba_bustag, bh, 0, &ctrl) &&
(ctrl & (IEOB_ONAIR|IEOB_IENAB)) == 0);
bus_space_unmap(oba->oba_bustag, bh, sizeof(struct ieob));
if (!matched)
- return (0);
+ return 0;
/* Default interrupt priority. */
if (oba->oba_pri == -1)
oba->oba_pri = 3;
- return (1);
+ return 1;
}
-void
+void
ie_obio_attach(device_t parent, device_t self, void *aux)
{
struct obio_attach_args *oba = aux;
@@ -280,7 +284,7 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
sc->sc_msize = memsize = 65536; /* XXX */
if (bus_space_map(oba->oba_bustag, oba->oba_paddr, sizeof(struct ieob),
- 0, &bh))
+ 0, &bh))
panic("ie_obio_attach: can't map regs");
sc->sc_reg = (void *)bh;
@@ -288,15 +292,13 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
* Allocate control & buffer memory.
*/
if ((error = bus_dmamap_create(dmatag, memsize, 1, memsize, 0,
- BUS_DMA_NOWAIT|BUS_DMA_24BIT,
- &sc->sc_dmamap)) != 0) {
+ BUS_DMA_NOWAIT|BUS_DMA_24BIT, &sc->sc_dmamap)) != 0) {
printf("%s: DMA map create error %d\n",
device_xname(self), error);
return;
}
if ((error = bus_dmamem_alloc(dmatag, memsize, 64*1024, 0,
- &seg, 1, &rseg,
- BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
+ &seg, 1, &rseg, BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
printf("%s: DMA memory allocation error %d\n",
device_xname(self), error);
return;
@@ -304,8 +306,7 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
/* Map DMA buffer in CPU addressable space */
if ((error = bus_dmamem_map(dmatag, &seg, rseg, memsize,
- (void **)&sc->sc_maddr,
- BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
+ (void **)&sc->sc_maddr, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
printf("%s: DMA buffer map error %d\n",
device_xname(self), error);
bus_dmamem_free(dmatag, &seg, rseg);
@@ -314,8 +315,7 @@ ie_obio_attach(device_t parent, device_t self, void *aux)
/* Load the segment */
if ((error = bus_dmamap_load(dmatag, sc->sc_dmamap,
- sc->sc_maddr, memsize, NULL,
- BUS_DMA_NOWAIT)) != 0) {
+ sc->sc_maddr, memsize, NULL, BUS_DMA_NOWAIT)) != 0) {
printf("%s: DMA buffer map load error %d\n",
device_xname(self), error);
bus_dmamem_unmap(dmatag, sc->sc_maddr, memsize);
diff --git a/sys/dev/ic/cs89x0.c b/sys/dev/ic/cs89x0.c
index c1843905d31..8d1e082b84c 100644
--- a/sys/dev/ic/cs89x0.c
+++ b/sys/dev/ic/cs89x0.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cs89x0.c,v 1.42 2019/02/05 06:17:02 msaitoh Exp $ */
+/* $NetBSD: cs89x0.c,v 1.43 2019/04/25 10:08:45 msaitoh Exp $ */
/*
* Copyright (c) 2004 Christopher Gilbert
@@ -147,7 +147,7 @@
**
** Revision 1.13 1997/05/22 21:06:54 cgd
** redo cs_copy_tx_frame() from scratch. It had a fatal flaw: it was blindly
-** casting from u_int8_t * to u_int16_t * without worrying about alignment
+** casting from uint8_t * to uint16_t * without worrying about alignment
** issues. This would cause bogus data to be spit out for mbufs with
** misaligned data. For instance, it caused the following bits to appear
** on the wire:
@@ -212,7 +212,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cs89x0.c,v 1.42 2019/02/05 06:17:02 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cs89x0.c,v 1.43 2019/04/25 10:08:45 msaitoh Exp $");
#include "opt_inet.h"
@@ -263,16 +263,16 @@ static int cs_reset_chip(struct cs_softc *);
static void cs_reset(struct cs_softc *);
static int cs_ioctl(struct ifnet *, u_long, void *);
static void cs_initChip(struct cs_softc *);
-static void cs_buffer_event(struct cs_softc *, u_int16_t);
-static void cs_transmit_event(struct cs_softc *, u_int16_t);
-static void cs_receive_event(struct cs_softc *, u_int16_t);
+static void cs_buffer_event(struct cs_softc *, uint16_t);
+static void cs_transmit_event(struct cs_softc *, uint16_t);
+static void cs_receive_event(struct cs_softc *, uint16_t);
static void cs_process_receive(struct cs_softc *);
static void cs_process_rx_early(struct cs_softc *);
static void cs_start_output(struct ifnet *);
static void cs_copy_tx_frame(struct cs_softc *, struct mbuf *);
static void cs_set_ladr_filt(struct cs_softc *, struct ethercom *);
-static u_int16_t cs_hash_index(char *);
-static void cs_counter_event(struct cs_softc *, u_int16_t);
+static uint16_t cs_hash_index(char *);
+static void cs_counter_event(struct cs_softc *, uint16_t);
static int cs_mediachange(struct ifnet *);
static void cs_mediastatus(struct ifnet *, struct ifmediareq *);
@@ -282,7 +282,7 @@ static int cs_enable(struct cs_softc *);
static void cs_disable(struct cs_softc *);
static void cs_stop(struct ifnet *, int);
static int cs_scan_eeprom(struct cs_softc *);
-static int cs_read_pktpg_from_eeprom(struct cs_softc *, int, u_int16_t *);
+static int cs_read_pktpg_from_eeprom(struct cs_softc *, int, uint16_t *);
/*
@@ -307,10 +307,10 @@ static int cs_read_pktpg_from_eeprom(struct cs_softc *, int, u_int16_t *);
* transmittion underrun occurs.
*/
struct cs_xmit_early {
- u_int16_t txcmd;
- int better;
- int better_count;
- int worse;
+ uint16_t txcmd;
+ int better;
+ int better_count;
+ int worse;
} cs_xmit_early_table[3] = {
{ TX_CMD_START_381, 0, INT_MAX, 1, },
{ TX_CMD_START_1021, 0, 50000, 2, },
@@ -318,31 +318,30 @@ struct cs_xmit_early {
};
int cs_default_media[] = {
- IFM_ETHER|IFM_10_2,
- IFM_ETHER|IFM_10_5,
- IFM_ETHER|IFM_10_T,
- IFM_ETHER|IFM_10_T|IFM_FDX,
+ IFM_ETHER | IFM_10_2,
+ IFM_ETHER | IFM_10_5,
+ IFM_ETHER | IFM_10_T,
+ IFM_ETHER | IFM_10_T | IFM_FDX,
};
-int cs_default_nmedia = sizeof(cs_default_media) / sizeof(cs_default_media[0]);
+int cs_default_nmedia = __arraycount(cs_default_media);
int
-cs_attach(struct cs_softc *sc, u_int8_t *enaddr, int *media,
+cs_attach(struct cs_softc *sc, uint8_t *enaddr, int *media,
int nmedia, int defmedia)
{
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
const char *chipname, *medname;
- u_int16_t reg;
+ uint16_t reg;
int i;
/* Start out in IO mode */
sc->sc_memorymode = FALSE;
- /* make sure we're right */
+ /* Make sure we're right */
for (i = 0; i < 10000; i++) {
reg = CS_READ_PACKET_PAGE(sc, PKTPG_EISA_NUM);
- if (reg == EISA_NUM_CRYSTAL) {
+ if (reg == EISA_NUM_CRYSTAL)
break;
- }
}
if (i == 10000) {
aprint_error_dev(sc->sc_dev, "wrong id(0x%x)\n", reg);
@@ -368,17 +367,16 @@ cs_attach(struct cs_softc *sc, u_int8_t *enaddr, int *media,
}
/*
- * the first thing to do is check that the mbuf cluster size is
+ * The first thing to do is check that the mbuf cluster size is
* greater than the MTU for an ethernet frame. The code depends on
* this and to port this to a OS where this was not the case would
* not be straightforward.
*
- * we need 1 byte spare because our
- * packet read loop can overrun.
+ * We need 1 byte spare because our packet read loop can overrun.
* and we may need pad bytes to align ip header.
*/
- if (MCLBYTES < ETHER_MAX_LEN + 1 +
- ALIGN(sizeof(struct ether_header)) - sizeof(struct ether_header)) {
+ if (MCLBYTES < ETHER_MAX_LEN + 1 + ALIGN(sizeof(struct ether_header))
+ - sizeof(struct ether_header)) {
printf("%s: MCLBYTES too small for Ethernet frame\n",
device_xname(sc->sc_dev));
return 1;
@@ -398,7 +396,7 @@ cs_attach(struct cs_softc *sc, u_int8_t *enaddr, int *media,
ifp->if_init = cs_init;
ifp->if_ioctl = cs_ioctl;
ifp->if_stop = cs_stop;
- ifp->if_watchdog = NULL; /* no watchdog at this stage */
+ ifp->if_watchdog = NULL; /* No watchdog at this stage */
ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
IFQ_SET_READY(&ifp->if_snd);
@@ -418,8 +416,12 @@ cs_attach(struct cs_softc *sc, u_int8_t *enaddr, int *media,
if (sc->sc_cfgflags & CFGFLG_PARSE_EEPROM) {
if (cs_scan_eeprom(sc) == CS_ERROR) {
- /* failed to scan the eeprom, pretend there isn't an eeprom */
- aprint_error_dev(sc->sc_dev, "unable to scan EEPROM\n");
+ /*
+ * Failed to scan the eeprom, pretend there isn't an
+ * eeprom
+ */
+ aprint_error_dev(sc->sc_dev,
+ "unable to scan EEPROM\n");
sc->sc_cfgflags |= CFGFLG_NOT_EEPROM;
}
}
@@ -520,12 +522,12 @@ cs_detach(struct cs_softc *sc)
}
#if 0
- /*
- * XXX not necessary
- */
+ /* XXX not necessary */
if (sc->sc_cfgflags & CFGFLG_DMA_MODE) {
- isa_dmamem_unmap(sc->sc_ic, sc->sc_drq, sc->sc_dmabase, sc->sc_dmasize);
- isa_dmamem_free(sc->sc_ic, sc->sc_drq, sc->sc_dmaaddr, sc->sc_dmasize);
+ isa_dmamem_unmap(sc->sc_ic, sc->sc_drq, sc->sc_dmabase,
+ sc->sc_dmasize);
+ isa_dmamem_free(sc->sc_ic, sc->sc_drq, sc->sc_dmaaddr,
+ sc->sc_dmasize);
isa_dmamap_destroy(sc->sc_ic, sc->sc_drq);
sc->sc_cfgflags &= ~CFGFLG_DMA_MODE;
}
@@ -550,7 +552,7 @@ cs_shutdown(device_t self, int howto)
void
cs_get_default_media(struct cs_softc *sc)
{
- u_int16_t adp_cfg, xmit_ctl;
+ uint16_t adp_cfg, xmit_ctl;
if (cs_verify_eeprom(sc) == CS_ERROR) {
aprint_error_dev(sc->sc_dev,
@@ -606,44 +608,44 @@ cs_get_default_media(struct cs_softc *sc)
int
cs_scan_eeprom(struct cs_softc *sc)
{
- u_int16_t result;
+ uint16_t result;
int i;
int eeprom_size;
- u_int8_t checksum = 0;
+ uint8_t checksum = 0;
if (cs_verify_eeprom(sc) == CS_ERROR) {
aprint_error_dev(sc->sc_dev,
"cs_scan_params: EEPROM missing or bad\n");
- return (CS_ERROR);
+ return CS_ERROR;
}
/*
- * read the 0th word from the eeprom, it will tell us the length
+ * Read the 0th word from the eeprom, it will tell us the length
* and if the eeprom is valid
*/
cs_read_eeprom(sc, 0, &result);
- /* check the eeprom signature */
+ /* Check the eeprom signature */
if ((result & 0xE000) != 0xA000) {
- /* empty eeprom */
- return (CS_ERROR);
+ /* Empty eeprom */
+ return CS_ERROR;
}
/*
- * take the eeprom size (note the read value doesn't include the header
+ * Take the eeprom size (note the read value doesn't include the header
* word)
*/
eeprom_size = (result & 0xff) + 2;
sc->eeprom_data = malloc(eeprom_size, M_DEVBUF, M_WAITOK);
if (sc->eeprom_data == NULL) {
- /* no memory, treat this as if there's no eeprom */
- return (CS_ERROR);
+ /* No memory, treat this as if there's no eeprom */
+ return CS_ERROR;
}
sc->eeprom_size = eeprom_size;
- /* read the eeprom into the buffer, also calculate the checksum */
+ /* Read the eeprom into the buffer, also calculate the checksum */
for (i = 0; i < (eeprom_size >> 1); i++) {
cs_read_eeprom(sc, i, &(sc->eeprom_data[i]));
checksum += (sc->eeprom_data[i] & 0xff00) >> 8;
@@ -651,26 +653,26 @@ cs_scan_eeprom(struct cs_softc *sc)
}
/*
- * validate checksum calculation, the sum of all the bytes should be 0,
+ * Validate checksum calculation, the sum of all the bytes should be 0,
* as the high byte of the last word is the 2's complement of the
* sum to that point.
*/
if (checksum != 0) {
aprint_error_dev(sc->sc_dev, "eeprom checksum failure\n");
- return (CS_ERROR);
+ return CS_ERROR;
}
- return (CS_OK);
+ return CS_OK;
}
static int
-cs_read_pktpg_from_eeprom(struct cs_softc *sc, int pktpg, u_int16_t *pValue)
+cs_read_pktpg_from_eeprom(struct cs_softc *sc, int pktpg, uint16_t *pValue)
{
int x, maxword;
/* Check that we have eeprom data */
if ((sc->eeprom_data == NULL) || (sc->eeprom_size < 2))
- return (CS_ERROR);
+ return CS_ERROR;
/*
* We only want to read the data words, the last word contains the
@@ -678,21 +680,21 @@ cs_read_pktpg_from_eeprom(struct cs_softc *sc, int pktpg, u_int16_t *pValue)
*/
maxword = (sc->eeprom_size - 2) >> 1;
- /* start 1 word in, as the first word is the length and signature */
+ /* Start 1 word in, as the first word is the length and signature */
x = 1;
while ( x < (maxword)) {
- u_int16_t header;
+ uint16_t header;
int group_size;
int offset;
int offset_max;
- /* read in the group header word */
+ /* Read in the group header word */
header = sc->eeprom_data[x];
- x++; /* skip group header */
+ x++; /* Skip group header */
/*
- * size of group in words is in the top 4 bits, note that it
+ * Size of group in words is in the top 4 bits, note that it
* is one less than the number of words
*/
group_size = header & 0xF000;
@@ -703,56 +705,62 @@ cs_read_pktpg_from_eeprom(struct cs_softc *sc, int pktpg, u_int16_t *pValue)
* perhaps the 8920 allows higher offsets, otherwise
* it's writing to places that it shouldn't
*/
- /* work out the offsets this group covers */
+ /* Work out the offsets this group covers */
offset = header & 0x0FFF;
offset_max = offset + (group_size << 1);
- /* check if the pkgpg we're after is in this group */
+ /* Check if the pkgpg we're after is in this group */
if ((offset <= pktpg) && (pktpg <= offset_max)) {
- /* the pkgpg value we want is in here */
+ /* The pkgpg value we want is in here */
int eeprom_location;
eeprom_location = ((pktpg - offset) >> 1) ;
*pValue = sc->eeprom_data[x + eeprom_location];
- return (CS_OK);
+ return CS_OK;
} else {
- /* skip this group (+ 1 for first entry) */
+ /* Skip this group (+ 1 for first entry) */
x += group_size + 1;
}
}
/*
- * if we've fallen out here then we don't have a value in the EEPROM
+ * If we've fallen out here then we don't have a value in the EEPROM
* for this pktpg so return an error
*/
- return (CS_ERROR);
+ return CS_ERROR;
}
int
cs_get_params(struct cs_softc *sc)
{
- u_int16_t isaConfig;
- u_int16_t adapterConfig;
+ uint16_t isaConfig;
+ uint16_t adapterConfig;
if (cs_verify_eeprom(sc) == CS_ERROR) {
aprint_error_dev(sc->sc_dev,
"cs_get_params: EEPROM missing or bad\n");
- return (CS_ERROR);
+ return CS_ERROR;
}
if (sc->sc_cfgflags & CFGFLG_PARSE_EEPROM) {
/* Get ISA configuration from the EEPROM */
if (cs_read_pktpg_from_eeprom(sc, PKTPG_BUS_CTL, &isaConfig)
- == CS_ERROR) {
- /* eeprom doesn't have this value, use data sheet default */
+ == CS_ERROR) {
+ /*
+ * Eeprom doesn't have this value, use data sheet
+ * default
+ */
isaConfig = 0x0017;
}
/* Get adapter configuration from the EEPROM */
- if (cs_read_pktpg_from_eeprom(sc, PKTPG_SELF_CTL, &adapterConfig)
- == CS_ERROR) {
- /* eeprom doesn't have this value, use data sheet default */
+ if (cs_read_pktpg_from_eeprom(sc, PKTPG_SELF_CTL,
+ &adapterConfig) == CS_ERROR) {
+ /*
+ * Eeprom doesn't have this value, use data sheet
+ * default
+ */
adapterConfig = 0x0015;
}
@@ -773,7 +781,8 @@ cs_get_params(struct cs_softc *sc)
goto eeprom_bad;
/* Get adapter configuration from the EEPROM */
- if (cs_read_eeprom(sc, EEPROM_ADPTR_CFG, &adapterConfig) == CS_ERROR)
+ if (cs_read_eeprom(sc, EEPROM_ADPTR_CFG, &adapterConfig)
+ == CS_ERROR)
goto eeprom_bad;
/* Copy the USE_SA flag */
@@ -789,11 +798,11 @@ cs_get_params(struct cs_softc *sc)
sc->sc_cfgflags |= CFGFLG_DCDC_POL;
}
- return (CS_OK);
+ return CS_OK;
eeprom_bad:
aprint_error_dev(sc->sc_dev,
"cs_get_params: unable to read from EEPROM\n");
- return (CS_ERROR);
+ return CS_ERROR;
}
int
@@ -805,7 +814,7 @@ cs_get_enaddr(struct cs_softc *sc)
if (cs_verify_eeprom(sc) == CS_ERROR) {
aprint_error_dev(sc->sc_dev,
"cs_get_enaddr: EEPROM missing or bad\n");
- return (CS_ERROR);
+ return CS_ERROR;
}
/* Get Ethernet address from the EEPROM */
@@ -833,12 +842,12 @@ cs_get_enaddr(struct cs_softc *sc)
sc->sc_enaddr[i * 2 + 1] = myea[i] >> 8;
}
- return (CS_OK);
+ return CS_OK;
eeprom_bad:
aprint_error_dev(sc->sc_dev,
"cs_get_enaddr: unable to read from EEPROM\n");
- return (CS_ERROR);
+ return CS_ERROR;
}
int
@@ -871,7 +880,7 @@ cs_reset_chip(struct cs_softc *sc)
sc->sc_txbusy = FALSE;
/*
- * there was a delay(125); here, but it seems uneccesary 125 usec is
+ * There was a delay(125); here, but it seems uneccesary 125 usec is
* 1/8000 of a second, not 1/8 of a second. the data sheet advises
* 1/10 of a second here, but the SI_BUSY and INIT_DONE loops below
* should be sufficient.
@@ -910,19 +919,19 @@ cs_reset_chip(struct cs_softc *sc)
int
cs_verify_eeprom(struct cs_softc *sc)
{
- u_int16_t self_status;
+ uint16_t self_status;
/* Verify that the EEPROM is present and OK */
self_status = CS_READ_PACKET_PAGE_IO(sc, PKTPG_SELF_ST);
if (((self_status & SELF_ST_EEP_PRES) &&
(self_status & SELF_ST_EEP_OK)) == 0)
- return (CS_ERROR);
+ return CS_ERROR;
- return (CS_OK);
+ return CS_OK;
}
int
-cs_read_eeprom(struct cs_softc *sc, int offset, u_int16_t *pValue)
+cs_read_eeprom(struct cs_softc *sc, int offset, uint16_t *pValue)
{
int x;
@@ -934,7 +943,7 @@ cs_read_eeprom(struct cs_softc *sc, int offset, u_int16_t *pValue)
}
if (x == MAXLOOP)
- return (CS_ERROR);
+ return CS_ERROR;
/* Issue the command to read the offset within the EEPROM */
CS_WRITE_PACKET_PAGE_IO(sc, PKTPG_EEPROM_CMD,
@@ -948,21 +957,21 @@ cs_read_eeprom(struct cs_softc *sc, int offset, u_int16_t *pValue)
}
if (x == MAXLOOP)
- return (CS_ERROR);
+ return CS_ERROR;
/* Get the EEPROM data from the EEPROM Data register */
*pValue = CS_READ_PACKET_PAGE_IO(sc, PKTPG_EEPROM_DATA);
- return (CS_OK);
+ return CS_OK;
}
void
cs_initChip(struct cs_softc *sc)
{
- u_int16_t busCtl;
- u_int16_t selfCtl;
- u_int16_t v;
- u_int16_t isaId;
+ uint16_t busCtl;
+ uint16_t selfCtl;
+ uint16_t v;
+ uint16_t isaId;
int i;
int media = IFM_SUBTYPE(sc->sc_media.ifm_cur->ifm_media);
@@ -999,9 +1008,7 @@ cs_initChip(struct cs_softc *sc)
/* If the media type is 10Base2 */
if (media == IFM_10_2) {
- /*
- * Enable the DC/DC converter if it has a low enable.
- */
+ /* Enable the DC/DC converter if it has a low enable. */
if ((sc->sc_cfgflags & CFGFLG_DCDC_POL) == 0)
/*
* Set the HCB1 bit, which causes the HC1 pin to go
@@ -1009,9 +1016,7 @@ cs_initChip(struct cs_softc *sc)
*/
selfCtl |= SELF_CTL_HCB1;
} else { /* Media type is 10BaseT or AUI */
- /*
- * Disable the DC/DC converter if it has a high enable.
- */
+ /* Disable the DC/DC converter if it has a high enable. */
if ((sc->sc_cfgflags & CFGFLG_DCDC_POL) != 0) {
/*
* Set the HCB1 bit, which causes the HC1 pin to go
@@ -1022,7 +1027,7 @@ cs_initChip(struct cs_softc *sc)
}
CS_WRITE_PACKET_PAGE(sc, PKTPG_SELF_CTL, selfCtl);
- /* enable normal link pulse */
+ /* Enable normal link pulse */
if (sc->sc_prodid == PROD_ID_CS8920 || sc->sc_prodid == PROD_ID_CS8920M)
CS_WRITE_PACKET_PAGE(sc, PKTPG_AUTONEG_CTL, AUTOCTL_NLP_ENABLE);
@@ -1032,7 +1037,7 @@ cs_initChip(struct cs_softc *sc)
/* RX_CTL set in cs_set_ladr_filt(), below */
- /* enable all transmission interrupts */
+ /* Enable all transmission interrupts */
CS_WRITE_PACKET_PAGE(sc, PKTPG_TX_CFG, TX_CFG_ALL_IE);
/* Accept all receive interrupts */
@@ -1041,8 +1046,8 @@ cs_initChip(struct cs_softc *sc)
/*
* Configure Operational Modes
*
- * I have turned off the BUF_CFG_RX_MISS_IE, to speed things up, this is
- * a better way to do it because the card has a counter which can be
+ * I have turned off the BUF_CFG_RX_MISS_IE, to speed things up, this
+ * is a better way to do it because the card has a counter which can be
* read to update the RX_MISS counter. This saves many interrupts.
*
* I have turned on the tx and rx overflow interrupts to counter using
@@ -1078,7 +1083,7 @@ cs_initChip(struct cs_softc *sc)
sc->sc_pktpgaddr >> 16);
busCtl = BUS_CTL_MEM_MODE;
- /* tell the chip to read the addresses off the SA pins */
+ /* Tell the chip to read the addresses off the SA pins */
if (sc->sc_cfgflags & CFGFLG_USE_SA) {
busCtl |= BUS_CTL_USE_SA;
}
@@ -1089,7 +1094,7 @@ cs_initChip(struct cs_softc *sc)
sc->sc_memorymode = TRUE;
/*
- * wait here (10ms) for the chip to swap over. this is the
+ * Wait here (10ms) for the chip to swap over. this is the
* maximum time that this could take.
*/
delay(10000);
@@ -1108,7 +1113,7 @@ cs_initChip(struct cs_softc *sc)
sc->sc_memorymode = FALSE;
} else {
/*
- * we are in memory mode so if we aren't using DMA,
+ * We are in memory mode so if we aren't using DMA,
* then program the chip to interrupt early.
*/
if ((sc->sc_cfgflags & CFGFLG_DMA_MODE) == 0) {
@@ -1130,18 +1135,18 @@ cs_initChip(struct cs_softc *sc)
if (sc->sc_irq != -1) {
/* Set the interrupt level in the chip */
if (sc->sc_prodid == PROD_ID_CS8900) {
- if (sc->sc_irq == 5) {
+ if (sc->sc_irq == 5)
CS_WRITE_PACKET_PAGE(sc, PKTPG_INT_NUM, 3);
- } else {
- CS_WRITE_PACKET_PAGE(sc, PKTPG_INT_NUM, (sc->sc_irq) - 10);
- }
- }
- else { /* CS8920 */
- CS_WRITE_PACKET_PAGE(sc, PKTPG_8920_INT_NUM, sc->sc_irq);
+ else
+ CS_WRITE_PACKET_PAGE(sc, PKTPG_INT_NUM,
+ (sc->sc_irq) - 10);
+ } else { /* CS8920 */
+ CS_WRITE_PACKET_PAGE(sc, PKTPG_8920_INT_NUM,
+ sc->sc_irq);
}
}
- /* write the multicast mask to the address filter register */
+ /* Write the multicast mask to the address filter register */
cs_set_ladr_filt(sc, &sc->sc_ethercom);
/* Enable reception and transmission of frames */
@@ -1190,9 +1195,8 @@ cs_init(struct ifnet *ifp)
/* Assume we have carrier until we are told otherwise. */
sc->sc_carrier = 1;
- } else {
+ } else
aprint_error_dev(sc->sc_dev, "unable to reset chip\n");
- }
splx(intState);
out:
@@ -1207,18 +1211,18 @@ cs_set_ladr_filt(struct cs_softc *sc, struct ethercom *ec)
struct ifnet *ifp = &ec->ec_if;
struct ether_multi *enm;
struct ether_multistep step;
- u_int16_t af[4];
- u_int16_t port, mask, index;
+ uint16_t af[4];
+ uint16_t port, mask, index;
/*
- * Set up multicast address filter by passing all multicast addresses
- * through a crc generator, and then using the high order 6 bits as an
- * index into the 64 bit logical address filter. The high order bit
- * selects the word, while the rest of the bits select the bit within
- * the word.
- */
+ * Set up multicast address filter by passing all multicast addresses
+ * through a crc generator, and then using the high order 6 bits as an
+ * index into the 64 bit logical address filter. The high order bit
+ * selects the word, while the rest of the bits select the bit within
+ * the word.
+ */
if (ifp->if_flags & IFF_PROMISC) {
- /* accept all valid frames. */
+ /* Accept all valid frames. */
CS_WRITE_PACKET_PAGE(sc, PKTPG_RX_CTL,
RX_CTL_PROMISC_A | RX_CTL_RX_OK_A |
RX_CTL_IND_A | RX_CTL_BCAST_A | RX_CTL_MCAST_A);
@@ -1227,7 +1231,7 @@ cs_set_ladr_filt(struct cs_softc *sc, struct ethercom *ec)
}
/*
- * accept frames if a. crc valid, b. individual address match c.
+ * Accept frames if a. crc valid, b. individual address match c.
* broadcast address,and d. multicast addresses matched in the hash
* filter
*/
@@ -1236,7 +1240,7 @@ cs_set_ladr_filt(struct cs_softc *sc, struct ethercom *ec)
/*
- * start off with all multicast flag clear, set it if we need to
+ * Start off with all multicast flag clear, set it if we need to
* later, otherwise we will leave it.
*/
ifp->if_flags &= ~IFF_ALLMULTI;
@@ -1252,33 +1256,33 @@ cs_set_ladr_filt(struct cs_softc *sc, struct ethercom *ec)
if (memcmp(enm->enm_addrlo, enm->enm_addrhi,
sizeof enm->enm_addrlo)) {
/*
- * We must listen to a range of multicast addresses.
- * For now, just accept all multicasts, rather than
- * trying to set only those filter bits needed to match
- * the range. (At this time, the only use of address
- * ranges is for IP multicast routing, for which the
- * range is big enough to require all bits set.)
- */
+ * We must listen to a range of multicast addresses.
+ * For now, just accept all multicasts, rather than
+ * trying to set only those filter bits needed to match
+ * the range. (At this time, the only use of address
+ * ranges is for IP multicast routing, for which the
+ * range is big enough to require all bits set.)
+ */
ifp->if_flags |= IFF_ALLMULTI;
af[0] = af[1] = af[2] = af[3] = 0xffff;
break;
} else {
/*
- * we have got an individual address so just set that
- * bit.
- */
+ * We have got an individual address so just set that
+ * bit.
+ */
index = cs_hash_index(enm->enm_addrlo);
/* Set the bit the Logical address filter. */
- port = (u_int16_t) (index >> 4);
- mask = (u_int16_t) (1 << (index & 0xf));
+ port = (uint16_t) (index >> 4);
+ mask = (uint16_t) (1 << (index & 0xf));
af[port] |= mask;
ETHER_NEXT_MULTI(step, enm);
}
}
- /* now program the chip with the addresses */
+ /* Now program the chip with the addresses */
CS_WRITE_PACKET_PAGE(sc, PKTPG_LOG_ADDR + 0, af[0]);
CS_WRITE_PACKET_PAGE(sc, PKTPG_LOG_ADDR + 2, af[1]);
CS_WRITE_PACKET_PAGE(sc, PKTPG_LOG_ADDR + 4, af[2]);
@@ -1286,7 +1290,7 @@ cs_set_ladr_filt(struct cs_softc *sc, struct ethercom *ec)
return;
}
-u_int16_t
+uint16_t
cs_hash_index(char *addr)
{
uint32_t crc;
@@ -1295,7 +1299,7 @@ cs_hash_index(char *addr)
crc = ether_crc32_le(addr, ETHER_ADDR_LEN);
hash_code = crc >> 26;
- return (hash_code);
+ return hash_code;
}
void
@@ -1319,7 +1323,7 @@ cs_ioctl(struct ifnet *ifp, u_long cmd, void *data)
state = splnet();
- result = 0; /* only set if something goes wrong */
+ result = 0; /* Only set if something goes wrong */
switch (cmd) {
case SIOCGIFMEDIA:
@@ -1356,7 +1360,7 @@ cs_mediachange(struct ifnet *ifp)
* to let the new value take hold.
*/
cs_init(ifp);
- return (0);
+ return 0;
}
void
@@ -1364,9 +1368,7 @@ cs_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
{
struct cs_softc *sc = ifp->if_softc;
- /*
- * The currently selected media is always the active media.
- */
+ /* The currently selected media is always the active media. */
ifmr->ifm_active = sc->sc_media.ifm_cur->ifm_media;
if (ifp->if_flags & IFF_UP) {
@@ -1381,8 +1383,8 @@ int
cs_intr(void *arg)
{
struct cs_softc *sc = arg;
- u_int16_t Event;
- u_int16_t rndEvent;
+ uint16_t Event;
+ uint16_t rndEvent;
/*printf("cs_intr %p\n", sc);*/
/* Ignore any interrupts that happen while the chip is being reset */
@@ -1399,7 +1401,7 @@ cs_intr(void *arg)
Event = CS_READ_PORT(sc, PORT_ISQ);
if ((Event & REG_NUM_MASK) == 0 || Event == 0xffff)
- return 0; /* not ours */
+ return 0; /* Not ours */
rndEvent = Event;
@@ -1439,21 +1441,19 @@ cs_intr(void *arg)
}
void
-cs_counter_event(struct cs_softc *sc, u_int16_t cntEvent)
+cs_counter_event(struct cs_softc *sc, uint16_t cntEvent)
{
struct ifnet *ifp;
- u_int16_t errorCount;
+ uint16_t errorCount;
ifp = &sc->sc_ethercom.ec_if;
switch (cntEvent & REG_NUM_MASK) {
case REG_NUM_TX_COL:
- /*
- * the count should be read before an overflow occurs.
- */
+ /* The count should be read before an overflow occurs. */
errorCount = CS_READ_PACKET_PAGE(sc, PKTPG_TX_COL);
/*
- * the tramsit event routine always checks the number of
+ * The tramsit event routine always checks the number of
* collisions for any packet so we don't increment any
* counters here, as they should already have been
* considered.
@@ -1477,29 +1477,28 @@ cs_counter_event(struct cs_softc *sc, u_int16_t cntEvent)
}
void
-cs_buffer_event(struct cs_softc *sc, u_int16_t bufEvent)
+cs_buffer_event(struct cs_softc *sc, uint16_t bufEvent)
{
/*
- * multiple events can be in the buffer event register at one time so
+ * Multiple events can be in the buffer event register at one time so
* a standard switch statement will not suffice, here every event
* must be checked.
*/
/*
- * if 128 bits have been rxed by the time we get here, the dest event
+ * If 128 bits have been rxed by the time we get here, the dest event
* will be cleared and 128 event will be set.
*/
- if ((bufEvent & (BUF_EVENT_RX_DEST | BUF_EVENT_RX_128)) != 0) {
+ if ((bufEvent & (BUF_EVENT_RX_DEST | BUF_EVENT_RX_128)) != 0)
cs_process_rx_early(sc);
- }
if (bufEvent & BUF_EVENT_RX_DMA) {
- /* process the receive data */
+ /* Process the receive data */
if (sc->sc_dma_process_rx)
(*sc->sc_dma_process_rx)(sc);
else
- /* should panic? */
+ /* Should panic? */
aprint_error_dev(sc->sc_dev, "unexpected DMA event\n");
}
@@ -1521,20 +1520,19 @@ cs_buffer_event(struct cs_softc *sc, u_int16_t bufEvent)
sc->sc_txbusy = FALSE;
}
- if (bufEvent & BUF_EVENT_SW_INT) {
+ if (bufEvent & BUF_EVENT_SW_INT)
printf("%s: software initiated interrupt\n",
device_xname(sc->sc_dev));
- }
}
void
-cs_transmit_event(struct cs_softc *sc, u_int16_t txEvent)
+cs_transmit_event(struct cs_softc *sc, uint16_t txEvent)
{
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
/* If there were any errors transmitting this frame */
- if (txEvent & (TX_EVENT_LOSS_CRS | TX_EVENT_SQE_ERR | TX_EVENT_OUT_WIN |
- TX_EVENT_JABBER | TX_EVENT_16_COLL)) {
+ if (txEvent & (TX_EVENT_LOSS_CRS | TX_EVENT_SQE_ERR |
+ TX_EVENT_OUT_WIN | TX_EVENT_JABBER | TX_EVENT_16_COLL)) {
/* Increment the output error count */
ifp->if_oerrors++;
@@ -1544,25 +1542,24 @@ cs_transmit_event(struct cs_softc *sc, u_int16_t txEvent)
/* If debugging is enabled then log error messages */
if (ifp->if_flags & IFF_DEBUG) {
- if (txEvent & TX_EVENT_LOSS_CRS) {
+ if (txEvent & TX_EVENT_LOSS_CRS)
aprint_error_dev(sc->sc_dev, "lost carrier\n");
- }
- if (txEvent & TX_EVENT_SQE_ERR) {
+
+ if (txEvent & TX_EVENT_SQE_ERR)
aprint_error_dev(sc->sc_dev, "SQE error\n");
- }
- if (txEvent & TX_EVENT_OUT_WIN) {
+
+ if (txEvent & TX_EVENT_OUT_WIN)
aprint_error_dev(sc->sc_dev,
"out-of-window collision\n");
- }
- if (txEvent & TX_EVENT_JABBER) {
+
+ if (txEvent & TX_EVENT_JABBER)
aprint_error_dev(sc->sc_dev, "jabber\n");
- }
- if (txEvent & TX_EVENT_16_COLL) {
- aprint_error_dev(sc->sc_dev, "16 collisions\n");
- }
+
+ if (txEvent & TX_EVENT_16_COLL)
+ aprint_error_dev(sc->sc_dev,
+ "16 collisions\n");
}
- }
- else {
+ } else {
/* Transmission successful, carrier is up. */
sc->sc_carrier = 1;
#ifdef SHARK
@@ -1571,11 +1568,10 @@ cs_transmit_event(struct cs_softc *sc, u_int16_t txEvent)
}
/* Add the number of collisions for this frame */
- if (txEvent & TX_EVENT_16_COLL) {
+ if (txEvent & TX_EVENT_16_COLL)
ifp->if_collisions += 16;
- } else {
+ else
ifp->if_collisions += ((txEvent & TX_EVENT_COLL_MASK) >> 11);
- }
ifp->if_opackets++;
@@ -1587,7 +1583,7 @@ cs_transmit_event(struct cs_softc *sc, u_int16_t txEvent)
}
void
-cs_print_rx_errors(struct cs_softc *sc, u_int16_t rxEvent)
+cs_print_rx_errors(struct cs_softc *sc, uint16_t rxEvent)
{
if (rxEvent & RX_EVENT_RUNT)
@@ -1608,7 +1604,7 @@ cs_print_rx_errors(struct cs_softc *sc, u_int16_t rxEvent)
}
void
-cs_receive_event(struct cs_softc *sc, u_int16_t rxEvent)
+cs_receive_event(struct cs_softc *sc, uint16_t rxEvent)
{
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
@@ -1617,9 +1613,7 @@ cs_receive_event(struct cs_softc *sc, u_int16_t rxEvent)
/* Increment the input error count */
ifp->if_ierrors++;
- /*
- * If debugging is enabled then log error messages.
- */
+ /* If debugging is enabled then log error messages. */
if (ifp->if_flags & IFF_DEBUG) {
if (rxEvent != REG_NUM_RX_EVENT) {
cs_print_rx_errors(sc, rxEvent);
@@ -1634,9 +1628,8 @@ cs_receive_event(struct cs_softc *sc, u_int16_t rxEvent)
CS_WRITE_PACKET_PAGE(sc, PKTPG_RX_CFG,
CS_READ_PACKET_PAGE(sc, PKTPG_RX_CFG) |
RX_CFG_SKIP);
- } else {
+ } else
aprint_error_dev(sc->sc_dev, "implied skip\n");
- }
}
} else {
/*
@@ -1662,7 +1655,7 @@ cs_process_receive(struct cs_softc *sc)
struct ifnet *ifp;
struct mbuf *m;
int totlen;
- u_int16_t *pBuff, *pBuffLimit;
+ uint16_t *pBuff, *pBuffLimit;
int pad;
unsigned int frameOffset = 0; /* XXX: gcc */
@@ -1682,9 +1675,8 @@ cs_process_receive(struct cs_softc *sc)
/* Get the length of the received frame */
totlen = CS_READ_PACKET_PAGE(sc, frameOffset);
frameOffset += 2;
- }
- else {
- /* drop status */
+ } else {
+ /* Drop status */
CS_READ_PORT(sc, PORT_RXTX_DATA);
/* Get the length of the received frame */
@@ -1695,7 +1687,7 @@ cs_process_receive(struct cs_softc *sc)
aprint_error_dev(sc->sc_dev, "invalid packet length %d\n",
totlen);
- /* skip the received frame */
+ /* Skip the received frame */
CS_WRITE_PACKET_PAGE(sc, PKTPG_RX_CFG,
CS_READ_PACKET_PAGE(sc, PKTPG_RX_CFG) | RX_CFG_SKIP);
return;
@@ -1707,7 +1699,7 @@ cs_process_receive(struct cs_softc *sc)
"cs_process_receive: unable to allocate mbuf\n");
ifp->if_ierrors++;
/*
- * couldn't allocate an mbuf so things are not good, may as
+ * Couldn't allocate an mbuf so things are not good, may as
* well drop the packet I think.
*
* have already read the length so we should be right to skip
@@ -1720,47 +1712,47 @@ cs_process_receive(struct cs_softc *sc)
m_set_rcvif(m, ifp);
m->m_pkthdr.len = totlen;
- /* number of bytes to align ip header on word boundary for ipintr */
+ /* Number of bytes to align ip header on word boundary for ipintr */
pad = ALIGN(sizeof(struct ether_header)) - sizeof(struct ether_header);
/*
- * alloc mbuf cluster if we need.
- * we need 1 byte spare because following
- * packet read loop can overrun.
+ * Alloc mbuf cluster if we need.
+ * We need 1 byte spare because following packet read loop can overrun.
*/
if (totlen + pad + 1 > MHLEN) {
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
- /* couldn't allocate an mbuf cluster */
+ /* Couldn't allocate an mbuf cluster */
aprint_error_dev(sc->sc_dev,
"cs_process_receive: "
"unable to allocate a cluster\n");
m_freem(m);
- /* skip the received frame */
+ /* Skip the received frame */
CS_WRITE_PACKET_PAGE(sc, PKTPG_RX_CFG,
- CS_READ_PACKET_PAGE(sc, PKTPG_RX_CFG) | RX_CFG_SKIP);
+ CS_READ_PACKET_PAGE(sc, PKTPG_RX_CFG)
+ | RX_CFG_SKIP);
return;
}
}
- /* align ip header on word boundary for ipintr */
+ /* Align ip header on word boundary for ipintr */
m->m_data += pad;
m->m_len = totlen;
- pBuff = mtod(m, u_int16_t *);
+ pBuff = mtod(m, uint16_t *);
- /* now read the data from the chip */
+ /* Now read the data from the chip */
if (sc->sc_memorymode) {
- pBuffLimit = pBuff + (totlen + 1) / 2; /* don't want to go over */
+ /* don't want to go over */
+ pBuffLimit = pBuff + (totlen + 1) / 2;
+
while (pBuff < pBuffLimit) {
*pBuff++ = CS_READ_PACKET_PAGE(sc, frameOffset);
frameOffset += 2;
}
- }
- else {
+ } else
IO_READ_MULTI_2(sc, PORT_RXTX_DATA, pBuff, (totlen + 1)>>1);
- }
cs_ether_input(sc, m);
}
@@ -1770,9 +1762,9 @@ cs_process_rx_early(struct cs_softc *sc)
{
struct ifnet *ifp;
struct mbuf *m;
- u_int16_t frameCount, oldFrameCount;
- u_int16_t rxEvent;
- u_int16_t *pBuff;
+ uint16_t frameCount, oldFrameCount;
+ uint16_t rxEvent;
+ uint16_t *pBuff;
int pad;
unsigned int frameOffset;
@@ -1789,7 +1781,7 @@ cs_process_rx_early(struct cs_softc *sc)
"cs_process_rx_early: unable to allocate mbuf\n");
ifp->if_ierrors++;
/*
- * couldn't allocate an mbuf so things are not good, may as
+ * Couldn't allocate an mbuf so things are not good, may as
* well drop the packet I think.
*
* have already read the length so we should be right to skip
@@ -1801,30 +1793,30 @@ cs_process_rx_early(struct cs_softc *sc)
}
m_set_rcvif(m, ifp);
/*
- * save processing by always using a mbuf cluster, guaranteed to fit
+ * Save processing by always using a mbuf cluster, guaranteed to fit
* packet
*/
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
- /* couldn't allocate an mbuf cluster */
+ /* Couldn't allocate an mbuf cluster */
aprint_error_dev(sc->sc_dev,
"cs_process_rx_early: unable to allocate a cluster\n");
m_freem(m);
- /* skip the frame */
+ /* Skip the frame */
CS_WRITE_PACKET_PAGE(sc, PKTPG_RX_CFG,
CS_READ_PACKET_PAGE(sc, PKTPG_RX_CFG) | RX_CFG_SKIP);
return;
}
- /* align ip header on word boundary for ipintr */
+ /* Align ip header on word boundary for ipintr */
pad = ALIGN(sizeof(struct ether_header)) - sizeof(struct ether_header);
m->m_data += pad;
- /* set up the buffer pointer to point to the data area */
- pBuff = mtod(m, u_int16_t *);
+ /* Set up the buffer pointer to point to the data area */
+ pBuff = mtod(m, uint16_t *);
/*
- * now read the frame byte counter until we have finished reading the
+ * Now read the frame byte counter until we have finished reading the
* frame
*/
oldFrameCount = 0;
@@ -1835,27 +1827,27 @@ cs_process_rx_early(struct cs_softc *sc)
frameOffset += 2;
}
- /* read the new count from the chip */
+ /* Read the new count from the chip */
frameCount = CS_READ_PACKET_PAGE(sc, PKTPG_FRAME_BYTE_COUNT);
}
- /* update the mbuf counts */
+ /* Update the mbuf counts */
m->m_len = oldFrameCount;
m->m_pkthdr.len = oldFrameCount;
- /* now check the Rx Event register */
+ /* Now check the Rx Event register */
rxEvent = CS_READ_PACKET_PAGE(sc, PKTPG_RX_EVENT);
if ((rxEvent & RX_EVENT_RX_OK) != 0) {
/*
- * do an implied skip, it seems to be more reliable than a
+ * Do an implied skip, it seems to be more reliable than a
* forced skip.
*/
rxEvent = CS_READ_PACKET_PAGE(sc, PKTPG_RX_STATUS);
rxEvent = CS_READ_PACKET_PAGE(sc, PKTPG_RX_LENGTH);
/*
- * now read the RX_EVENT register to perform an implied skip.
+ * Now read the RX_EVENT register to perform an implied skip.
*/
rxEvent = CS_READ_PACKET_PAGE(sc, PKTPG_RX_EVENT);
@@ -1872,24 +1864,22 @@ cs_start_output(struct ifnet *ifp)
struct cs_softc *sc;
struct mbuf *pMbuf;
struct mbuf *pMbufChain;
- u_int16_t BusStatus;
- u_int16_t Length;
+ uint16_t BusStatus;
+ uint16_t Length;
int txLoop = 0;
int dropout = 0;
sc = ifp->if_softc;
- /* check that the interface is up and running */
- if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) {
+ /* Check that the interface is up and running */
+ if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
return;
- }
/* Don't interrupt a transmission in progress */
- if (sc->sc_txbusy) {
+ if (sc->sc_txbusy)
return;
- }
- /* this loop will only run through once if transmission is successful */
+ /* This loop will only run through once if transmission is successful */
/*
* While there are packets to transmit and a transmit is not in
* progress
@@ -1900,9 +1890,9 @@ cs_start_output(struct ifnet *ifp)
break;
/*
- * If BPF is listening on this interface, let it see the packet
- * before we commit it to the wire.
- */
+ * If BPF is listening on this interface, let it see the packet
+ * before we commit it to the wire.
+ */
bpf_mtap(ifp, pMbufChain, BPF_D_OUT);
/* Find the total length of the data to transmit */
@@ -1926,18 +1916,15 @@ cs_start_output(struct ifnet *ifp)
*/
if (sc->sc_memorymode) {
CS_WRITE_PACKET_PAGE(sc, PKTPG_TX_CMD,
- cs_xmit_early_table[sc->sc_xe_ent].txcmd);
+ cs_xmit_early_table[sc->sc_xe_ent].txcmd);
CS_WRITE_PACKET_PAGE(sc, PKTPG_TX_LENGTH, Length);
- }
- else {
+ } else {
CS_WRITE_PORT(sc, PORT_TX_CMD,
- cs_xmit_early_table[sc->sc_xe_ent].txcmd);
+ cs_xmit_early_table[sc->sc_xe_ent].txcmd);
CS_WRITE_PORT(sc, PORT_TX_LENGTH, Length);
}
- /*
- * Adjust early-transmit machinery.
- */
+ /* Adjust early-transmit machinery. */
if (--sc->sc_xe_togo == 0) {
sc->sc_xe_ent =
cs_xmit_early_table[sc->sc_xe_ent].better;
@@ -1985,7 +1972,7 @@ cs_start_output(struct ifnet *ifp)
txLoop = 0;
} else {
/*
- * if we get here we want to try
+ * If we get here we want to try
* again with the same mbuf, until
* the chip lets us transmit.
*/
@@ -2021,25 +2008,23 @@ cs_copy_tx_frame(struct cs_softc *sc, struct mbuf *m0)
{
struct mbuf *m;
int len, leftover, frameoff;
- u_int16_t dbuf;
- u_int8_t *p;
+ uint16_t dbuf;
+ uint8_t *p;
#ifdef DIAGNOSTIC
- u_int8_t *lim;
+ uint8_t *lim;
#endif
/* Initialize frame pointer and data port address */
frameoff = PKTPG_TX_FRAME;
- /* start out with no leftover data */
+ /* Start out with no leftover data */
leftover = 0;
dbuf = 0;
/* Process the chain of mbufs */
for (m = m0; m != NULL; m = m->m_next) {
- /*
- * Process all of the data in a single mbuf.
- */
- p = mtod(m, u_int8_t *);
+ /* Process all of the data in a single mbuf. */
+ p = mtod(m, uint8_t *);
len = m->m_len;
#ifdef DIAGNOSTIC
lim = p + len;
@@ -2063,9 +2048,7 @@ cs_copy_tx_frame(struct cs_softc *sc, struct mbuf *m0)
}
leftover = 0;
} else if ((long) p & 1) {
- /*
- * Misaligned data. Buffer the next byte.
- */
+ /* Misaligned data. Buffer the next byte. */
dbuf = *p++;
len--;
leftover = 1;
@@ -2080,13 +2063,11 @@ cs_copy_tx_frame(struct cs_softc *sc, struct mbuf *m0)
len &= ~1;
if (sc->sc_memorymode) {
MEM_WRITE_REGION_2(sc, frameoff,
- (u_int16_t *) p, len >> 1);
+ (uint16_t *) p, len >> 1);
frameoff += len;
- }
- else {
- IO_WRITE_MULTI_2(sc,
- PORT_RXTX_DATA, (u_int16_t *)p, len >> 1);
- }
+ } else
+ IO_WRITE_MULTI_2(sc, PORT_RXTX_DATA,
+ (uint16_t *)p, len >> 1);
p += len;
if (leftover)
@@ -2102,12 +2083,10 @@ cs_copy_tx_frame(struct cs_softc *sc, struct mbuf *m0)
#endif
}
if (leftover) {
- if (sc->sc_memorymode) {
+ if (sc->sc_memorymode)
CS_WRITE_PACKET_PAGE(sc, frameoff, dbuf);
- }
- else {
+ else
CS_WRITE_PORT(sc, PORT_RXTX_DATA, dbuf);
- }
}
}
@@ -2121,12 +2100,12 @@ cs_enable(struct cs_softc *sc)
error = (*sc->sc_enable)(sc);
if (error)
- return (error);
+ return error;
}
sc->sc_cfgflags |= CFGFLG_ENABLED;
}
- return (0);
+ return 0;
}
static void
@@ -2151,9 +2130,8 @@ cs_stop(struct ifnet *ifp, int disable)
CS_WRITE_PACKET_PAGE(sc, PKTPG_BUF_CFG, 0);
CS_WRITE_PACKET_PAGE(sc, PKTPG_BUS_CTL, 0);
- if (disable) {
+ if (disable)
cs_disable(sc);
- }
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
}
diff --git a/sys/dev/ic/rtl80x9.c b/sys/dev/ic/rtl80x9.c
index 2b36429df8b..3f2b82e8017 100644
--- a/sys/dev/ic/rtl80x9.c
+++ b/sys/dev/ic/rtl80x9.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rtl80x9.c,v 1.16 2014/06/16 16:48:16 msaitoh Exp $ */
+/* $NetBSD: rtl80x9.c,v 1.17 2019/04/25 10:08:45 msaitoh Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtl80x9.c,v 1.16 2014/06/16 16:48:16 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl80x9.c,v 1.17 2019/04/25 10:08:45 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -66,14 +66,14 @@ rtl80x9_mediachange(struct dp8390_softc *dsc)
* set up in ne_pci_rtl8029_init_card() called via dp8390_init().
*/
dp8390_reset(dsc);
- return (0);
+ return 0;
}
void
rtl80x9_mediastatus(struct dp8390_softc *sc, struct ifmediareq *ifmr)
{
struct ifnet *ifp = &sc->sc_ec.ec_if;
- u_int8_t cr_proto = sc->cr_proto |
+ uint8_t cr_proto = sc->cr_proto |
((ifp->if_flags & IFF_RUNNING) ? ED_CR_STA : ED_CR_STP);
/*
@@ -86,9 +86,9 @@ rtl80x9_mediastatus(struct dp8390_softc *sc, struct ifmediareq *ifmr)
if (NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG0) &
RTL3_CONFIG0_BNC)
- ifmr->ifm_active = IFM_ETHER|IFM_10_2;
+ ifmr->ifm_active = IFM_ETHER | IFM_10_2;
else {
- ifmr->ifm_active = IFM_ETHER|IFM_10_T;
+ ifmr->ifm_active = IFM_ETHER | IFM_10_T;
if (NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG3) &
RTL3_CONFIG3_FUDUP)
ifmr->ifm_active |= IFM_FDX;
@@ -105,14 +105,14 @@ rtl80x9_init_card(struct dp8390_softc *sc)
{
struct ifmedia *ifm = &sc->sc_media;
struct ifnet *ifp = &sc->sc_ec.ec_if;
- u_int8_t cr_proto = sc->cr_proto |
+ uint8_t cr_proto = sc->cr_proto |
((ifp->if_flags & IFF_RUNNING) ? ED_CR_STA : ED_CR_STP);
- u_int8_t reg;
+ uint8_t reg;
/* Set NIC to page 3 registers. */
NIC_PUT(sc->sc_regt, sc->sc_regh, ED_P0_CR, cr_proto | ED_CR_PAGE_3);
- /* write enable config1-3. */
+ /* Write enable config1-3. */
NIC_PUT(sc->sc_regt, sc->sc_regh, NERTL_RTL3_EECR,
RTL3_EECR_EEM1|RTL3_EECR_EEM0);
@@ -146,7 +146,7 @@ rtl80x9_init_card(struct dp8390_softc *sc)
reg &= ~RTL3_CONFIG3_FUDUP;
NIC_PUT(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG3, reg);
- /* write disable config1-3 */
+ /* Write disable config1-3 */
NIC_PUT(sc->sc_regt, sc->sc_regh, NERTL_RTL3_EECR, 0);
/* Set NIC to page 0 registers. */
@@ -157,16 +157,15 @@ void
rtl80x9_media_init(struct dp8390_softc *sc)
{
static int rtl80x9_media[] = {
- IFM_ETHER|IFM_AUTO,
- IFM_ETHER|IFM_10_T,
- IFM_ETHER|IFM_10_T|IFM_FDX,
- IFM_ETHER|IFM_10_2,
+ IFM_ETHER | IFM_AUTO,
+ IFM_ETHER | IFM_10_T,
+ IFM_ETHER | IFM_10_T|IFM_FDX,
+ IFM_ETHER | IFM_10_2,
};
- static const int rtl80x9_nmedia =
- sizeof(rtl80x9_media) / sizeof(rtl80x9_media[0]);
+ static const int rtl80x9_nmedia = __arraycount(rtl80x9_media);
int i, defmedia;
- u_int8_t conf2, conf3;
+ uint8_t conf2, conf3;
aprint_normal_dev(sc->sc_dev,
"10base2, 10baseT, 10baseT-FDX, auto, default ");
diff --git a/sys/dev/ic/smc91cxx.c b/sys/dev/ic/smc91cxx.c
index eb5a61faad4..5cfe522d9d2 100644
--- a/sys/dev/ic/smc91cxx.c
+++ b/sys/dev/ic/smc91cxx.c
@@ -1,4 +1,4 @@
-/* $NetBSD: smc91cxx.c,v 1.100 2019/04/22 09:00:12 msaitoh Exp $ */
+/* $NetBSD: smc91cxx.c,v 1.101 2019/04/25 10:08:45 msaitoh Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.100 2019/04/22 09:00:12 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.101 2019/04/25 10:08:45 msaitoh Exp $");
#include "opt_inet.h"
@@ -118,7 +118,7 @@ __KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.100 2019/04/22 09:00:12 msaitoh Exp $
#define bus_space_read_multi_stream_4 bus_space_read_multi_4
#define bus_space_write_stream_4 bus_space_write_4
-#define bus_space_read_stream_4 bus_space_read_4
+#define bus_space_read_stream_4 bus_space_read_4
#endif /* __BUS_SPACE_HAS_STREAM_METHODS */
/* XXX Hardware padding doesn't work yet(?) */
@@ -145,16 +145,16 @@ const char *smc91cxx_idstrs[] = {
/* Supported media types. */
static const int smc91cxx_media[] = {
- IFM_ETHER|IFM_10_T,
- IFM_ETHER|IFM_10_5,
+ IFM_ETHER | IFM_10_T,
+ IFM_ETHER | IFM_10_5,
};
-#define NSMC91CxxMEDIA (sizeof(smc91cxx_media) / sizeof(smc91cxx_media[0]))
+#define NSMC91CxxMEDIA __arraycount(smc91cxx_media)
/*
* MII bit-bang glue.
*/
-u_int32_t smc91cxx_mii_bitbang_read(device_t);
-void smc91cxx_mii_bitbang_write(device_t, u_int32_t);
+uint32_t smc91cxx_mii_bitbang_read(device_t);
+void smc91cxx_mii_bitbang_write(device_t, uint32_t);
static const struct mii_bitbang_ops smc91cxx_mii_bitbang_ops = {
smc91cxx_mii_bitbang_read,
@@ -193,8 +193,8 @@ static inline int ether_cmp(const void *, const void *);
static inline int
ether_cmp(const void *va, const void *vb)
{
- const u_int8_t *a = va;
- const u_int8_t *b = vb;
+ const uint8_t *a = va;
+ const uint8_t *b = vb;
return ((a[5] != b[5]) || (a[4] != b[4]) || (a[3] != b[3]) ||
(a[2] != b[2]) || (a[1] != b[1]) || (a[0] != b[0]));
@@ -226,16 +226,16 @@ smc91cxx_intr_ack_write(bus_space_tag_t bst, bus_space_handle_t bsh,
}
void
-smc91cxx_attach(struct smc91cxx_softc *sc, u_int8_t *myea)
+smc91cxx_attach(struct smc91cxx_softc *sc, uint8_t *myea)
{
struct ifnet *ifp = &sc->sc_ec.ec_if;
bus_space_tag_t bst = sc->sc_bst;
bus_space_handle_t bsh = sc->sc_bsh;
struct ifmedia *ifm = &sc->sc_mii.mii_media;
const char *idstr;
- u_int32_t miicapabilities;
- u_int16_t tmp;
- u_int8_t enaddr[ETHER_ADDR_LEN];
+ uint32_t miicapabilities;
+ uint16_t tmp;
+ uint8_t enaddr[ETHER_ADDR_LEN];
int i, aui, mult, scale, memsize;
char pbuf[9];
@@ -347,20 +347,18 @@ smc91cxx_attach(struct smc91cxx_softc *sc, u_int8_t *myea)
MII_PHY_ANY, MII_OFFSET_ANY, 0);
if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
ifmedia_add(&sc->sc_mii.mii_media,
- IFM_ETHER|IFM_NONE, 0, NULL);
+ IFM_ETHER | IFM_NONE, 0, NULL);
ifmedia_set(&sc->sc_mii.mii_media,
- IFM_ETHER|IFM_NONE);
+ IFM_ETHER | IFM_NONE);
} else {
ifmedia_set(&sc->sc_mii.mii_media,
- IFM_ETHER|IFM_AUTO);
+ IFM_ETHER | IFM_AUTO);
}
sc->sc_flags |= SMC_FLAGS_HAS_MII;
break;
} else
if (sc->sc_chipid == CHIP_91C111) {
- /*
- * XXX: Should bring it out of low-power mode
- */
+ /* XXX: Should bring it out of low-power mode */
aprint_normal("EPH interface in low power mode\n");
sc->sc_internal_phy = 0;
return;
@@ -393,7 +391,7 @@ smc91cxx_mediachange(struct ifnet *ifp)
{
struct smc91cxx_softc *sc = ifp->if_softc;
- return (smc91cxx_set_media(sc, sc->sc_mii.mii_media.ifm_media));
+ return smc91cxx_set_media(sc, sc->sc_mii.mii_media.ifm_media);
}
int
@@ -401,7 +399,7 @@ smc91cxx_set_media(struct smc91cxx_softc *sc, int media)
{
bus_space_tag_t bst = sc->sc_bst;
bus_space_handle_t bsh = sc->sc_bsh;
- u_int16_t tmp;
+ uint16_t tmp;
int rc;
/*
@@ -410,10 +408,10 @@ smc91cxx_set_media(struct smc91cxx_softc *sc, int media)
* up the media for us.
*/
if ((sc->sc_flags & SMC_FLAGS_ENABLED) == 0)
- return (0);
+ return 0;
if (IFM_TYPE(media) != IFM_ETHER)
- return (EINVAL);
+ return EINVAL;
if ((sc->sc_flags & SMC_FLAGS_HAS_MII) == 0 ||
(rc = mii_mediachg(&sc->sc_mii)) == ENXIO)
@@ -433,7 +431,7 @@ smc91cxx_set_media(struct smc91cxx_softc *sc, int media)
break;
default:
- return (EINVAL);
+ return EINVAL;
}
return rc;
@@ -448,7 +446,7 @@ smc91cxx_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
struct smc91cxx_softc *sc = ifp->if_softc;
bus_space_tag_t bst = sc->sc_bst;
bus_space_handle_t bsh = sc->sc_bsh;
- u_int16_t tmp;
+ uint16_t tmp;
if ((sc->sc_flags & SMC_FLAGS_ENABLED) == 0) {
ifmr->ifm_active = IFM_ETHER | IFM_NONE;
@@ -456,9 +454,7 @@ smc91cxx_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
return;
}
- /*
- * If we have MII, go ask the PHY what's going on.
- */
+ /* If we have MII, go ask the PHY what's going on. */
if (sc->sc_flags & SMC_FLAGS_HAS_MII) {
mii_pollstat(&sc->sc_mii);
ifmr->ifm_active = sc->sc_mii.mii_media_active;
@@ -481,8 +477,8 @@ smc91cxx_init(struct smc91cxx_softc *sc)
struct ifnet *ifp = &sc->sc_ec.ec_if;
bus_space_tag_t bst = sc->sc_bst;
bus_space_handle_t bsh = sc->sc_bsh;
- u_int16_t tmp;
- const u_int8_t *enaddr;
+ uint16_t tmp;
+ const uint8_t *enaddr;
int s, i;
s = splnet();
@@ -502,7 +498,7 @@ smc91cxx_init(struct smc91cxx_softc *sc)
/* Set the Ethernet address. */
SMC_SELECT_BANK(sc, 1);
- enaddr = (const u_int8_t *)CLLADDR(ifp->if_sadl);
+ enaddr = (const uint8_t *)CLLADDR(ifp->if_sadl);
for (i = 0; i < ETHER_ADDR_LEN; i += 2) {
tmp = enaddr[i + 1] << 8 | enaddr[i];
bus_space_write_2(bst, bsh, IAR_ADDR0_REG_W + i, tmp);
@@ -516,16 +512,14 @@ smc91cxx_init(struct smc91cxx_softc *sc)
bus_space_write_2(bst, bsh, CONTROL_REG_W, (CTR_AUTO_RELEASE |
CTR_TE_ENABLE | CTR_CR_ENABLE | CTR_LE_ENABLE));
- /*
- * Reset the MMU and wait for it to be un-busy.
- */
+ /* Reset the MMU and wait for it to be un-busy. */
SMC_SELECT_BANK(sc, 2);
bus_space_write_2(bst, bsh, MMU_CMD_REG_W, MMUCR_RESET);
sc->sc_txpacketno = ARR_FAILED;
for (;;) {
tmp = bus_space_read_2(bst, bsh, MMU_CMD_REG_W);
if (tmp == 0xffff) {
- /* card went away! */
+ /* Card went away! */
splx(s);
return;
}
@@ -533,9 +527,7 @@ smc91cxx_init(struct smc91cxx_softc *sc)
break;
}
- /*
- * Disable all interrupts.
- */
+ /* Disable all interrupts. */
smc91cxx_intr_mask_write(bst, bsh, 0);
/*
@@ -551,9 +543,7 @@ smc91cxx_init(struct smc91cxx_softc *sc)
(RPC_LS_TXRX << RPC_LSB_SHIFT));
}
- /*
- * Set current media.
- */
+ /* Set current media. */
smc91cxx_set_media(sc, sc->sc_mii.mii_media.ifm_cur->ifm_media);
/*
@@ -572,9 +562,7 @@ smc91cxx_init(struct smc91cxx_softc *sc)
bus_space_write_2(bst, bsh, RECV_CONTROL_REG_W, tmp);
- /*
- * Set transmitter control to "enabled".
- */
+ /* Set transmitter control to "enabled". */
tmp = TCR_ENABLE;
#ifndef SMC91CXX_SW_PAD
@@ -587,9 +575,7 @@ smc91cxx_init(struct smc91cxx_softc *sc)
bus_space_write_2(bst, bsh, TXMIT_CONTROL_REG_W, tmp);
- /*
- * Now, enable interrupts.
- */
+ /* Now, enable interrupts. */
SMC_SELECT_BANK(sc, 2);
sc->sc_intmask = IM_EPH_INT | IM_RX_OVRN_INT | IM_RCV_INT;
@@ -607,9 +593,7 @@ smc91cxx_init(struct smc91cxx_softc *sc)
callout_reset(&sc->sc_mii_callout, hz, smc91cxx_tick, sc);
}
- /*
- * Attempt to start any pending transmission.
- */
+ /* Attempt to start any pending transmission. */
smc91cxx_start(ifp);
splx(s);
@@ -627,18 +611,16 @@ smc91cxx_start(struct ifnet *ifp)
bus_space_handle_t bsh = sc->sc_bsh;
u_int len;
struct mbuf *m;
- u_int16_t length, npages;
- u_int16_t oddbyte;
- u_int8_t packetno;
+ uint16_t length, npages;
+ uint16_t oddbyte;
+ uint8_t packetno;
int timo, pad;
if ((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING)
return;
again:
- /*
- * Peek at the next packet.
- */
+ /* Peek at the next packet. */
IFQ_POLL(&ifp->if_snd, m);
if (m == NULL)
return;
@@ -652,7 +634,7 @@ smc91cxx_start(struct ifnet *ifp)
len += m->m_len;
/*
- * We drop packets that are too large. Perhaps we should
+ * We drop packets that are too large. Perhaps we should
* truncate them instead?
*/
if (len > (ETHER_MAX_LEN - ETHER_CRC_LEN)) {
@@ -666,9 +648,7 @@ smc91cxx_start(struct ifnet *ifp)
pad = 0;
#ifdef SMC91CXX_SW_PAD
- /*
- * Not using hardware padding; pad to ETHER_MIN_LEN.
- */
+ /* Not using hardware padding; pad to ETHER_MIN_LEN. */
if (len < (ETHER_MIN_LEN - ETHER_CRC_LEN))
pad = ETHER_MIN_LEN - ETHER_CRC_LEN - len;
#endif
@@ -682,9 +662,7 @@ smc91cxx_start(struct ifnet *ifp)
*/
npages = ((length & ~1) + 6) >> 8;
- /*
- * Now allocate the memory.
- */
+ /* Now allocate the memory. */
SMC_SELECT_BANK(sc, 2);
bus_space_write_2(bst, bsh, MMU_CMD_REG_W, MMUCR_ALLOC | npages);
@@ -695,7 +673,7 @@ smc91cxx_start(struct ifnet *ifp)
} else {
do {
if (bus_space_read_1(bst, bsh,
- INTR_STAT_REG_B) & IM_ALLOC_INT)
+ INTR_STAT_REG_B) & IM_ALLOC_INT)
break;
delay(1);
} while (--timo);
@@ -720,14 +698,10 @@ smc91cxx_start(struct ifnet *ifp)
return;
}
- /*
- * We have a packet number - set the data window.
- */
+ /* We have a packet number - set the data window. */
bus_space_write_2(bst, bsh, PACKET_NUM_REG_B, packetno);
- /*
- * Point to the beginning of the packet.
- */
+ /* Point to the beginning of the packet. */
bus_space_write_2(bst, bsh, POINTER_REG_W, PTR_AUTOINC /* | 0x0000 */);
/*
@@ -756,9 +730,7 @@ smc91cxx_start(struct ifnet *ifp)
pad -= 1;
}
- /*
- * Push out padding.
- */
+ /* Push out padding. */
while (pad > 1) {
bus_space_write_2(bst, bsh, DATA_REG_W, 0);
pad -= 2;
@@ -810,22 +782,20 @@ smc91cxx_copy_tx_frame(struct smc91cxx_softc *sc, struct mbuf *m0)
bus_space_handle_t bsh = sc->sc_bsh;
struct mbuf *m;
int len, leftover;
- u_int16_t dbuf;
- u_int8_t *p;
+ uint16_t dbuf;
+ uint8_t *p;
#ifdef DIAGNOSTIC
- u_int8_t *lim;
+ uint8_t *lim;
#endif
- /* start out with no leftover data */
+ /* Start out with no leftover data */
leftover = 0;
dbuf = 0;
/* Process the chain of mbufs */
for (m = m0; m != NULL; m = m->m_next) {
- /*
- * Process all of the data in a single mbuf.
- */
- p = mtod(m, u_int8_t *);
+ /* Process all of the data in a single mbuf. */
+ p = mtod(m, uint8_t *);
len = m->m_len;
#ifdef DIAGNOSTIC
lim = p + len;
@@ -843,9 +813,7 @@ smc91cxx_copy_tx_frame(struct smc91cxx_softc *sc, struct mbuf *m0)
bus_space_write_2(bst, bsh, DATA_REG_W, dbuf);
leftover = 0;
} else if ((long) p & 1) {
- /*
- * Misaligned data. Buffer the next byte.
- */
+ /* Misaligned data. Buffer the next byte. */
dbuf = *p++;
len--;
leftover = 1;
@@ -859,7 +827,7 @@ smc91cxx_copy_tx_frame(struct smc91cxx_softc *sc, struct mbuf *m0)
leftover = len & 1;
len &= ~1;
bus_space_write_multi_stream_2(bst, bsh,
- DATA_REG_W, (u_int16_t *)p, len >> 1);
+ DATA_REG_W, (uint16_t *)p, len >> 1);
p += len;
if (leftover)
@@ -888,19 +856,17 @@ smc91cxx_intr(void *arg)
struct ifnet *ifp = &sc->sc_ec.ec_if;
bus_space_tag_t bst = sc->sc_bst;
bus_space_handle_t bsh = sc->sc_bsh;
- u_int8_t mask, interrupts, status;
- u_int16_t packetno, tx_status, card_stats;
- u_int16_t v;
+ uint8_t mask, interrupts, status;
+ uint16_t packetno, tx_status, card_stats;
+ uint16_t v;
if ((sc->sc_flags & SMC_FLAGS_ENABLED) == 0 ||
!device_is_active(sc->sc_dev))
- return (0);
+ return 0;
SMC_SELECT_BANK(sc, 2);
- /*
- * Obtain the current interrupt status and mask.
- */
+ /* Obtain the current interrupt status and mask. */
v = bus_space_read_2(bst, bsh, INTR_STAT_REG_B);
/*
@@ -914,46 +880,34 @@ smc91cxx_intr(void *arg)
/* Ours? */
if (status == 0)
- return (0);
+ return 0;
- /*
- * It's ours; disable all interrupts while we process them.
- */
+ /* It's ours; disable all interrupts while we process them. */
smc91cxx_intr_mask_write(bst, bsh, 0);
- /*
- * Receive overrun interrupts.
- */
+ /* Receive overrun interrupts. */
if (status & IM_RX_OVRN_INT) {
smc91cxx_intr_ack_write(bst, bsh, IM_RX_OVRN_INT, 0);
ifp->if_ierrors++;
}
- /*
- * Receive interrupts.
- */
+ /* Receive interrupts. */
if (status & IM_RCV_INT) {
smc91cxx_read(sc);
}
- /*
- * Memory allocation interrupts.
- */
+ /* Memory allocation interrupts. */
if (status & IM_ALLOC_INT) {
/* Disable this interrupt. */
mask &= ~IM_ALLOC_INT;
sc->sc_intmask &= ~IM_ALLOC_INT;
- /*
- * Save allocated packet number for use in start
- */
+ /* Save allocated packet number for use in start */
packetno = bus_space_read_1(bst, bsh, ALLOC_RESULT_REG_B);
KASSERT(sc->sc_txpacketno & ARR_FAILED);
sc->sc_txpacketno = packetno;
- /*
- * We can transmit again!
- */
+ /* We can transmit again! */
ifp->if_flags &= ~IFF_OACTIVE;
ifp->if_timer = 0;
}
@@ -969,9 +923,7 @@ smc91cxx_intr(void *arg)
packetno = bus_space_read_2(bst, bsh, FIFO_PORTS_REG_W) &
FIFO_TX_MASK;
- /*
- * Select this as the packet to read from.
- */
+ /* Select this as the packet to read from. */
bus_space_write_2(bst, bsh, PACKET_NUM_REG_B, packetno);
/*
@@ -1016,9 +968,7 @@ smc91cxx_intr(void *arg)
TCR_ENABLE | TCR_PAD_ENABLE);
#endif
- /*
- * Kill the failed packet and wait for the MMU to unbusy.
- */
+ /* Kill the failed packet and wait for the MMU to unbusy. */
SMC_SELECT_BANK(sc, 2);
while (bus_space_read_2(bst, bsh, MMU_CMD_REG_W) & MMUCR_BUSY)
/* XXX bound this loop! */ ;
@@ -1052,30 +1002,22 @@ smc91cxx_intr(void *arg)
ifp->if_timer = 0;
}
- /*
- * Internal PHY status change
- */
+ /* Internal PHY status change */
if (sc->sc_chipid == CHIP_91C111 && sc->sc_internal_phy &&
(status & IM_MD_INT)) {
- /*
- * Internal PHY status change
- */
+ /* Internal PHY status change */
smc91cxx_intr_ack_write(bst, bsh, IM_MD_INT, 0);
mii_pollstat(&sc->sc_mii);
}
- /*
- * Other errors. Reset the interface.
- */
+ /* Other errors. Reset the interface. */
if (status & IM_EPH_INT) {
smc91cxx_stop(sc);
smc91cxx_init(sc);
}
- /*
- * Attempt to queue more packets for transmission.
- */
+ /* Attempt to queue more packets for transmission. */
if_schedule_deferred_start(ifp);
/*
@@ -1088,7 +1030,7 @@ smc91cxx_intr(void *arg)
if (status)
rnd_add_uint32(&sc->rnd_source, status);
- return (1);
+ return 1;
}
/*
@@ -1103,9 +1045,9 @@ smc91cxx_read(struct smc91cxx_softc *sc)
bus_space_handle_t bsh = sc->sc_bsh;
struct ether_header *eh;
struct mbuf *m;
- u_int16_t status, packetno, packetlen;
- u_int8_t *data;
- u_int32_t dr;
+ uint16_t status, packetno, packetlen;
+ uint8_t *data;
+ uint32_t dr;
bool first = true;
again:
@@ -1128,12 +1070,10 @@ smc91cxx_read(struct smc91cxx_softc *sc)
PTR_READ | PTR_RCV | PTR_AUTOINC /* | 0x0000 */);
delay(1);
- /*
- * First two words are status and packet length.
- */
+ /* First two words are status and packet length. */
dr = bus_space_read_4(bst, bsh, DATA_REG_W);
- status = (u_int16_t)dr;
- packetlen = (u_int16_t)(dr >> 16);
+ status = (uint16_t)dr;
+ packetlen = (uint16_t)(dr >> 16);
packetlen &= RLEN_MASK;
if (packetlen < ETHER_MIN_LEN - ETHER_CRC_LEN + 6 || packetlen > 1534) {
@@ -1147,23 +1087,17 @@ smc91cxx_read(struct smc91cxx_softc *sc)
*/
packetlen -= 6;
- /*
- * Account for receive errors and discard.
- */
+ /* Account for receive errors and discard. */
if (status & RS_ERRORS) {
ifp->if_ierrors++;
goto out;
}
- /*
- * Adjust for odd-length packet.
- */
+ /* Adjust for odd-length packet. */
if (status & RS_ODDFRAME)
packetlen++;
- /*
- * Allocate a header mbuf.
- */
+ /* Allocate a header mbuf. */
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
goto out;
@@ -1188,32 +1122,32 @@ smc91cxx_read(struct smc91cxx_softc *sc)
* is aligned.
*/
if ((sc->sc_flags & SMC_FLAGS_32BIT_READ) == 0) {
- m->m_data = (char *) ALIGN(mtod(m, char *) +
+ m->m_data = (char *)ALIGN(mtod(m, char *) +
sizeof(struct ether_header)) - sizeof(struct ether_header);
eh = mtod(m, struct ether_header *);
- data = mtod(m, u_int8_t *);
+ data = mtod(m, uint8_t *);
KASSERT(trunc_page((uintptr_t)data) ==
trunc_page((uintptr_t)data + packetlen - 1));
if (packetlen > 1)
bus_space_read_multi_stream_2(bst, bsh, DATA_REG_W,
- (u_int16_t *)data, packetlen >> 1);
+ (uint16_t *)data, packetlen >> 1);
if (packetlen & 1) {
data += packetlen & ~1;
*data = bus_space_read_1(bst, bsh, DATA_REG_B);
}
} else {
- m->m_data = (void *) ALIGN(mtod(m, void *));
+ m->m_data = (void *)ALIGN(mtod(m, void *));
eh = mtod(m, struct ether_header *);
- data = mtod(m, u_int8_t *);
+ data = mtod(m, uint8_t *);
KASSERT(trunc_page((uintptr_t)data) ==
trunc_page((uintptr_t)data + packetlen - 1));
if (packetlen > 3)
bus_space_read_multi_stream_4(bst, bsh, DATA_REG_W,
- (u_int32_t *)data, packetlen >> 2);
+ (uint32_t *)data, packetlen >> 2);
if (packetlen & 3) {
data += packetlen & ~3;
- *((u_int32_t *)data) =
+ *((uint32_t *)data) =
bus_space_read_stream_4(bst, bsh, DATA_REG_W);
}
}
@@ -1225,9 +1159,7 @@ smc91cxx_read(struct smc91cxx_softc *sc)
* (should be ensured by chipset configuration)
*/
if ((ifp->if_flags & IFF_PROMISC) != 0) {
- /*
- * Drop packet looped back from myself.
- */
+ /* Drop packet looped back from myself. */
if (ether_cmp(eh->ether_shost, CLLADDR(ifp->if_sadl)) == 0) {
m_freem(m);
goto out;
@@ -1239,16 +1171,12 @@ smc91cxx_read(struct smc91cxx_softc *sc)
if_percpuq_enqueue(ifp->if_percpuq, m);
out:
- /*
- * Tell the card to free the memory occupied by this packet.
- */
+ /* Tell the card to free the memory occupied by this packet. */
while (bus_space_read_2(bst, bsh, MMU_CMD_REG_W) & MMUCR_BUSY)
/* XXX bound this loop! */ ;
bus_space_write_2(bst, bsh, MMU_CMD_REG_W, MMUCR_RELEASE);
- /*
- * Check for another packet.
- */
+ /* Check for another packet. */
goto again;
}
@@ -1339,7 +1267,7 @@ smc91cxx_ioctl(struct ifnet *ifp, u_long cmd, void *data)
}
splx(s);
- return (error);
+ return error;
}
/*
@@ -1378,22 +1306,16 @@ smc91cxx_stop(struct smc91cxx_softc *sc)
bus_space_tag_t bst = sc->sc_bst;
bus_space_handle_t bsh = sc->sc_bsh;
- /*
- * Clear interrupt mask; disable all interrupts.
- */
+ /* Clear interrupt mask; disable all interrupts. */
SMC_SELECT_BANK(sc, 2);
smc91cxx_intr_mask_write(bst, bsh, 0);
- /*
- * Disable transmitter and receiver.
- */
+ /* Disable transmitter and receiver. */
SMC_SELECT_BANK(sc, 0);
bus_space_write_2(bst, bsh, RECV_CONTROL_REG_W, 0);
bus_space_write_2(bst, bsh, TXMIT_CONTROL_REG_W, 0);
- /*
- * Cancel watchdog timer.
- */
+ /* Cancel watchdog timer. */
sc->sc_ec.ec_if.if_timer = 0;
}
@@ -1407,12 +1329,12 @@ smc91cxx_enable(struct smc91cxx_softc *sc)
if ((sc->sc_flags & SMC_FLAGS_ENABLED) == 0 && sc->sc_enable != NULL) {
if ((*sc->sc_enable)(sc) != 0) {
aprint_error_dev(sc->sc_dev, "device enable failed\n");
- return (EIO);
+ return EIO;
}
}
sc->sc_flags |= SMC_FLAGS_ENABLED;
- return (0);
+ return 0;
}
/*
@@ -1450,7 +1372,7 @@ smc91cxx_detach(device_t self, int flags)
/* Succeed now if there's no work to do. */
if ((sc->sc_flags & SMC_FLAGS_ATTACHED) == 0)
- return (0);
+ return 0;
/* smc91cxx_disable() checks SMC_FLAGS_ENABLED */
smc91cxx_disable(sc);
@@ -1465,20 +1387,20 @@ smc91cxx_detach(device_t self, int flags)
ether_ifdetach(ifp);
if_detach(ifp);
- return (0);
+ return 0;
}
-u_int32_t
+uint32_t
smc91cxx_mii_bitbang_read(device_t self)
{
struct smc91cxx_softc *sc = device_private(self);
/* We're already in bank 3. */
- return (bus_space_read_2(sc->sc_bst, sc->sc_bsh, MGMT_REG_W));
+ return bus_space_read_2(sc->sc_bst, sc->sc_bsh, MGMT_REG_W);
}
void
-smc91cxx_mii_bitbang_write(device_t self, u_int32_t val)
+smc91cxx_mii_bitbang_write(device_t self, uint32_t val)
{
struct smc91cxx_softc *sc = device_private(self);
@@ -1533,7 +1455,7 @@ smc91cxx_statchg(struct ifnet *ifp)
else
mctl &= ~TCR_SWFDUP;
bus_space_write_2(bst, bsh, TXMIT_CONTROL_REG_W, mctl);
- SMC_SELECT_BANK(sc, 2); /* back to operating window */
+ SMC_SELECT_BANK(sc, 2); /* Back to operating window */
}
/*
diff --git a/sys/dev/isa/if_ef.c b/sys/dev/isa/if_ef.c
index 6a72b70aeb1..0ebe63e61eb 100644
--- a/sys/dev/isa/if_ef.c
+++ b/sys/dev/isa/if_ef.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ef.c,v 1.33 2019/04/09 06:00:08 msaitoh Exp $ */
+/* $NetBSD: if_ef.c,v 1.34 2019/04/25 10:08:46 msaitoh Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ef.c,v 1.33 2019/04/09 06:00:08 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ef.c,v 1.34 2019/04/25 10:08:46 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -80,18 +80,18 @@ static int ef_media[] = {
IFM_ETHER | IFM_10_5,
IFM_ETHER | IFM_10_2,
};
-#define NEF_MEDIA (sizeof(ef_media) / sizeof(ef_media[0]))
+#define NEF_MEDIA __arraycount(ef_media)
static int eftp_media[] = {
IFM_ETHER | IFM_10_T,
};
-#define NEFTP_MEDIA (sizeof(eftp_media) / sizeof(eftp_media[0]))
+#define NEFTP_MEDIA __arraycount(eftp_media)
/* Routines required by the MI i82586 driver API */
-static void ef_reset(struct ie_softc *, int);
-static void ef_hwinit(struct ie_softc *);
-static void ef_atten(struct ie_softc *, int);
-static int ef_intrhook(struct ie_softc *, int);
+static void ef_reset(struct ie_softc *, int);
+static void ef_hwinit(struct ie_softc *);
+static void ef_atten(struct ie_softc *, int);
+static int ef_intrhook(struct ie_softc *, int);
static void ef_copyin(struct ie_softc *, void *, int, size_t);
static void ef_copyout(struct ie_softc *, const void *, int, size_t);
@@ -103,7 +103,7 @@ static void ef_write_24(struct ie_softc *, int, int);
static void ef_mediastatus(struct ie_softc *, struct ifmediareq *);
/* Local routines */
-static int ef_port_check(bus_space_tag_t, bus_space_handle_t);
+static int ef_port_check(bus_space_tag_t, bus_space_handle_t);
static int ef_match(device_t, cfdata_t, void *);
static void ef_attach(device_t, device_t, void *);
@@ -117,7 +117,7 @@ static void ef_attach(device_t, device_t, void *);
* which will unique per ISA bus.
*/
-#define MAXCARDS_PER_ISABUS 8 /* If you have more than 8, you lose */
+#define MAXCARDS_PER_ISABUS 8 /* If you have more than 8, you lose */
struct ef_isabus {
LIST_ENTRY(ef_isabus) isa_link;
@@ -312,10 +312,10 @@ ef_write_24(struct ie_softc *sc, int offset, int addr)
static void
ef_mediastatus(struct ie_softc *sc, struct ifmediareq *ifmr)
{
- struct ifmedia *ifm = &sc->sc_media;
+ struct ifmedia *ifm = &sc->sc_media;
- /* The currently selected media is always the active media. */
- ifmr->ifm_active = ifm->ifm_cur->ifm_media;
+ /* The currently selected media is always the active media. */
+ ifmr->ifm_active = ifm->ifm_cur->ifm_media;
}
static int
@@ -645,7 +645,7 @@ static int
ef_port_check(bus_space_tag_t iot, bus_space_handle_t ioh)
{
int i;
- u_char ch;
+ u_char ch;
const u_char *signature = EF_SIGNATURE;
for (i = 0; i < strlen(signature); i++) {
diff --git a/sys/dev/isa/if_ix.c b/sys/dev/isa/if_ix.c
index dde99b1f8dd..88131f0e964 100644
--- a/sys/dev/isa/if_ix.c
+++ b/sys/dev/isa/if_ix.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ix.c,v 1.37 2019/04/09 06:19:34 msaitoh Exp $ */
+/* $NetBSD: if_ix.c,v 1.38 2019/04/25 10:08:46 msaitoh Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ix.c,v 1.37 2019/04/09 06:19:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ix.c,v 1.38 2019/04/25 10:08:46 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -68,7 +68,7 @@ static int ix_media[] = {
IFM_ETHER | IFM_10_2,
IFM_ETHER | IFM_10_T,
};
-#define NIX_MEDIA (sizeof(ix_media) / sizeof(ix_media[0]))
+#define NIX_MEDIA __arraycount(ix_media)
struct ix_softc {
struct ie_softc sc_ie;
@@ -81,12 +81,12 @@ struct ix_softc {
void *sc_ih; /* interrupt handle */
};
-static void ix_reset(struct ie_softc *, int);
-static void ix_atten(struct ie_softc *, int);
-static int ix_intrhook(struct ie_softc *, int);
+static void ix_reset(struct ie_softc *, int);
+static void ix_atten(struct ie_softc *, int);
+static int ix_intrhook(struct ie_softc *, int);
-static void ix_copyin(struct ie_softc *, void *, int, size_t);
-static void ix_copyout(struct ie_softc *, const void *, int, size_t);
+static void ix_copyin(struct ie_softc *, void *, int, size_t);
+static void ix_copyout(struct ie_softc *, const void *, int, size_t);
static void ix_bus_barrier(struct ie_softc *, int, int, int);
@@ -220,15 +220,15 @@ ix_intrhook(struct ie_softc *sc, int where)
switch (where) {
case INTR_ENTER:
- /* entering ISR: disable card interrupts */
+ /* Entering ISR: disable card interrupts */
bus_space_write_1(isc->sc_regt, isc->sc_regh,
IX_IRQ, isc->irq_encoded);
break;
case INTR_EXIT:
- /* exiting ISR: re-enable card interrupts */
+ /* Exiting ISR: re-enable card interrupts */
bus_space_write_1(isc->sc_regt, isc->sc_regh, IX_IRQ,
- isc->irq_encoded | IX_IRQ_ENABLE);
+ isc->irq_encoded | IX_IRQ_ENABLE);
break;
}
@@ -267,7 +267,7 @@ ix_copyin(struct ie_softc *sc, void *dst, int offset, size_t size)
wptr = (uint16_t*)bptr;
if (isc->use_pio) {
- for (i = 0; i < size / 2; i++) {
+ for (i = 0; i < size / 2; i++) {
*wptr = bus_space_read_2(sc->bt, sc->bh, IX_DATAPORT);
wptr++;
}
@@ -416,7 +416,7 @@ ix_write_24 (struct ie_softc *sc, int offset, int addr)
bus_space_barrier(sc->bt, sc->bh, IX_DATAPORT, 2,
BUS_SPACE_BARRIER_WRITE);
} else {
- bus_space_write_4(sc->bt, sc->bh, offset, val);
+ bus_space_write_4(sc->bt, sc->bh, offset, val);
bus_space_barrier(sc->bt, sc->bh, offset, 4,
BUS_SPACE_BARRIER_WRITE);
}
@@ -440,7 +440,7 @@ ix_zeromem(struct ie_softc *sc, int offset, int count)
count--;
}
- dribble = count % 2;
+ dribble = count % 2;
for (i = 0; i < count / 2; i++)
bus_space_write_2(sc->bt, sc->bh, IX_DATAPORT, 0);
@@ -459,10 +459,10 @@ ix_zeromem(struct ie_softc *sc, int offset, int count)
static void
ix_mediastatus(struct ie_softc *sc, struct ifmediareq *ifmr)
{
- struct ifmedia *ifm = &sc->sc_media;
+ struct ifmedia *ifm = &sc->sc_media;
- /* The currently selected media is always the active media. */
- ifmr->ifm_active = ifm->ifm_cur->ifm_media;
+ /* The currently selected media is always the active media. */
+ ifmr->ifm_active = ifm->ifm_cur->ifm_media;
}
int
diff --git a/sys/dev/pci/if_le_pci.c b/sys/dev/pci/if_le_pci.c
index 483cefd6028..e627cc576d6 100644
--- a/sys/dev/pci/if_le_pci.c
+++ b/sys/dev/pci/if_le_pci.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le_pci.c,v 1.53 2018/12/09 11:14:02 jdolecek Exp $ */
+/* $NetBSD: if_le_pci.c,v 1.54 2019/04/25 10:08:46 msaitoh Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_pci.c,v 1.53 2018/12/09 11:14:02 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_pci.c,v 1.54 2019/04/25 10:08:46 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -109,12 +109,12 @@ CFATTACH_DECL_NEW(le_pci, sizeof(struct le_softc),
#define LE_PCI_MEMSIZE 16384
static int le_pci_supmedia[] = {
- IFM_ETHER|IFM_AUTO,
- IFM_ETHER|IFM_AUTO|IFM_FDX,
- IFM_ETHER|IFM_10_T,
- IFM_ETHER|IFM_10_T|IFM_FDX,
- IFM_ETHER|IFM_10_5,
- IFM_ETHER|IFM_10_5|IFM_FDX,
+ IFM_ETHER | IFM_AUTO,
+ IFM_ETHER | IFM_AUTO | IFM_FDX,
+ IFM_ETHER | IFM_10_T,
+ IFM_ETHER | IFM_10_T | IFM_FDX,
+ IFM_ETHER | IFM_10_5,
+ IFM_ETHER | IFM_10_5 | IFM_FDX,
};
static void
@@ -138,7 +138,7 @@ le_pci_rdcsr(struct lance_softc *sc, uint16_t port)
bus_space_write_2(iot, ioh, lesc->sc_rap, port);
val = bus_space_read_2(iot, ioh, lesc->sc_rdp);
- return (val);
+ return val;
}
static int
@@ -153,14 +153,14 @@ le_pci_mediachange(struct lance_softc *sc)
if (IFM_SUBTYPE(newmedia) !=
IFM_SUBTYPE(lesc->sc_currentmedia)) {
if (IFM_SUBTYPE(newmedia) == IFM_AUTO) {
- /* switch to autoselect - BCR2 bit 1 */
+ /* Switch to autoselect - BCR2 bit 1 */
bus_space_write_2(iot, ioh, PCNET_PCI_RAP, 2);
reg = bus_space_read_2(iot, ioh, PCNET_PCI_BDP);
reg |= 2;
bus_space_write_2(iot, ioh, PCNET_PCI_RAP, 2);
bus_space_write_2(iot, ioh, PCNET_PCI_BDP, reg);
} else {
- /* force media type (in init block) */
+ /* Force media type (in init block) */
lance_reset(sc);
if (IFM_SUBTYPE(newmedia) == IFM_10_T)
sc->sc_initmodemedia = 1; /* UTP */
@@ -169,7 +169,7 @@ le_pci_mediachange(struct lance_softc *sc)
lance_init(&sc->sc_ethercom.ec_if);
if (IFM_SUBTYPE(lesc->sc_currentmedia) == IFM_AUTO) {
- /* take away autoselect - BCR2 bit 1 */
+ /* Take away autoselect - BCR2 bit 1 */
bus_space_write_2(iot, ioh, PCNET_PCI_RAP, 2);
reg = bus_space_read_2(iot, ioh, PCNET_PCI_BDP);
reg &= ~2;
@@ -182,13 +182,15 @@ le_pci_mediachange(struct lance_softc *sc)
if ((IFM_OPTIONS(newmedia) ^ IFM_OPTIONS(lesc->sc_currentmedia))
& IFM_FDX) {
- /* toggle full duplex - BCR9 */
+ /* Toggle full duplex - BCR9 */
bus_space_write_2(iot, ioh, PCNET_PCI_RAP, 9);
reg = bus_space_read_2(iot, ioh, PCNET_PCI_BDP);
if (IFM_OPTIONS(newmedia) & IFM_FDX) {
reg |= 1; /* FDEN */
- /* allow FDX on AUI only if explicitly chosen,
- not in autoselect mode */
+ /*
+ * Allow FDX on AUI only if explicitly chosen, not in
+ * autoselect mode
+ */
if (IFM_SUBTYPE(newmedia) == IFM_10_5)
reg |= 2; /* AUIFD */
else
@@ -200,7 +202,7 @@ le_pci_mediachange(struct lance_softc *sc)
}
lesc->sc_currentmedia = newmedia;
- return (0);
+ return 0;
}
static int
@@ -209,14 +211,14 @@ le_pci_match(device_t parent, cfdata_t cf, void *aux)
struct pci_attach_args *pa = aux;
if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_AMD)
- return (0);
+ return 0;
switch (PCI_PRODUCT(pa->pa_id)) {
case PCI_PRODUCT_AMD_PCNET_PCI:
- return (1);
+ return 1;
}
- return (0);
+ return 0;
}
static void
@@ -257,9 +259,7 @@ le_pci_attach(device_t parent, device_t self, void *aux)
return;
}
- /*
- * Extract the physical MAC address from the ROM.
- */
+ /* Extract the physical MAC address from the ROM. */
for (i = 0; i < sizeof(sc->sc_enaddr); i++)
sc->sc_enaddr[i] = bus_space_read_1(iot, ioh, i);
@@ -267,9 +267,7 @@ le_pci_attach(device_t parent, device_t self, void *aux)
lesc->sc_ioh = ioh;
lesc->sc_dmat = dmat;
- /*
- * Allocate a DMA area for the card.
- */
+ /* Allocate a DMA area for the card. */
if (bus_dmamem_alloc(dmat, LE_PCI_MEMSIZE, PAGE_SIZE, 0, &seg, 1,
&rseg, BUS_DMA_NOWAIT)) {
aprint_error_dev(self, "couldn't allocate memory for card\n");
@@ -282,9 +280,7 @@ le_pci_attach(device_t parent, device_t self, void *aux)
return;
}
- /*
- * Create and load the DMA map for the DMA area.
- */
+ /* Create and load the DMA map for the DMA area. */
if (bus_dmamap_create(dmat, LE_PCI_MEMSIZE, 1,
LE_PCI_MEMSIZE, 0, BUS_DMA_NOWAIT, &lesc->sc_dmam)) {
aprint_error_dev(self, "couldn't create DMA map\n");
@@ -313,7 +309,7 @@ le_pci_attach(device_t parent, device_t self, void *aux)
sc->sc_hwinit = NULL;
sc->sc_supmedia = le_pci_supmedia;
- sc->sc_nsupmedia = sizeof(le_pci_supmedia) / sizeof(int);
+ sc->sc_nsupmedia = __arraycount(le_pci_supmedia);
sc->sc_defaultmedia = le_pci_supmedia[0];
sc->sc_mediachange = le_pci_mediachange;
lesc->sc_currentmedia = le_pci_supmedia[0];
diff --git a/sys/dev/vme/if_ie_vme.c b/sys/dev/vme/if_ie_vme.c
index fa191f2332b..67543c79263 100644
--- a/sys/dev/vme/if_ie_vme.c
+++ b/sys/dev/vme/if_ie_vme.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ie_vme.c,v 1.31 2014/08/18 04:26:38 riastradh Exp $ */
+/* $NetBSD: if_ie_vme.c,v 1.32 2019/04/25 10:08:46 msaitoh Exp $ */
/*
* Copyright (c) 1995 Charles D. Cranor
@@ -140,7 +140,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ie_vme.c,v 1.31 2014/08/18 04:26:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ie_vme.c,v 1.32 2019/04/25 10:08:46 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -184,12 +184,12 @@ __KERNEL_RCSID(0, "$NetBSD: if_ie_vme.c,v 1.31 2014/08/18 04:26:38 riastradh Exp
#define IEVME_PGMASK 0x0fff /* gives the physical page frame number */
struct ievme {
- u_int16_t pgmap[IEVME_MAPSZ];
- u_int16_t xxx[32]; /* prom */
- u_int16_t status; /* see below for bits */
- u_int16_t xxx2; /* filler */
- u_int16_t pectrl; /* parity control (see below) */
- u_int16_t peaddr; /* low 16 bits of address */
+ uint16_t pgmap[IEVME_MAPSZ];
+ uint16_t xxx[32]; /* prom */
+ uint16_t status; /* see below for bits */
+ uint16_t xxx2; /* filler */
+ uint16_t pectrl; /* parity control (see below) */
+ uint16_t peaddr; /* low 16 bits of address */
};
/*
@@ -218,7 +218,7 @@ struct ievme {
static int media[] = {
IFM_ETHER | IFM_10_2,
};
-#define NMEDIA (sizeof(media) / sizeof(media[0]))
+#define NMEDIA __arraycount(media)
/*
* the 3E board not supported (yet?)
@@ -254,6 +254,7 @@ void
ie_vmereset(struct ie_softc *sc, int what)
{
struct ie_vme_softc *vsc = (struct ie_vme_softc *)sc;
+
write_iev(vsc, status, IEVME_RESET);
delay(100); /* XXX could be shorter? */
write_iev(vsc, status, 0);
@@ -264,9 +265,9 @@ ie_vmeattend(struct ie_softc *sc, int why)
{
struct ie_vme_softc *vsc = (struct ie_vme_softc *)sc;
- /* flag! */
+ /* Flag! */
write_iev(vsc, status, read_iev(vsc, status) | IEVME_ATTEN);
- /* down. */
+ /* Down. */
write_iev(vsc, status, read_iev(vsc, status) & ~IEVME_ATTEN);
}
@@ -285,19 +286,20 @@ ie_vmeintr(struct ie_softc *sc, int where)
struct ie_vme_softc *vsc = (struct ie_vme_softc *)sc;
if (where != INTR_ENTER)
- return (0);
+ return 0;
- /*
- * check for parity error
- */
+ /*
+ * check for parity error
+ */
if (read_iev(vsc, status) & IEVME_PERR) {
- aprint_error_dev(sc->sc_dev, "parity error (ctrl 0x%x @ 0x%02x%04x)\n",
- read_iev(vsc, pectrl),
- read_iev(vsc, pectrl) & IEVME_HADDR,
- read_iev(vsc, peaddr));
+ aprint_error_dev(sc->sc_dev,
+ "parity error (ctrl 0x%x @ 0x%02x%04x)\n",
+ read_iev(vsc, pectrl),
+ read_iev(vsc, pectrl) & IEVME_HADDR,
+ read_iev(vsc, peaddr));
write_iev(vsc, pectrl, read_iev(vsc, pectrl) | IEVME_PARACK);
}
- return (0);
+ return 0;
}
void ie_memcopyin(struct ie_softc *, void *, int, size_t);
@@ -312,9 +314,9 @@ ie_memcopyin(struct ie_softc *sc, void *p, int offset, size_t size)
size_t help;
if ((offset & 1) && ((u_long)p & 1) && size > 0) {
- *(u_int8_t *)p = bus_space_read_1(sc->bt, sc->bh, offset);
+ *(uint8_t *)p = bus_space_read_1(sc->bt, sc->bh, offset);
offset++;
- p = (u_int8_t *)p + 1;
+ p = (uint8_t *)p + 1;
size--;
}
@@ -329,8 +331,8 @@ ie_memcopyin(struct ie_softc *sc, void *p, int offset, size_t size)
return;
offset += 2 * help;
- p = (u_int16_t *)p + help;
- *(u_int8_t *)p = bus_space_read_1(sc->bt, sc->bh, offset);
+ p = (uint16_t *)p + help;
+ *(uint8_t *)p = bus_space_read_1(sc->bt, sc->bh, offset);
}
/*
@@ -342,9 +344,9 @@ ie_memcopyout(struct ie_softc *sc, const void *p, int offset, size_t size)
size_t help;
if ((offset & 1) && ((u_long)p & 1) && size > 0) {
- bus_space_write_1(sc->bt, sc->bh, offset, *(const u_int8_t *)p);
+ bus_space_write_1(sc->bt, sc->bh, offset, *(const uint8_t *)p);
offset++;
- p = (const u_int8_t *)p + 1;
+ p = (const uint8_t *)p + 1;
size--;
}
@@ -359,20 +361,20 @@ ie_memcopyout(struct ie_softc *sc, const void *p, int offset, size_t size)
return;
offset += 2 * help;
- p = (const u_int16_t *)p + help;
- bus_space_write_1(sc->bt, sc->bh, offset, *(const u_int8_t *)p);
+ p = (const uint16_t *)p + help;
+ bus_space_write_1(sc->bt, sc->bh, offset, *(const uint8_t *)p);
}
/* read a 16-bit value at BH offset */
-u_int16_t ie_vme_read16(struct ie_softc *, int offset);
+uint16_t ie_vme_read16(struct ie_softc *, int offset);
/* write a 16-bit value at BH offset */
-void ie_vme_write16(struct ie_softc *, int offset, u_int16_t value);
+void ie_vme_write16(struct ie_softc *, int offset, uint16_t value);
void ie_vme_write24(struct ie_softc *, int offset, int addr);
-u_int16_t
+uint16_t
ie_vme_read16(struct ie_softc *sc, int offset)
{
- u_int16_t v;
+ uint16_t v;
bus_space_barrier(sc->bt, sc->bh, offset, 2, BUS_SPACE_BARRIER_READ);
v = bus_space_read_2(sc->bt, sc->bh, offset);
@@ -380,7 +382,7 @@ ie_vme_read16(struct ie_softc *sc, int offset)
}
void
-ie_vme_write16(struct ie_softc *sc, int offset, u_int16_t v)
+ie_vme_write16(struct ie_softc *sc, int offset, uint16_t v)
{
int v0 = ((((v)&0xff)<<8) | (((v)>>8)&0xff));
bus_space_write_2(sc->bt, sc->bh, offset, v0);
@@ -391,7 +393,7 @@ void
ie_vme_write24(struct ie_softc *sc, int offset, int addr)
{
u_char *f = (u_char *)&addr;
- u_int16_t v0, v1;
+ uint16_t v0, v1;
u_char *t;
t = (u_char *)&v0;
@@ -415,38 +417,37 @@ ie_vme_match(device_t parent, cfdata_t cf, void *aux)
if (va->numcfranges < 2) {
printf("ie_vme_match: need 2 ranges\n");
- return (0);
+ return 0;
}
if ((va->r[1].offset & 0xff0fffff) ||
((va->r[0].offset & 0xfff00000)
!= (va->r[1].offset & 0xfff00000))) {
printf("ie_vme_match: base address mismatch\n");
- return (0);
+ return 0;
}
if (va->r[0].size != VMECF_LEN_DEFAULT &&
va->r[0].size != sizeof(struct ievme)) {
printf("ie_vme_match: bad csr size\n");
- return (0);
+ return 0;
}
if (va->r[1].size == VMECF_LEN_DEFAULT) {
printf("ie_vme_match: must specify memory size\n");
- return (0);
+ return 0;
}
mod = 0x3d; /* VME_AM_A24|VME_AM_MBO|VME_AM_SUPER|VME_AM_DATA */
if (va->r[0].am != VMECF_AM_DEFAULT &&
va->r[0].am != mod)
- return (0);
+ return 0;
if (vme_space_alloc(va->va_vct, va->r[0].offset,
sizeof(struct ievme), mod))
- return (0);
- if (vme_space_alloc(va->va_vct, va->r[1].offset,
- va->r[1].size, mod)) {
+ return 0;
+ if (vme_space_alloc(va->va_vct, va->r[1].offset, va->r[1].size, mod)) {
vme_space_free(va->va_vct, va->r[0].offset,
sizeof(struct ievme), mod);
- return (0);
+ return 0;
}
error = vme_probe(ct, va->r[0].offset, 2, mod, VME_D16, 0, 0);
vme_space_free(va->va_vct, va->r[0].offset, sizeof(struct ievme), mod);
@@ -458,7 +459,7 @@ ie_vme_match(device_t parent, cfdata_t cf, void *aux)
void
ie_vme_attach(device_t parent, device_t self, void *aux)
{
- u_int8_t myaddr[ETHER_ADDR_LEN];
+ uint8_t myaddr[ETHER_ADDR_LEN];
struct ie_vme_softc *vsc = device_private(self);
struct vme_attach_args *va = aux;
vme_chipset_tag_t ct = va->va_vct;
@@ -472,9 +473,8 @@ ie_vme_attach(device_t parent, device_t self, void *aux)
vme_am_t mod;
/*
- * *note*: we don't detect the difference between a VME3E and
- * a multibus/vme card. if you want to use a 3E you'll have
- * to fix this.
+ * *note*: We don't detect the difference between a VME3E and a
+ * multibus/vme card. If you want to use a 3E you'll have to fix this.
*/
mod = 0x3d; /* VME_AM_A24|VME_AM_MBO|VME_AM_SUPER|VME_AM_DATA */
if (vme_space_alloc(va->va_vct, va->r[0].offset,
@@ -501,8 +501,7 @@ ie_vme_attach(device_t parent, device_t self, void *aux)
memsize = va->r[1].size;
if (vme_space_map(ct, va->r[0].offset, sizeof(struct ievme), mod,
- VME_D16 | VME_D8, 0,
- &vsc->ievt, &vsc->ievh, &resc) != 0)
+ VME_D16 | VME_D8, 0, &vsc->ievt, &vsc->ievh, &resc) != 0)
panic("if_ie: vme map csr");
rampaddr = va->r[1].offset;
@@ -550,9 +549,7 @@ ie_vme_attach(device_t parent, device_t self, void *aux)
return;
}
- /*
- * Rest of first page is unused; rest of ram for buffers.
- */
+ /* Rest of first page is unused; rest of ram for buffers. */
sc->buf_area = IEVME_PAGESIZE;
sc->buf_area_sz = memsize - IEVME_PAGESIZE;