Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Use config(1) and IOCONF= to generate most of the auto-c...
details: https://anonhg.NetBSD.org/src/rev/79bc5434e3c8
branches: trunk
changeset: 358179:79bc5434e3c8
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sat Dec 16 06:39:07 2017 +0000
description:
Use config(1) and IOCONF= to generate most of the auto-config data
structures. (Note that bin/52823 documents the reasons for still
requiring hand-crafted cfattach structures.)
diffstat:
sys/dev/pad/pad.c | 65 ++++++++++++++-------------------------------
sys/modules/pad/Makefile | 3 +-
sys/modules/pad/pad.ioconf | 7 ++++
3 files changed, 30 insertions(+), 45 deletions(-)
diffs (153 lines):
diff -r f6ed832f74b9 -r 79bc5434e3c8 sys/dev/pad/pad.c
--- a/sys/dev/pad/pad.c Sat Dec 16 03:13:29 2017 +0000
+++ b/sys/dev/pad/pad.c Sat Dec 16 06:39:07 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pad.c,v 1.47 2017/12/16 02:45:14 pgoyette Exp $ */
+/* $NetBSD: pad.c,v 1.48 2017/12/16 06:39:07 pgoyette Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.47 2017/12/16 02:45:14 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.48 2017/12/16 06:39:07 pgoyette Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -346,10 +346,11 @@
cf->cf_unit = i;
cf->cf_fstate = FSTATE_STAR;
- if (device_lookup(&pad_cd, minor(dev)) == NULL)
+ paddev = device_lookup(&pad_cd, minor(dev));
+ if (paddev == NULL)
paddev = config_attach_pseudo(cf);
- else
- paddev = device_lookup(&pad_cd, minor(dev));
+ if (paddev == NULL)
+ return ENXIO;
sc = device_private(paddev);
if (sc == NULL)
@@ -903,39 +904,18 @@
#ifdef _MODULE
-/* XXX These should really be created by config(1)'s IOCONF mechanism */
+#include "ioconf.c"
-static const struct cfiattrdata audiobuscf_iattrdata = {
- "audiobus", 0, { { NULL, NULL, 0 }, }
-};
-static const struct cfiattrdata * const pad_attrs[] = {
- &audiobuscf_iattrdata, NULL
-};
-
-CFDRIVER_DECL(pad, DV_DULL, pad_attrs);
-extern struct cfattach pad_ca;
-static int padloc[] = { -1, -1 };
+devmajor_t cmajor = NODEVMAJOR, bmajor = NODEVMAJOR;
-static struct cfdata pad_cfdata[] = {
- {
- .cf_name = "pad",
- .cf_atname = "pad",
- .cf_unit = 0,
- .cf_fstate = FSTATE_STAR,
- .cf_loc = padloc,
- .cf_flags = 0,
- .cf_pspec = NULL,
- },
- { NULL, NULL, 0, 0, NULL, 0, NULL }
-};
+/*
+ * We need our own version of cfattach since config(1)'s ioconf does not
+ * generate what we need
+ */
-/* provide the vectors required for config_{init,fini}_component() */
-
-struct cfdriver * const pad_cfdriver[] = { &pad_cd, NULL };
+static struct cfattach *pad_cfattachinit[] = { &pad_ca, NULL };
-static struct cfattach * const pad_cfattachinit[] = { &pad_ca, NULL };
-
-static const struct cfattachinit pad_cfattach[] = {
+static struct cfattachinit pad_cfattach[] = {
{ "pad", pad_cfattachinit },
{ NULL, NULL }
};
@@ -944,28 +924,25 @@
static int
pad_modcmd(modcmd_t cmd, void *arg)
{
-#ifdef _MODULE
- devmajor_t cmajor = NODEVMAJOR, bmajor = NODEVMAJOR;
-#endif
int error = 0;
switch (cmd) {
case MODULE_CMD_INIT:
#ifdef _MODULE
- error = config_init_component(pad_cfdriver, pad_cfattach,
- pad_cfdata);
+ pad_cfattach[1] = cfattach_ioconf_pad[0];
+ error = config_init_component(cfdriver_ioconf_pad,
+ pad_cfattach, cfdata_ioconf_pad);
if (error)
break;
error = devsw_attach(pad_cd.cd_name, NULL, &bmajor,
&pad_cdevsw, &cmajor);
if (error) {
- config_fini_component(pad_cfdriver, pad_cfattach,
- pad_cfdata);
+ config_fini_component(cfdriver_ioconf_pad,
+ pad_cfattach, cfdata_ioconf_pad);
break;
}
- (void)config_attach_pseudo(pad_cfdata);
#endif
break;
@@ -975,8 +952,8 @@
if (error)
break;
- error = config_fini_component(pad_cfdriver, pad_cfattach,
- pad_cfdata);
+ error = config_fini_component(cfdriver_ioconf_pad,
+ pad_cfattach, cfdata_ioconf_pad);
if (error) {
error = devsw_attach(pad_cd.cd_name, NULL, &bmajor,
&pad_cdevsw, &cmajor);
diff -r f6ed832f74b9 -r 79bc5434e3c8 sys/modules/pad/Makefile
--- a/sys/modules/pad/Makefile Sat Dec 16 03:13:29 2017 +0000
+++ b/sys/modules/pad/Makefile Sat Dec 16 06:39:07 2017 +0000
@@ -1,10 +1,11 @@
-# $NetBSD: Makefile,v 1.2 2014/11/18 01:56:41 jmcneill Exp $
+# $NetBSD: Makefile,v 1.3 2017/12/16 06:39:07 pgoyette Exp $
.include "../Makefile.inc"
.PATH: ${S}/dev/pad
KMOD= pad
+IOCONF= pad.ioconf
SRCS= pad.c
diff -r f6ed832f74b9 -r 79bc5434e3c8 sys/modules/pad/pad.ioconf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/pad/pad.ioconf Sat Dec 16 06:39:07 2017 +0000
@@ -0,0 +1,7 @@
+# $NetBSD: pad.ioconf,v 1.1 2017/12/16 06:39:07 pgoyette Exp $
+
+ioconf pad
+
+include "conf/files"
+
+pseudo-device pad
Home |
Main Index |
Thread Index |
Old Index