summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpirofti <pirofti@openbsd.org>2010-07-02 01:07:20 +0000
committerpirofti <pirofti@openbsd.org>2010-07-02 01:07:20 +0000
commitfdabe9d895bc5d9c9a3c25ff6ea1b38748bcbf0d (patch)
treec1f8de4b2339da45ab3acd3bd13b95014ba522c3
parentSome functions change the ifp in during ether_input(). This confuses the (diff)
downloadwireguard-openbsd-fdabe9d895bc5d9c9a3c25ff6ea1b38748bcbf0d.tar.xz
wireguard-openbsd-fdabe9d895bc5d9c9a3c25ff6ea1b38748bcbf0d.zip
Abstraction clean-up. `I like it' deraadt@.
-rw-r--r--sys/dev/pci/puc.c25
-rw-r--r--sys/dev/pci/pucdata.c4
-rw-r--r--sys/dev/pci/pucvar.h9
3 files changed, 12 insertions, 26 deletions
diff --git a/sys/dev/pci/puc.c b/sys/dev/pci/puc.c
index ad37194ceb8..b117a4e4f50 100644
--- a/sys/dev/pci/puc.c
+++ b/sys/dev/pci/puc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: puc.c,v 1.14 2009/03/03 16:52:25 deraadt Exp $ */
+/* $OpenBSD: puc.c,v 1.15 2010/07/02 01:07:20 pirofti Exp $ */
/* $NetBSD: puc.c,v 1.3 1999/02/06 06:29:54 cgd Exp $ */
/*
@@ -349,22 +349,13 @@ puc_find_description(u_int16_t vend, u_int16_t prod,
{
int i;
-#define checkreg(val, index) \
- (((val) & puc_devices[i].rmask[(index)]) == puc_devices[i].rval[(index)])
-#define pucdevdone(idx) \
- (puc_devices[idx].rval[0] == 0 && puc_devices[idx].rval[1] == 0 \
- && puc_devices[idx].rval[2] == 0 && puc_devices[idx].rval[3] == 0)
-
- for (i = 0; !pucdevdone(i); i++) {
- if (checkreg(vend, PUC_REG_VEND) &&
- checkreg(prod, PUC_REG_PROD) &&
- checkreg(svend, PUC_REG_SVEND) &&
- checkreg(sprod, PUC_REG_SPROD))
- return (&puc_devices[i]);
- }
-
-#undef devdone
-#undef checkreg
+ for (i = 0; puc_devs[i].rval[0] && puc_devs[i].rval[1] &&
+ puc_devs[i].rval[2] && puc_devs[i].rval[3]; i++)
+ if ((vend & puc_devs[i].rmask[0]) == puc_devs[i].rval[0] &&
+ (prod & puc_devs[i].rmask[1]) == puc_devs[i].rval[1] &&
+ (svend & puc_devs[i].rmask[2]) == puc_devs[i].rval[2] &&
+ (sprod & puc_devs[i].rmask[3]) == puc_devs[i].rval[3])
+ return (&puc_devs[i]);
return (NULL);
}
diff --git a/sys/dev/pci/pucdata.c b/sys/dev/pci/pucdata.c
index 36525cf8005..69779395d8a 100644
--- a/sys/dev/pci/pucdata.c
+++ b/sys/dev/pci/pucdata.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pucdata.c,v 1.69 2010/04/27 16:32:53 sthen Exp $ */
+/* $OpenBSD: pucdata.c,v 1.70 2010/07/02 01:07:20 pirofti Exp $ */
/* $NetBSD: pucdata.c,v 1.6 1999/07/03 05:55:23 cgd Exp $ */
/*
@@ -46,7 +46,7 @@
#include <dev/pci/pcidevs.h>
#include <dev/ic/comreg.h>
-const struct puc_device_description puc_devices[] = {
+const struct puc_device_description puc_devs[] = {
/*
* XXX no entry because I have no data:
* XXX Dolphin Peripherals 4006 (single parallel)
diff --git a/sys/dev/pci/pucvar.h b/sys/dev/pci/pucvar.h
index 26c624fbd3f..4254d060aef 100644
--- a/sys/dev/pci/pucvar.h
+++ b/sys/dev/pci/pucvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pucvar.h,v 1.7 2009/03/03 16:52:25 deraadt Exp $ */
+/* $OpenBSD: pucvar.h,v 1.8 2010/07/02 01:07:20 pirofti Exp $ */
/* $NetBSD: pucvar.h,v 1.2 1999/02/06 06:29:54 cgd Exp $ */
/*
@@ -51,11 +51,6 @@ struct puc_device_description {
} ports[PUC_MAX_PORTS];
};
-#define PUC_REG_VEND 0
-#define PUC_REG_PROD 1
-#define PUC_REG_SVEND 2
-#define PUC_REG_SPROD 3
-
#define PUC_PORT_TYPE_NONE 0
#define PUC_PORT_TYPE_COM 1
#define PUC_PORT_TYPE_LPT 2
@@ -85,7 +80,7 @@ struct puc_attach_args {
void (*intr_disestablish)(struct puc_attach_args *, void *);
};
-extern const struct puc_device_description puc_devices[];
+extern const struct puc_device_description puc_devs[];
#define PUC_NBARS 6
struct puc_softc {