diff options
| author | msaitoh <msaitoh@NetBSD.org> | 2019-04-25 10:08:45 +0000 |
|---|---|---|
| committer | msaitoh <msaitoh@NetBSD.org> | 2019-04-25 10:08:45 +0000 |
| commit | ea20c19bec2534495931321f7846abd1ca0146a2 (patch) | |
| tree | a4625f8a1ec247d82c7d1b64bb177785acb12ddf /sys/dev | |
| parent | c518611761c3db696659d546fcbad5d18967fe52 (diff) | |
No functional change:
- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ic/cs89x0.c | 516 | ||||
| -rw-r--r-- | sys/dev/ic/rtl80x9.c | 33 | ||||
| -rw-r--r-- | sys/dev/ic/smc91cxx.c | 286 | ||||
| -rw-r--r-- | sys/dev/isa/if_ef.c | 28 | ||||
| -rw-r--r-- | sys/dev/isa/if_ix.c | 34 | ||||
| -rw-r--r-- | sys/dev/pci/if_le_pci.c | 54 | ||||
| -rw-r--r-- | sys/dev/vme/if_ie_vme.c | 101 |
7 files changed, 472 insertions, 580 deletions
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; |
