tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: config(5) break down
On Fri Mar 26 2010 at 13:25:43 +0900, Masao Uebayashi wrote:
> syntax. I spent a whole weekend to read sys/conf/files, ioconf.c, and
> module stubs in sys/dev/usb/uaudio.c. I wasted a whole weekend. I've
This patch should work and make it easier. No, it doesn't solve
dependencies, but gets developers at least halfway there without having
to waste weekends (with code). Unfortunately I can't test, since I
forgot to buy a usb audio device from Akihabara ;)
Index: dev/usb/uaudio.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/uaudio.c,v
retrieving revision 1.117
diff -p -u -r1.117 uaudio.c
--- dev/usb/uaudio.c 12 Nov 2009 19:50:01 -0000 1.117
+++ dev/usb/uaudio.c 26 Mar 2010 06:11:39 -0000
@@ -3065,67 +3065,21 @@ uaudio_set_speed(struct uaudio_softc *sc
MODULE(MODULE_CLASS_DRIVER, uaudio, NULL);
-static const struct cfiattrdata audiobuscf_iattrdata = {
- "audiobus", 0, { { NULL, NULL, 0 }, }
-};
-static const struct cfiattrdata * const uaudio_attrs[] = {
- &audiobuscf_iattrdata, NULL
-};
-CFDRIVER_DECL(uaudio, DV_DULL, uaudio_attrs);
-extern struct cfattach uaudio_ca;
-static int uaudioloc[6/*USBIFIFCF_NLOCS*/] = {
- -1/*USBIFIFCF_PORT_DEFAULT*/,
- -1/*USBIFIFCF_CONFIGURATION_DEFAULT*/,
- -1/*USBIFIFCF_INTERFACE_DEFAULT*/,
- -1/*USBIFIFCF_VENDOR_DEFAULT*/,
- -1/*USBIFIFCF_PRODUCT_DEFAULT*/,
- -1/*USBIFIFCF_RELEASE_DEFAULT*/};
-static struct cfparent uhubparent = {
- "usbifif", NULL, DVUNIT_ANY
-};
-static struct cfdata uaudio_cfdata[] = {
- {
- .cf_name = "uaudio",
- .cf_atname = "uaudio",
- .cf_unit = 0,
- .cf_fstate = FSTATE_STAR,
- .cf_loc = uaudioloc,
- .cf_flags = 0,
- .cf_pspec = &uhubparent,
- },
- { NULL }
-};
+#include "ioconf.c"
static int
uaudio_modcmd(modcmd_t cmd, void *arg)
{
- int err;
switch (cmd) {
case MODULE_CMD_INIT:
- err = config_cfdriver_attach(&uaudio_cd);
- if (err) {
- return err;
- }
- err = config_cfattach_attach("uaudio", &uaudio_ca);
- if (err) {
- config_cfdriver_detach(&uaudio_cd);
- return err;
- }
- err = config_cfdata_attach(uaudio_cfdata, 1);
- if (err) {
- config_cfattach_detach("uaudio", &uaudio_ca);
- config_cfdriver_detach(&uaudio_cd);
- return err;
- }
- return 0;
+ return config_init_component(cfdriver_comp_uaudio,
+ cfattach_comp_uaudio, cfdata_uaudio);
+
case MODULE_CMD_FINI:
- err = config_cfdata_detach(uaudio_cfdata);
- if (err)
- return err;
- config_cfattach_detach("uaudio", &uaudio_ca);
- config_cfdriver_detach(&uaudio_cd);
- return 0;
+ return config_fini_component(cfdriver_comp_uaudio,
+ cfattach_comp_uaudio, cfdata_uaudio);
+
default:
return ENOTTY;
}
Index: modules/uaudio/Makefile
===================================================================
RCS file: /cvsroot/src/sys/modules/uaudio/Makefile,v
retrieving revision 1.1
diff -p -u -r1.1 Makefile
--- modules/uaudio/Makefile 28 Jun 2008 09:14:56 -0000 1.1
+++ modules/uaudio/Makefile 26 Mar 2010 06:11:39 -0000
@@ -5,6 +5,7 @@
.PATH: ${S}/dev/usb
KMOD= uaudio
+IOCONF= UAUDIO.ioconf
SRCS= uaudio.c
.include <bsd.kmodule.mk>
Index: modules/uaudio/UAUDIO.ioconf
===================================================================
RCS file: modules/uaudio/UAUDIO.ioconf
diff -N modules/uaudio/UAUDIO.ioconf
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/uaudio/UAUDIO.ioconf 26 Mar 2010 06:11:39 -0000
@@ -0,0 +1,12 @@
+# $NetBSD$
+#
+
+ioconf uaudio
+
+include "conf/files"
+include "dev/usb/files.usb"
+
+pseudo-root uhub*
+
+# USB audio
+uaudio* at uhub? port ? configuration ?
Home |
Main Index |
Thread Index |
Old Index