summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2009-12-15 20:26:22 +0000
committerJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2009-12-15 20:26:22 +0000
commit65ae7942f03b048ffd5a59ab6cf91b8f54112034 (patch)
treee166fe92b9e777a8a020eb1d9562cc699116f0e8 /sys/dev
parentab2b3daf8766001738f6d218a9e430fafb2fc8f7 (diff)
- instead of rolling a macro that is functional equivalent to nitems(),
just use nitems(). (this leaves NENTS() alone for now) ok deraadt@ krw@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/cardbus/cardbus.c5
-rw-r--r--sys/dev/ic/ac97.c14
-rw-r--r--sys/dev/pci/agp.c9
-rw-r--r--sys/dev/pci/ciss_pci.c5
4 files changed, 14 insertions, 19 deletions
diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c
index 76f6decc6eb..02ddbecb951 100644
--- a/sys/dev/cardbus/cardbus.c
+++ b/sys/dev/cardbus/cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cardbus.c,v 1.39 2009/03/29 21:53:52 sthen Exp $ */
+/* $OpenBSD: cardbus.c,v 1.40 2009/12/15 20:26:21 jasper Exp $ */
/* $NetBSD: cardbus.c,v 1.24 2000/04/02 19:11:37 mycroft Exp $ */
/*
@@ -885,9 +885,8 @@ tuple_name(int type)
"VERS_2", "FORMAT", "GEOMETRY", "BYTEORDER", /* 40-43 */
"DATE", "BATTERY", "ORG", "FORMAT_A" /* 44-47 */
};
-#define NAME_LEN(x) (sizeof(x)/sizeof(x[0]))
- if (type > 0 && type < NAME_LEN(tuple_name_s))
+ if (type > 0 && type < nitems(tuple_name_s))
return (tuple_name_s[type]);
else if (0xff == type)
return ("END");
diff --git a/sys/dev/ic/ac97.c b/sys/dev/ic/ac97.c
index cef9a9b88f8..c04f01b6822 100644
--- a/sys/dev/ic/ac97.c
+++ b/sys/dev/ic/ac97.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ac97.c,v 1.70 2008/10/23 21:50:01 jakemsr Exp $ */
+/* $OpenBSD: ac97.c,v 1.71 2009/12/15 20:26:21 jasper Exp $ */
/*
* Copyright (c) 1999, 2000 Constantine Sapuntzakis
@@ -310,8 +310,6 @@ const struct ac97_source_info {
/* Missing features: Simulated Stereo, POP, Loopback mode */
};
-#define SOURCE_INFO_SIZE (sizeof(source_info)/sizeof(source_info[0]))
-
/*
* Check out http://www.intel.com/technology/computing/audio/index.htm
* for information on AC-97
@@ -321,7 +319,7 @@ struct ac97_softc {
/* ac97_codec_if must be at the first of ac97_softc. */
struct ac97_codec_if codec_if;
struct ac97_host_if *host_if;
-#define MAX_SOURCES (2 * SOURCE_INFO_SIZE)
+#define MAX_SOURCES (2 * nitems(source_info))
struct ac97_source_info source_info[MAX_SOURCES];
int num_source_info;
enum ac97_host_flags host_flags;
@@ -504,7 +502,7 @@ const struct ac97_codecid {
{ 0x03, 0xff, 0, 0, "YMF753-S" },
};
-#define cl(n) n, sizeof(n)/sizeof(n[0])
+#define cl(n) n, nitems(n)
const struct ac97_vendorid {
u_int32_t id;
char * const name;
@@ -646,7 +644,7 @@ ac97_setup_defaults(struct ac97_softc *as)
bzero(as->shadow_reg, sizeof(as->shadow_reg));
- for (idx = 0; idx < SOURCE_INFO_SIZE; idx++) {
+ for (idx = 0; idx < nitems(source_info); idx++) {
const struct ac97_source_info *si = &source_info[idx];
ac97_write(as, si->reg, si->default_value);
@@ -659,7 +657,7 @@ ac97_restore_shadow(struct ac97_codec_if *self)
struct ac97_softc *as = (struct ac97_softc *)self;
int idx;
- for (idx = 0; idx < SOURCE_INFO_SIZE; idx++) {
+ for (idx = 0; idx < nitems(source_info); idx++) {
const struct ac97_source_info *si = &source_info[idx];
ac97_write(as, si->reg, as->shadow_reg[si->reg >> 1]);
@@ -708,7 +706,7 @@ ac97_setup_source_info(struct ac97_softc *as)
struct ac97_source_info *si, *si2;
int idx, ouridx;
- for (idx = 0, ouridx = 0; idx < SOURCE_INFO_SIZE; idx++) {
+ for (idx = 0, ouridx = 0; idx < nitems(source_info); idx++) {
si = &as->source_info[ouridx];
if (!ac97_check_capability(as, source_info[idx].req_feature))
diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c
index a4359e9a8d4..bc1b1f7b0f5 100644
--- a/sys/dev/pci/agp.c
+++ b/sys/dev/pci/agp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp.c,v 1.32 2009/05/10 16:57:44 oga Exp $ */
+/* $OpenBSD: agp.c,v 1.33 2009/12/15 20:26:21 jasper Exp $ */
/*-
* Copyright (c) 2000 Doug Rabson
* All rights reserved.
@@ -163,7 +163,6 @@ agp_attach(struct device *parent, struct device *self, void *aux)
{2048, 1920},
{4096, 3932}
};
-#define agp_max_size (sizeof(agp_max)/sizeof(agp_max[0]))
/*
* Work out an upper bound for agp memory allocation. This
@@ -171,10 +170,10 @@ agp_attach(struct device *parent, struct device *self, void *aux)
*/
memsize = ptoa(physmem) >> 20;
- for (i = 0; i < agp_max_size && memsize > agp_max[i][0]; i++)
+ for (i = 0; i < nitems(agp_max) && memsize > agp_max[i][0]; i++)
;
- if (i == agp_max_size)
- i = agp_max_size - 1;
+ if (i == nitems(agp_max))
+ i = nitems(agp_max) - 1;
sc->sc_maxmem = agp_max[i][1] << 20;
/*
diff --git a/sys/dev/pci/ciss_pci.c b/sys/dev/pci/ciss_pci.c
index fe0c051978c..b6ce2914be9 100644
--- a/sys/dev/pci/ciss_pci.c
+++ b/sys/dev/pci/ciss_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ciss_pci.c,v 1.13 2008/11/17 06:56:56 brad Exp $ */
+/* $OpenBSD: ciss_pci.c,v 1.14 2009/12/15 20:26:21 jasper Exp $ */
/*
* Copyright (c) 2005 Michael Shalayeff
@@ -86,14 +86,13 @@ const struct pci_matchid ciss_pci_devices[] = {
{ PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_11 },
{ PCI_VENDOR_HP, PCI_PRODUCT_HP_HPSA_12 }
};
-#define CISS_PCI_NDEVS sizeof(ciss_pci_devices)/sizeof(ciss_pci_devices[0])
int
ciss_pci_match(struct device *parent, void *match, void *aux)
{
struct pci_attach_args *pa = aux;
- return pci_matchbyid(pa, ciss_pci_devices, CISS_PCI_NDEVS);
+ return pci_matchbyid(pa, ciss_pci_devices, nitems(ciss_pci_devices));
}
void