summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2015-07-21 17:59:59 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2015-07-21 17:59:59 +0000
commitc995eae6ae804bcbe83569a7945706d65e8dd823 (patch)
treea3337fb7da4a0fa52561187ad64ae1fe6ce22a57 /sys
parent816f4958da090fe328a490d67aafd10c4bbcbd41 (diff)
Switch pvbus(4) to fully dynamic autoconf - drivers don't have to be
listed in pvbus.c anymore and are defined by the config only. OK mlarkin@ sf@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pv/pvbus.c36
-rw-r--r--sys/dev/pv/pvvar.h3
-rw-r--r--sys/dev/pv/vmt.c9
3 files changed, 26 insertions, 22 deletions
diff --git a/sys/dev/pv/pvbus.c b/sys/dev/pv/pvbus.c
index bc886f0814f..4c5297470f7 100644
--- a/sys/dev/pv/pvbus.c
+++ b/sys/dev/pv/pvbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pvbus.c,v 1.1 2015/07/21 03:38:22 reyk Exp $ */
+/* $OpenBSD: pvbus.c,v 1.2 2015/07/21 17:59:58 reyk Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -47,6 +47,7 @@ int pvbus_activate(struct device *, int);
int pvbus_match(struct device *, void *, void *);
void pvbus_attach(struct device *, struct device *, void *);
int pvbus_print(void *, const char *);
+int pvbus_search(struct device *, void *, void *);
struct cfattach pvbus_ca = {
sizeof(struct pvbus_softc),
@@ -74,13 +75,6 @@ struct pvbus_type {
{ NULL }
};
-struct pv_attach_args pvbus_devices[] = {
-#if NVMT > 0
- { "vmt", PVBUS_VMWARE },
-#endif
- { NULL }
-};
-
int
pvbus_probe(void)
{
@@ -101,7 +95,6 @@ void
pvbus_attach(struct device *parent, struct device *self, void *aux)
{
struct pvbus_softc *sc = (struct pvbus_softc *)self;
- struct pv_attach_args *pva;
uint32_t reg0, base;
union {
uint32_t regs[3];
@@ -150,14 +143,7 @@ pvbus_attach(struct device *parent, struct device *self, void *aux)
}
#endif
- /* Attach drivers */
- for (i = 0; pvbus_devices[i].pva_busname != NULL; i++) {
- pva = &pvbus_devices[i];
- pva->pva_types = sc->pvbus_types;
- if (sc->pvbus_types & pva->pva_type)
- config_found(self, &pva->pva_busname,
- pvbus_print);
- }
+ config_search(pvbus_search, self, sc);
}
int
@@ -184,6 +170,22 @@ pvbus_activate(struct device *self, int act)
}
int
+pvbus_search(struct device *parent, void *arg, void *aux)
+{
+ struct pvbus_softc *sc = (struct pvbus_softc *)aux;
+ struct cfdata *cf = arg;
+ struct pv_attach_args pva;
+
+ pva.pva_busname = cf->cf_driver->cd_name;
+ pva.pva_types = sc->pvbus_types;
+
+ if (cf->cf_attach->ca_match(parent, cf, &pva) > 0)
+ config_attach(parent, cf, &pva, pvbus_print);
+
+ return (0);
+}
+
+int
pvbus_print(void *aux, const char *pnp)
{
struct pv_attach_args *pva = aux;
diff --git a/sys/dev/pv/pvvar.h b/sys/dev/pv/pvvar.h
index 06161c7d51a..efaf78d3102 100644
--- a/sys/dev/pv/pvvar.h
+++ b/sys/dev/pv/pvvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pvvar.h,v 1.1 2015/07/21 03:38:22 reyk Exp $ */
+/* $OpenBSD: pvvar.h,v 1.2 2015/07/21 17:59:58 reyk Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -30,7 +30,6 @@ struct pvbus_attach_args {
struct pv_attach_args {
const char *pva_busname;
- uint8_t pva_type; /* required hv type */
uint8_t pva_types; /* detected hv types */
};
diff --git a/sys/dev/pv/vmt.c b/sys/dev/pv/vmt.c
index 967682db53b..52f9cd884bc 100644
--- a/sys/dev/pv/vmt.c
+++ b/sys/dev/pv/vmt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmt.c,v 1.1 2015/07/21 09:13:11 reyk Exp $ */
+/* $OpenBSD: vmt.c,v 1.2 2015/07/21 17:59:58 reyk Exp $ */
/*
* Copyright (c) 2007 David Crawshaw <david@zentus.com>
@@ -40,6 +40,7 @@
#include <net/if_var.h>
#include <netinet/in.h>
+#include <dev/pv/pvvar.h>
#include <dev/rndvar.h>
/* "The" magic number, always occupies the EAX register. */
@@ -317,12 +318,14 @@ vmt_probe(void)
int
vmt_match(struct device *parent, void *match, void *aux)
{
- const char **busname = (const char **)aux;
+ struct pv_attach_args *pva = aux;
+ if ((pva->pva_types & PVBUS_VMWARE) == 0)
+ return (0);
if (!vmt_probe())
return (0);
- return (strcmp(*busname, vmt_cd.cd_name) == 0);
+ return (1);
}
void