Module Name: src Committed By: pgoyette Date: Sun Jun 4 23:34:55 UTC 2017
Modified Files: src/sys/dev/hdaudio: hdaudio.c src/sys/dev/pci: hdaudio_pci.c Log Message: Move the hdaudio_cd out of the hdaudio_pci module and into the main hdaudio module. Rearrange the inter-module dependencies accordingly. Should resolve (my) PR kern/49836 XXX Pull-ups needed for netbsd-8 branch To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/hdaudio/hdaudio.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/hdaudio_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/hdaudio/hdaudio.c diff -u src/sys/dev/hdaudio/hdaudio.c:1.4 src/sys/dev/hdaudio/hdaudio.c:1.5 --- src/sys/dev/hdaudio/hdaudio.c:1.4 Wed Dec 23 12:45:06 2015 +++ src/sys/dev/hdaudio/hdaudio.c Sun Jun 4 23:34:55 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: hdaudio.c,v 1.4 2015/12/23 12:45:06 jmcneill Exp $ */ +/* $NetBSD: hdaudio.c,v 1.5 2017/06/04 23:34:55 pgoyette Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd <supp...@precedence.co.uk> @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.4 2015/12/23 12:45:06 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.5 2017/06/04 23:34:55 pgoyette Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -1602,7 +1602,18 @@ hdaudioioctl(dev_t dev, u_long cmd, void return err; } -MODULE(MODULE_CLASS_DRIVER, hdaudio, NULL); +MODULE(MODULE_CLASS_DRIVER, hdaudio, "audio"); +#ifdef _MODULE +static const struct cfiattrdata hdaudiobuscf_iattrdata = { + "hdaudiobus", 1, { + { "nid", "-1", -1 }, + } +}; +static const struct cfiattrdata * const hdaudio_attrs[] = { + &hdaudiobuscf_iattrdata, NULL +}; +CFDRIVER_DECL(hdaudio, DV_AUDIODEV, hdaudio_attrs); +#endif static int hdaudio_modcmd(modcmd_t cmd, void *opaque) @@ -1617,16 +1628,30 @@ hdaudio_modcmd(modcmd_t cmd, void *opaqu #ifdef _MODULE error = devsw_attach("hdaudio", NULL, &bmaj, &hdaudio_cdevsw, &cmaj); + if (error) + break; + error = config_cfdriver_attach(&hdaudio_cd); + if (error) + devsw_detach(NULL, &hdaudio_cdevsw); #endif - return error; + break; case MODULE_CMD_FINI: #ifdef _MODULE - devsw_detach(NULL, &hdaudio_cdevsw); + error = config_cfdriver_detach(&hdaudio_cd); + if (error) + break; + error = devsw_detach(NULL, &hdaudio_cdevsw); + if (error) { + config_cfdriver_attach(&hdaudio_cd); + break; + } #endif - return 0; + break; default: - return ENOTTY; + error = ENOTTY; + break; } + return error; } DEV_VERBOSE_DEFINE(hdaudio); Index: src/sys/dev/pci/hdaudio_pci.c diff -u src/sys/dev/pci/hdaudio_pci.c:1.7 src/sys/dev/pci/hdaudio_pci.c:1.8 --- src/sys/dev/pci/hdaudio_pci.c:1.7 Thu Apr 27 10:01:54 2017 +++ src/sys/dev/pci/hdaudio_pci.c Sun Jun 4 23:34:55 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: hdaudio_pci.c,v 1.7 2017/04/27 10:01:54 msaitoh Exp $ */ +/* $NetBSD: hdaudio_pci.c,v 1.8 2017/06/04 23:34:55 pgoyette Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd <supp...@precedence.co.uk> @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hdaudio_pci.c,v 1.7 2017/04/27 10:01:54 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdaudio_pci.c,v 1.8 2017/06/04 23:34:55 pgoyette Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -269,27 +269,41 @@ hdaudio_pci_resume(device_t self, const return hdaudio_resume(&sc->sc_hdaudio); } -MODULE(MODULE_CLASS_DRIVER, hdaudio_pci, "hdaudio"); +MODULE(MODULE_CLASS_DRIVER, hdaudio_pci, "pci,hdaudio,audio"); #ifdef _MODULE +/* + * XXX Don't allow ioconf.c to redefine the "struct cfdriver hdaudio_cd" + * XXX it will be defined in the common hdaudio module + */ + +#undef CFDRIVER_DECL +#define CFDRIVER_DECL(name, class, attr) /* nothing */ #include "ioconf.c" #endif static int hdaudio_pci_modcmd(modcmd_t cmd, void *opaque) { +#ifdef _MODULE + /* + * We ignore the cfdriver_vec[] that ioconf provides, since + * the cfdrivers are attached already. + */ + static struct cfdriver * const no_cfdriver_vec[] = { NULL }; +#endif int error = 0; switch (cmd) { case MODULE_CMD_INIT: #ifdef _MODULE - error = config_init_component(cfdriver_ioconf_hdaudio_pci, + error = config_init_component(no_cfdriver_vec, cfattach_ioconf_hdaudio_pci, cfdata_ioconf_hdaudio_pci); #endif return error; case MODULE_CMD_FINI: #ifdef _MODULE - error = config_fini_component(cfdriver_ioconf_hdaudio_pci, + error = config_fini_component(no_cfdriver_vec, cfattach_ioconf_hdaudio_pci, cfdata_ioconf_hdaudio_pci); #endif return error;