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/arch/sun2/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/arch/sun2/dev')
| -rw-r--r-- | sys/arch/sun2/dev/if_ie_mbmem.c | 82 | ||||
| -rw-r--r-- | sys/arch/sun2/dev/if_ie_obio.c | 62 |
2 files changed, 72 insertions, 72 deletions
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); |
