diff options
author | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2010-12-17 22:38:55 +0000 |
---|---|---|
committer | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2010-12-17 22:38:55 +0000 |
commit | 102afdd6a7b6d3f5088a346d1c2d0d0270cbbced (patch) | |
tree | 630b0c5639bd5a4c078409cbe764a9fc1da488c6 /sys/dev | |
parent | f90a2c56da97da2907278a6797235ca0f13bdfd5 (diff) |
- use nitems()
ok jakemsr@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/if_atu.c | 10 | ||||
-rw-r--r-- | sys/dev/usb/if_ral.c | 10 | ||||
-rw-r--r-- | sys/dev/usb/if_rum.c | 10 | ||||
-rw-r--r-- | sys/dev/usb/uchcom.c | 5 | ||||
-rw-r--r-- | sys/dev/usb/usb_subr.c | 4 |
5 files changed, 15 insertions, 24 deletions
diff --git a/sys/dev/usb/if_atu.c b/sys/dev/usb/if_atu.c index eabe9665798..7aeae194dba 100644 --- a/sys/dev/usb/if_atu.c +++ b/sys/dev/usb/if_atu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_atu.c,v 1.97 2010/12/06 04:41:39 jakemsr Exp $ */ +/* $OpenBSD: if_atu.c,v 1.98 2010/12/17 22:38:54 jasper Exp $ */ /* * Copyright (c) 2003, 2004 * Daan Vreeken <Danovitsch@Vitsch.net>. All rights reserved. @@ -892,7 +892,7 @@ atu_internal_firmware(void *arg) */ /* Choose the right firmware for the device */ - for (i = 0; i < sizeof(atu_radfirm)/sizeof(atu_radfirm[0]); i++) + for (i = 0; i < nitems(atu_radfirm); i++) if (sc->atu_radio == atu_radfirm[i].atur_type) name = atu_radfirm[i].atur_internal; @@ -1003,7 +1003,7 @@ atu_external_firmware(void *arg) size_t bytes_left = 0; char *name = "unknown-device"; - for (i = 0; i < sizeof(atu_radfirm)/sizeof(atu_radfirm[0]); i++) + for (i = 0; i < nitems(atu_radfirm); i++) if (sc->atu_radio == atu_radfirm[i].atur_type) name = atu_radfirm[i].atur_external; @@ -1117,7 +1117,7 @@ atu_match(struct device *parent, void *match, void *aux) if (!uaa->iface) return(UMATCH_NONE); - for (i = 0; i < sizeof(atu_devs)/sizeof(atu_devs[0]); i++) { + for (i = 0; i < nitems(atu_devs); i++) { struct atu_type *t = &atu_devs[i]; if (uaa->vendor == t->atu_vid && @@ -1283,7 +1283,7 @@ atu_attach(struct device *parent, struct device *self, void *aux) * look up the radio_type for the device * basically does the same as USB_MATCH */ - for (i = 0; i < sizeof(atu_devs)/sizeof(atu_devs[0]); i++) { + for (i = 0; i < nitems(atu_devs); i++) { struct atu_type *t = &atu_devs[i]; if (uaa->vendor == t->atu_vid && diff --git a/sys/dev/usb/if_ral.c b/sys/dev/usb/if_ral.c index 0e8f825f9eb..00af1ed3df1 100644 --- a/sys/dev/usb/if_ral.c +++ b/sys/dev/usb/if_ral.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ral.c,v 1.117 2010/12/06 04:41:39 jakemsr Exp $ */ +/* $OpenBSD: if_ral.c,v 1.118 2010/12/17 22:38:54 jasper Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -1852,7 +1852,6 @@ ural_read_eeprom(struct ural_softc *sc) int ural_bbp_init(struct ural_softc *sc) { -#define N(a) (sizeof (a) / sizeof ((a)[0])) int i, ntries; /* wait for BBP to be ready */ @@ -1867,7 +1866,7 @@ ural_bbp_init(struct ural_softc *sc) } /* initialize BBP registers to default values */ - for (i = 0; i < N(ural_def_bbp); i++) + for (i = 0; i < nitems(ural_def_bbp); i++) ural_bbp_write(sc, ural_def_bbp[i].reg, ural_def_bbp[i].val); #if 0 @@ -1880,7 +1879,6 @@ ural_bbp_init(struct ural_softc *sc) #endif return 0; -#undef N } void @@ -1935,7 +1933,6 @@ ural_set_rxantenna(struct ural_softc *sc, int antenna) int ural_init(struct ifnet *ifp) { -#define N(a) (sizeof (a) / sizeof ((a)[0])) struct ural_softc *sc = ifp->if_softc; struct ieee80211com *ic = &sc->sc_ic; uint16_t tmp; @@ -1945,7 +1942,7 @@ ural_init(struct ifnet *ifp) ural_stop(ifp, 0); /* initialize MAC registers to default values */ - for (i = 0; i < N(ural_def_mac); i++) + for (i = 0; i < nitems(ural_def_mac); i++) ural_write(sc, ural_def_mac[i].reg, ural_def_mac[i].val); /* wait for BBP and RF to wake up (this can take a long time!) */ @@ -2083,7 +2080,6 @@ ural_init(struct ifnet *ifp) fail: ural_stop(ifp, 1); return error; -#undef N } void diff --git a/sys/dev/usb/if_rum.c b/sys/dev/usb/if_rum.c index 6312915407e..035b073778a 100644 --- a/sys/dev/usb/if_rum.c +++ b/sys/dev/usb/if_rum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rum.c,v 1.94 2010/12/06 04:41:39 jakemsr Exp $ */ +/* $OpenBSD: if_rum.c,v 1.95 2010/12/17 22:38:54 jasper Exp $ */ /*- * Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr> @@ -1939,7 +1939,6 @@ rum_read_eeprom(struct rum_softc *sc) int rum_bbp_init(struct rum_softc *sc) { -#define N(a) (sizeof (a) / sizeof ((a)[0])) int i, ntries; /* wait for BBP to be ready */ @@ -1956,7 +1955,7 @@ rum_bbp_init(struct rum_softc *sc) } /* initialize BBP registers to default values */ - for (i = 0; i < N(rum_def_bbp); i++) + for (i = 0; i < nitems(rum_def_bbp); i++) rum_bbp_write(sc, rum_def_bbp[i].reg, rum_def_bbp[i].val); /* write vendor-specific BBP values (from EEPROM) */ @@ -1967,13 +1966,11 @@ rum_bbp_init(struct rum_softc *sc) } return 0; -#undef N } int rum_init(struct ifnet *ifp) { -#define N(a) (sizeof (a) / sizeof ((a)[0])) struct rum_softc *sc = ifp->if_softc; struct ieee80211com *ic = &sc->sc_ic; uint32_t tmp; @@ -1983,7 +1980,7 @@ rum_init(struct ifnet *ifp) rum_stop(ifp, 0); /* initialize MAC registers to default values */ - for (i = 0; i < N(rum_def_mac); i++) + for (i = 0; i < nitems(rum_def_mac); i++) rum_write(sc, rum_def_mac[i].reg, rum_def_mac[i].val); /* set host ready */ @@ -2110,7 +2107,6 @@ rum_init(struct ifnet *ifp) fail: rum_stop(ifp, 1); return error; -#undef N } void diff --git a/sys/dev/usb/uchcom.c b/sys/dev/usb/uchcom.c index dd4b564220c..935cd7b5c35 100644 --- a/sys/dev/usb/uchcom.c +++ b/sys/dev/usb/uchcom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uchcom.c,v 1.12 2010/12/17 21:53:34 jasper Exp $ */ +/* $OpenBSD: uchcom.c,v 1.13 2010/12/17 22:38:54 jasper Exp $ */ /* $NetBSD: uchcom.c,v 1.1 2007/09/03 17:57:37 tshiozak Exp $ */ /* @@ -160,7 +160,6 @@ static const struct uchcom_divider_record dividers[] = { 2941, 368, 93750, { 1, 0, 0 } }, { 367, 1, 11719, { 0, 0, 0 } }, }; -#define NUM_DIVIDERS (sizeof (dividers) / sizeof (dividers[0])) void uchcom_get_status(void *, int, u_char *, u_char *); void uchcom_set(void *, int, int, int); @@ -665,7 +664,7 @@ uchcom_calc_divider_settings(struct uchcom_divider *dp, uint32_t rate) uint32_t div, rem, mod; /* find record */ - for (i=0; i<NUM_DIVIDERS; i++) { + for (i=0; i<nitems(dividers); i++) { if (dividers[i].dvr_high >= rate && dividers[i].dvr_low <= rate) { rp = ÷rs[i]; diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c index 9dc23999599..d67b43ee4da 100644 --- a/sys/dev/usb/usb_subr.c +++ b/sys/dev/usb/usb_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb_subr.c,v 1.76 2010/12/15 00:59:26 jakemsr Exp $ */ +/* $OpenBSD: usb_subr.c,v 1.77 2010/12/17 22:38:54 jasper Exp $ */ /* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ @@ -1381,7 +1381,7 @@ usbd_fill_deviceinfo(usbd_device_handle dev, struct usb_device_info *di, if (dev->hub) { for (i = 0; - i < sizeof(di->udi_ports) / sizeof(di->udi_ports[0]) && + i < nitems(di->udi_ports) && i < dev->hub->hubdesc.bNbrPorts; i++) { p = &dev->hub->ports[i]; if (p->device) |