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/sparc/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/sparc/dev')
| -rw-r--r-- | sys/arch/sparc/dev/if_ie_obio.c | 48 | ||||
| -rw-r--r-- | sys/arch/sparc/dev/if_le_obio.c | 33 |
2 files changed, 34 insertions, 47 deletions
diff --git a/sys/arch/sparc/dev/if_ie_obio.c b/sys/arch/sparc/dev/if_ie_obio.c index 6c9299225b6..b31bda332be 100644 --- a/sys/arch/sparc/dev/if_ie_obio.c +++ b/sys/arch/sparc/dev/if_ie_obio.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ie_obio.c,v 1.41 2013/10/19 19:40:23 mrg Exp $ */ +/* $NetBSD: if_ie_obio.c,v 1.42 2019/04/25 10:08:45 msaitoh Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.41 2013/10/19 19:40:23 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.42 2019/04/25 10:08:45 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -130,7 +130,7 @@ CFATTACH_DECL_NEW(ie_obio, sizeof(struct ie_softc), static int media[] = { IFM_ETHER | IFM_10_2, }; -#define NMEDIA (sizeof(media) / sizeof(media[0])) +#define NMEDIA __arraycount(media) /* @@ -188,9 +188,9 @@ ie_obio_memcopyout(struct ie_softc *sc, const void *p, int offset, size_t size) wcopy(p, addr, size); } -/* read a 16-bit value at BH offset */ +/* Read a 16-bit value at BH offset */ uint16_t ie_obio_read16(struct ie_softc *, int); -/* write a 16-bit value at BH offset */ +/* Write a 16-bit value at BH offset */ void ie_obio_write16(struct ie_softc *, int, uint16_t); void ie_obio_write24(struct ie_softc *, int, int); @@ -205,6 +205,7 @@ ie_obio_read16(struct ie_softc *sc, int offset) void ie_obio_write16(struct ie_softc *sc, int offset, uint16_t v) { + v = (((v&0xff)<<8) | ((v>>8)&0xff)); bus_space_write_2(sc->bt, sc->bh, offset, v); } @@ -232,14 +233,14 @@ ie_obio_match(device_t parent, cfdata_t cf, void *aux) struct obio4_attach_args *oba; if (uoba->uoba_isobio4 == 0) - return (0); + return 0; oba = &uoba->uoba_oba4; - return (bus_space_probe(oba->oba_bustag, oba->oba_paddr, + return bus_space_probe(oba->oba_bustag, oba->oba_paddr, 1, /* probe size */ 0, /* offset */ 0, /* flags */ - NULL, NULL)); + NULL, NULL); } void @@ -274,27 +275,21 @@ ie_obio_attach(device_t parent, device_t self, void *aux) sc->sc_msize = memsize = 65536; /* XXX */ if (bus_space_map(oba->oba_bustag, oba->oba_paddr, - sizeof(struct ieob), - BUS_SPACE_MAP_LINEAR, - &bh) != 0) { + sizeof(struct ieob), BUS_SPACE_MAP_LINEAR, &bh) != 0) { printf("%s: cannot map registers\n", device_xname(self)); return; } sc->sc_reg = (void *)bh; - /* - * Allocate control & buffer memory. - */ + /* Allocate control & buffer memory. */ if ((error = bus_dmamap_create(dmatag, memsize, 1, memsize, 0, - BUS_DMA_NOWAIT|BUS_DMA_24BIT, - &sc->sc_dmamap)) != 0) { + BUS_DMA_NOWAIT|BUS_DMA_24BIT, &sc->sc_dmamap)) != 0) { printf("%s: DMA map create error %d\n", device_xname(self), error); return; } - if ((error = bus_dmamem_alloc(dmatag, memsize, 64*1024, 0, - &seg, 1, &rseg, - BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) { + if ((error = bus_dmamem_alloc(dmatag, memsize, 64*1024, 0, &seg, 1, + &rseg, BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) { printf("%s: DMA memory allocation error %d\n", device_xname(self), error); return; @@ -302,8 +297,7 @@ ie_obio_attach(device_t parent, device_t self, void *aux) /* Map DMA buffer in CPU addressable space */ if ((error = bus_dmamem_map(dmatag, &seg, rseg, memsize, - (void **)&sc->sc_maddr, - BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) { + (void **)&sc->sc_maddr, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) { printf("%s: DMA buffer map error %d\n", device_xname(self), error); bus_dmamem_free(dmatag, &seg, rseg); @@ -311,9 +305,8 @@ ie_obio_attach(device_t parent, device_t self, void *aux) } /* Load the segment */ - if ((error = bus_dmamap_load(dmatag, sc->sc_dmamap, - sc->sc_maddr, memsize, NULL, - BUS_DMA_NOWAIT)) != 0) { + if ((error = bus_dmamap_load(dmatag, sc->sc_dmamap, sc->sc_maddr, + memsize, NULL, BUS_DMA_NOWAIT)) != 0) { printf("%s: DMA buffer map load error %d\n", device_xname(self), error); bus_dmamem_unmap(dmatag, sc->sc_maddr, memsize); @@ -337,7 +330,7 @@ ie_obio_attach(device_t parent, device_t self, void *aux) * SCP; the actual buffers start at maddr+PAGE_SIZE. * * In a picture: - + |---//--- ISCP-SCB-----scp-|--//- buffers -//-|... |iscp-scb-----SCP-| | | | | | | | | |<---PAGE_SIZE-->| | |<--PAGE_SIZE-+-->| @@ -391,7 +384,6 @@ ie_obio_attach(device_t parent, device_t self, void *aux) i82586_attach(sc, "onboard", myaddr, media, NMEDIA, media[0]); /* Establish interrupt channel */ - (void)bus_intr_establish(oba->oba_bustag, - oba->oba_pri, IPL_NET, - i82586_intr, sc); + (void)bus_intr_establish(oba->oba_bustag, oba->oba_pri, IPL_NET, + i82586_intr, sc); } diff --git a/sys/arch/sparc/dev/if_le_obio.c b/sys/arch/sparc/dev/if_le_obio.c index 7b64ad9fbc7..4ea42377c5f 100644 --- a/sys/arch/sparc/dev/if_le_obio.c +++ b/sys/arch/sparc/dev/if_le_obio.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_le_obio.c,v 1.27 2011/07/01 18:50:41 dyoung Exp $ */ +/* $NetBSD: if_le_obio.c,v 1.28 2019/04/25 10:08:45 msaitoh Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_le_obio.c,v 1.27 2011/07/01 18:50:41 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_le_obio.c,v 1.28 2019/04/25 10:08:45 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -72,9 +72,9 @@ struct le_softc { * Media types supported. */ static int lemedia[] = { - IFM_ETHER|IFM_10_T, + IFM_ETHER | IFM_10_T, }; -#define NLEMEDIA (sizeof(lemedia) / sizeof(lemedia[0])) +#define NLEMEDIA __arraycount(lemedia) static int lematch_obio(device_t, cfdata_t, void *); static void leattach_obio(device_t, device_t, void *); @@ -105,7 +105,7 @@ lerdcsr(struct lance_softc *sc, uint16_t port) bus_space_handle_t h = lesc->sc_reg; bus_space_write_2(t, h, LEREG1_RAP, port); - return (bus_space_read_2(t, h, LEREG1_RDP)); + return bus_space_read_2(t, h, LEREG1_RDP); } static int @@ -115,14 +115,14 @@ lematch_obio(device_t parent, cfdata_t cf, void *aux) struct obio4_attach_args *oba; if (uoba->uoba_isobio4 == 0) - return (0); + return 0; oba = &uoba->uoba_oba4; - return (bus_space_probe(oba->oba_bustag, oba->oba_paddr, + return bus_space_probe(oba->oba_bustag, oba->oba_paddr, 2, /* probe size */ 0, /* offset */ 0, /* flags */ - NULL, NULL)); + NULL, NULL); } static void @@ -142,39 +142,34 @@ leattach_obio(device_t parent, device_t self, void *aux) lesc->sc_dmatag = dmatag = oba->oba_dmatag; if (bus_space_map(oba->oba_bustag, oba->oba_paddr, - 2 * sizeof(uint16_t), - 0, &lesc->sc_reg) != 0) { + 2 * sizeof(uint16_t), 0, &lesc->sc_reg) != 0) { aprint_error(": cannot map registers\n"); return; } /* Get a DMA handle */ if ((error = bus_dmamap_create(dmatag, MEMSIZE, 1, MEMSIZE, 0, - BUS_DMA_NOWAIT|BUS_DMA_24BIT, - &lesc->sc_dmamap)) != 0) { + BUS_DMA_NOWAIT|BUS_DMA_24BIT, &lesc->sc_dmamap)) != 0) { aprint_error(": DMA map create error %d\n", error); return; } /* Allocate DMA buffer */ if ((error = bus_dmamem_alloc(dmatag, MEMSIZE, PAGE_SIZE, 0, - &seg, 1, &rseg, - BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) { + &seg, 1, &rseg, BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) { aprint_error(": DMA memory allocation error %d\n", error); return; } /* Map DMA buffer into kernel space */ if ((error = bus_dmamem_map(dmatag, &seg, rseg, MEMSIZE, - (void **)&sc->sc_mem, - BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) { + (void **)&sc->sc_mem, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) { aprint_error(": DMA memory map error %d\n", error); bus_dmamem_free(lesc->sc_dmatag, &seg, rseg); return; } /* Load DMA buffer */ if ((error = bus_dmamap_load(dmatag, lesc->sc_dmamap, - sc->sc_mem, MEMSIZE, NULL, - BUS_DMA_NOWAIT)) != 0) { + sc->sc_mem, MEMSIZE, NULL, BUS_DMA_NOWAIT)) != 0) { aprint_error(": DMA buffer map load error %d\n", error); bus_dmamem_unmap(dmatag, (void *)sc->sc_mem, MEMSIZE); bus_dmamem_free(dmatag, &seg, rseg); @@ -204,5 +199,5 @@ leattach_obio(device_t parent, device_t self, void *aux) /* Install interrupt */ (void)bus_intr_establish(lesc->sc_bustag, oba->oba_pri, IPL_NET, - am7990_intr, sc); + am7990_intr, sc); } |
