Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Move the hdaudio_cd out of the hdaudio_pci module an...



details:   https://anonhg.NetBSD.org/src/rev/b60a989f6191
branches:  trunk
changeset: 824426:b60a989f6191
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sun Jun 04 23:34:55 2017 +0000

description:
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

diffstat:

 sys/dev/hdaudio/hdaudio.c |  39 ++++++++++++++++++++++++++++++++-------
 sys/dev/pci/hdaudio_pci.c |  24 +++++++++++++++++++-----
 2 files changed, 51 insertions(+), 12 deletions(-)

diffs (136 lines):

diff -r 9c35bb24d8c4 -r b60a989f6191 sys/dev/hdaudio/hdaudio.c
--- a/sys/dev/hdaudio/hdaudio.c Sun Jun 04 21:03:20 2017 +0000
+++ b/sys/dev/hdaudio/hdaudio.c Sun Jun 04 23:34:55 2017 +0000
@@ -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 <support%precedence.co.uk@localhost>
@@ -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 @@
        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 @@
 #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);
diff -r 9c35bb24d8c4 -r b60a989f6191 sys/dev/pci/hdaudio_pci.c
--- a/sys/dev/pci/hdaudio_pci.c Sun Jun 04 21:03:20 2017 +0000
+++ b/sys/dev/pci/hdaudio_pci.c Sun Jun 04 23:34:55 2017 +0000
@@ -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 <support%precedence.co.uk@localhost>
@@ -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 @@
        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;



Home | Main Index | Thread Index | Old Index