[svn-commits] fjoe: freebsd/trunk r9249 - in /freebsd/trunk: drivers/dahdi/ drivers/dahdi/v...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Sep 1 13:11:47 CDT 2010


Author: fjoe
Date: Wed Sep  1 13:11:41 2010
New Revision: 9249

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9249
Log:
- Implement try_module_get() and module_put() KAPI
- Implement standard modevent for DAHDI drivers and modules

Modified:
    freebsd/trunk/drivers/dahdi/dahdi-base.c
    freebsd/trunk/drivers/dahdi/dahdi_dynamic.c
    freebsd/trunk/drivers/dahdi/dahdi_dynamic_eth.c
    freebsd/trunk/drivers/dahdi/dahdi_dynamic_ethmf.c
    freebsd/trunk/drivers/dahdi/dahdi_dynamic_loc.c
    freebsd/trunk/drivers/dahdi/dahdi_echocan_jpah.c
    freebsd/trunk/drivers/dahdi/dahdi_echocan_kb1.c
    freebsd/trunk/drivers/dahdi/dahdi_echocan_mg2.c
    freebsd/trunk/drivers/dahdi/dahdi_echocan_oslec.c
    freebsd/trunk/drivers/dahdi/dahdi_echocan_sec.c
    freebsd/trunk/drivers/dahdi/dahdi_echocan_sec2.c
    freebsd/trunk/drivers/dahdi/dahdi_transcode.c
    freebsd/trunk/drivers/dahdi/voicebus/voicebus.c
    freebsd/trunk/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c
    freebsd/trunk/drivers/dahdi/wcb4xxp/base.c
    freebsd/trunk/drivers/dahdi/wcfxo.c
    freebsd/trunk/drivers/dahdi/wct4xxp/base.c
    freebsd/trunk/drivers/dahdi/wctc4xxp/base.c
    freebsd/trunk/drivers/dahdi/wctdm.c
    freebsd/trunk/drivers/dahdi/wctdm24xxp/base.c
    freebsd/trunk/drivers/dahdi/wcte11xp.c
    freebsd/trunk/drivers/dahdi/wcte12xp/base.c
    freebsd/trunk/freebsd/dahdi/bsd-compat.c
    freebsd/trunk/include/dahdi/compat/bsd.h

Modified: freebsd/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi-base.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi-base.c Wed Sep  1 13:11:41 2010
@@ -9169,9 +9169,6 @@
 }
 
 #else /* !__FreeBSD__ */
-MODULE_AUTHOR("Mark Spencer <markster at digium.com>");
-MODULE_DESCRIPTION("DAHDI Telephony Interface");
-MODULE_LICENSE("GPL v2");
 /* DAHDI now provides timing. If anybody wants dahdi_dummy it's probably
  * for that. So make dahdi provide it for now. This alias may be removed
  * in the future, and users are encouraged not to rely on it. */
@@ -9353,25 +9350,8 @@
 }
 
 #if defined(__FreeBSD__)
-static int
-dahdi_modevent(module_t mod, int cmd, void *arg)
-{
-	switch (cmd) {
-	case MOD_LOAD:
-		return dahdi_init();
-
-	case MOD_UNLOAD:
-		dahdi_cleanup();
-		return 0;
-
-	default:
-		/* we only understand load/unload*/
-		return EOPNOTSUPP;
-	}
-}
-
 /* Now declare the module to the system */
-DAHDI_DEV_MODULE(dahdi, dahdi_modevent, NULL);
+DAHDI_DEV_MODULE(dahdi);
 MODULE_VERSION(dahdi, 1);
 MODULE_DEPEND(dahdi, firmware, 1, 1, 1);
 #ifdef CONFIG_DAHDI_CORE_TIMER
@@ -9391,7 +9371,11 @@
 DEV_MODULE(dahdi_dummy, dahdi_dummy_modevent, NULL);
 MODULE_VERSION(dahdi_dummy, 1);
 #endif
-#else /* !__FreeBSD__ */
+#endif /* __FreeBSD__ */
+
+MODULE_AUTHOR("Mark Spencer <markster at digium.com>");
+MODULE_DESCRIPTION("DAHDI Telephony Interface");
+MODULE_LICENSE("GPL v2");
+
 module_init(dahdi_init);
 module_exit(dahdi_cleanup);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/dahdi_dynamic.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_dynamic.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_dynamic.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_dynamic.c Wed Sep  1 13:11:41 2010
@@ -1005,33 +1005,17 @@
 SYSCTL_NODE(_dahdi, OID_AUTO, dynamic, CTLFLAG_RW, 0, "DAHDI Dynamic Span Support");
 #define MODULE_PARAM_PREFIX "dahdi.dynamic"
 #define MODULE_PARAM_PARENT _dahdi_dynamic
-#endif /* __FreeBSD__ */
-
-module_param(debug, int, 0600);
-
-#if defined(__FreeBSD__)
-static int
-dahdi_dynamic_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	switch (type) {
-	case MOD_LOAD:
-		return ztdynamic_init();
-	case MOD_UNLOAD:
-		ztdynamic_cleanup();
-		return 0;
-	default:
-		return EOPNOTSUPP;
-	}
-}
-
-DAHDI_DEV_MODULE(dahdi_dynamic, dahdi_dynamic_modevent, NULL);
+
+DAHDI_DEV_MODULE(dahdi_dynamic);
 MODULE_VERSION(dahdi_dynamic, 1);
 MODULE_DEPEND(dahdi_dynamic, dahdi, 1, 1, 1);
-#else /* !__FreeBSD__ */
+#endif /* __FreeBSD__ */
+
+module_param(debug, int, 0600);
+
 MODULE_DESCRIPTION("DAHDI Dynamic Span Support");
 MODULE_AUTHOR("Mark Spencer <markster at digium.com>");
 MODULE_LICENSE("GPL v2");
 
 module_init(ztdynamic_init);
 module_exit(ztdynamic_cleanup);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/dahdi_dynamic_eth.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_dynamic_eth.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_dynamic_eth.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_dynamic_eth.c Wed Sep  1 13:11:41 2010
@@ -500,30 +500,16 @@
 }
 
 #if defined(__FreeBSD__)
-static int
-dahdi_dynamic_eth_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	switch (type) {
-	case MOD_LOAD:
-		return ztdeth_init();
-	case MOD_UNLOAD:
-		ztdeth_exit();
-		return 0;
-	default:
-		return EOPNOTSUPP;
-	}
-}
-
-DAHDI_DEV_MODULE(dahdi_dynamic_eth, dahdi_dynamic_eth_modevent, NULL);
+DAHDI_DEV_MODULE(dahdi_dynamic_eth);
 MODULE_VERSION(dahdi_dynamic_eth, 1);
 MODULE_DEPEND(dahdi_dynamic_eth, dahdi, 1, 1, 1);
 MODULE_DEPEND(dahdi_dynamic_eth, dahdi_dynamic, 1, 1, 1);
 MODULE_DEPEND(dahdi_dynamic_eth, ng_dahdi_netdev, 1, 1, 1);
-#else /* !__FreeBSD__ */
+#endif /* __FreeBSD__ */
+
 MODULE_DESCRIPTION("DAHDI Dynamic TDMoE Support");
 MODULE_AUTHOR("Mark Spencer <markster at digium.com>");
 MODULE_LICENSE("GPL v2");
 
 module_init(ztdeth_init);
 module_exit(ztdeth_exit);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/dahdi_dynamic_ethmf.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_dynamic_ethmf.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_dynamic_ethmf.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_dynamic_ethmf.c Wed Sep  1 13:11:41 2010
@@ -954,26 +954,13 @@
 }
 
 #if defined(__FreeBSD__)
-static int
-dahdi_dynamic_ethmf_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	switch (type) {
-	case MOD_LOAD:
-		return ztdethmf_init();
-	case MOD_UNLOAD:
-		ztdethmf_exit();
-		return 0;
-	default:
-		return EOPNOTSUPP;
-	}
-}
-
-DAHDI_DEV_MODULE(dahdi_dynamic_ethmf, dahdi_dynamic_ethmf_modevent, NULL);
+DAHDI_DEV_MODULE(dahdi_dynamic_ethmf);
 MODULE_VERSION(dahdi_dynamic_ethmf, 1);
 MODULE_DEPEND(dahdi_dynamic_ethmf, dahdi, 1, 1, 1);
 MODULE_DEPEND(dahdi_dynamic_ethmf, dahdi_dynamic, 1, 1, 1);
 MODULE_DEPEND(dahdi_dynamic_ethmf, ng_dahdi_netdev, 1, 1, 1);
-#else /* !__FreeBSD__ */
+#endif /* __FreeBSD__ */
+
 MODULE_DESCRIPTION("DAHDI Dynamic TDMoEmf Support");
 MODULE_AUTHOR("Joseph Benden <joe at thrallingpenguin.com>");
 #ifdef MODULE_LICENSE
@@ -982,4 +969,3 @@
 
 module_init(ztdethmf_init);
 module_exit(ztdethmf_exit);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/dahdi_dynamic_loc.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_dynamic_loc.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_dynamic_loc.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_dynamic_loc.c Wed Sep  1 13:11:41 2010
@@ -268,27 +268,13 @@
 }
 
 #if defined(__FreeBSD__)
-static int
-dahdi_dynamic_loc_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	switch (type) {
-	case MOD_LOAD:
-		return ztdlocal_init();
-	case MOD_UNLOAD:
-		ztdlocal_exit();
-		return 0;
-	default:
-		return EOPNOTSUPP;
-	}
-}
-
-DAHDI_DEV_MODULE(dahdi_dynamic_loc, dahdi_dynamic_loc_modevent, NULL);
+DAHDI_DEV_MODULE(dahdi_dynamic_loc);
 MODULE_VERSION(dahdi_dynamic_loc, 1);
 MODULE_DEPEND(dahdi_dynamic_loc, dahdi, 1, 1, 1);
 MODULE_DEPEND(dahdi_dynamic_loc, dahdi_dynamic, 1, 1, 1);
-#else /* !__FreeBSD__ */
+#endif /* __FreeBSD__ */
+
 module_init(ztdlocal_init);
 module_exit(ztdlocal_exit);
 
 MODULE_LICENSE("GPL v2");
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/dahdi_echocan_jpah.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_echocan_jpah.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_echocan_jpah.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_echocan_jpah.c Wed Sep  1 13:11:41 2010
@@ -148,36 +148,17 @@
 SYSCTL_NODE(_dahdi_echocan, OID_AUTO, jpah, CTLFLAG_RW, 0, "DAHDI 'JPAH' Echo Canceler");
 #define MODULE_PARAM_PREFIX "dahdi.echocan.jpah"
 #define MODULE_PARAM_PARENT _dahdi_echocan_jpah
+
+DAHDI_DEV_MODULE(dahdi_echocan_jpah);
+MODULE_VERSION(dahdi_echocan_jpah, 1);
+MODULE_DEPEND(dahdi_echocan_jpah, dahdi, 1, 1, 1);
 #endif
 
 module_param(debug, int, S_IRUGO | S_IWUSR);
 
-#if defined(__FreeBSD__)
-static int
-echocan_jpah_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	int res;
-
-	switch (type) {
-	case MOD_LOAD:
-		res = mod_init();
-		return (-res);
-	case MOD_UNLOAD:
-		mod_exit();
-		return (0);
-	default:
-		return (EOPNOTSUPP);
-	}
-}
-
-DAHDI_DEV_MODULE(dahdi_echocan_jpah, echocan_jpah_modevent, NULL);
-MODULE_VERSION(dahdi_echocan_jpah, 1);
-MODULE_DEPEND(dahdi_echocan_jpah, dahdi, 1, 1, 1);
-#else /* !__FreeBSD__ */
 MODULE_DESCRIPTION("DAHDI Jason Parker Audio Hoser");
 MODULE_AUTHOR("Jason Parker <jparker at digium.com>");
 MODULE_LICENSE("GPL v2");
 
 module_init(mod_init);
 module_exit(mod_exit);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/dahdi_echocan_kb1.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_echocan_kb1.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_echocan_kb1.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_echocan_kb1.c Wed Sep  1 13:11:41 2010
@@ -746,37 +746,18 @@
 SYSCTL_NODE(_dahdi_echocan, OID_AUTO, kb1, CTLFLAG_RW, 0, "DAHDI 'KB1' Echo Canceler");
 #define MODULE_PARAM_PREFIX "dahdi.echocan.kb1"
 #define MODULE_PARAM_PARENT _dahdi_echocan_kb1
-#endif
+
+DAHDI_DEV_MODULE(dahdi_echocan_kb1);
+MODULE_VERSION(dahdi_echocan_kb1, 1);
+MODULE_DEPEND(dahdi_echocan_kb1, dahdi, 1, 1, 1);
+#endif /* __FreeBSD__ */
 
 module_param(debug, int, S_IRUGO | S_IWUSR);
 module_param(aggressive, int, S_IRUGO | S_IWUSR);
 
-#if defined(__FreeBSD__)
-static int
-echocan_kb1_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	int res;
-
-	switch (type) {
-	case MOD_LOAD:
-		res = mod_init();
-		return (-res);
-	case MOD_UNLOAD:
-		mod_exit();
-		return (0);
-	default:
-		return (EOPNOTSUPP);
-	}
-}
-
-DAHDI_DEV_MODULE(dahdi_echocan_kb1, echocan_kb1_modevent, NULL);
-MODULE_VERSION(dahdi_echocan_kb1, 1);
-MODULE_DEPEND(dahdi_echocan_kb1, dahdi, 1, 1, 1);
-#else /* !__FreeBSD__ */
 MODULE_DESCRIPTION("DAHDI 'KB1' Echo Canceler");
 MODULE_AUTHOR("Kris Boutilier");
 MODULE_LICENSE("GPL v2");
 
 module_init(mod_init);
 module_exit(mod_exit);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/dahdi_echocan_mg2.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_echocan_mg2.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_echocan_mg2.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_echocan_mg2.c Wed Sep  1 13:11:41 2010
@@ -893,37 +893,18 @@
 SYSCTL_NODE(_dahdi_echocan, OID_AUTO, mg2, CTLFLAG_RW, 0, "DAHDI 'MG2' Echo Canceler");
 #define MODULE_PARAM_PREFIX "dahdi.echocan.mg2"
 #define MODULE_PARAM_PARENT _dahdi_echocan_mg2
-#endif
+
+DAHDI_DEV_MODULE(dahdi_echocan_mg2);
+MODULE_VERSION(dahdi_echocan_mg2, 1);
+MODULE_DEPEND(dahdi_echocan_mg2, dahdi, 1, 1, 1);
+#endif /* __FreeBSD__ */
 
 module_param(debug, int, S_IRUGO | S_IWUSR);
 module_param(aggressive, int, S_IRUGO | S_IWUSR);
 
-#if defined(__FreeBSD__)
-static int
-echocan_mg2_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	int res;
-
-	switch (type) {
-	case MOD_LOAD:
-		res = mod_init();
-		return (-res);
-	case MOD_UNLOAD:
-		mod_exit();
-		return (0);
-	default:
-		return (EOPNOTSUPP);
-	}
-}
-
-DAHDI_DEV_MODULE(dahdi_echocan_mg2, echocan_mg2_modevent, NULL);
-MODULE_VERSION(dahdi_echocan_mg2, 1);
-MODULE_DEPEND(dahdi_echocan_mg2, dahdi, 1, 1, 1);
-#else /* !__FreeBSD__ */
 MODULE_DESCRIPTION("DAHDI 'MG2' Echo Canceler");
 MODULE_AUTHOR("Michael Gernoth");
 MODULE_LICENSE("GPL v2");
 
 module_init(mod_init);
 module_exit(mod_exit);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/dahdi_echocan_oslec.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_echocan_oslec.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_echocan_oslec.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_echocan_oslec.c Wed Sep  1 13:11:41 2010
@@ -142,31 +142,14 @@
 }
 
 #if defined(__FreeBSD__)
-static int
-echocan_oslec_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	int res;
-
-	switch (type) {
-	case MOD_LOAD:
-		res = mod_init();
-		return (-res);
-	case MOD_UNLOAD:
-		mod_exit();
-		return (0);
-	default:
-		return (EOPNOTSUPP);
-	}
-}
-
-DAHDI_DEV_MODULE(dahdi_echocan_oslec, echocan_oslec_modevent, NULL);
+DAHDI_DEV_MODULE(dahdi_echocan_oslec);
 MODULE_VERSION(dahdi_echocan_oslec, 1);
 MODULE_DEPEND(dahdi_echocan_oslec, dahdi, 1, 1, 1);
-#else
+#endif /* __FreeBSD__ */
+
 MODULE_DESCRIPTION("DAHDI OSLEC wrapper");
 MODULE_AUTHOR("Tzafrir Cohen <tzafrir.cohen at xorcom.com>");
 MODULE_LICENSE("GPL");
 
 module_init(mod_init);
 module_exit(mod_exit);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/dahdi_echocan_sec.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_echocan_sec.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_echocan_sec.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_echocan_sec.c Wed Sep  1 13:11:41 2010
@@ -359,36 +359,17 @@
 SYSCTL_NODE(_dahdi_echocan, OID_AUTO, sec, CTLFLAG_RW, 0, "DAHDI 'SEC' Echo Canceler");
 #define MODULE_PARAM_PREFIX "dahdi.echocan.sec"
 #define MODULE_PARAM_PARENT _dahdi_echocan_sec
-#endif
-
-module_param(debug, int, S_IRUGO | S_IWUSR);
-
-#if defined(__FreeBSD__)
-static int
-echocan_sec_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	int res;
-
-	switch (type) {
-	case MOD_LOAD:
-		res = mod_init();
-		return (-res);
-	case MOD_UNLOAD:
-		mod_exit();
-		return (0);
-	default:
-		return (EOPNOTSUPP);
-	}
-}
-
-DAHDI_DEV_MODULE(dahdi_echocan_sec, echocan_sec_modevent, NULL);
+
+DAHDI_DEV_MODULE(dahdi_echocan_sec);
 MODULE_VERSION(dahdi_echocan_sec, 1);
 MODULE_DEPEND(dahdi_echocan_sec, dahdi, 1, 1, 1);
-#else /* !__FreeBSD__ */
+#endif /* __FreeBSD__ */
+
+module_param(debug, int, S_IRUGO | S_IWUSR);
+
 MODULE_DESCRIPTION("DAHDI 'SEC' Echo Canceler");
 MODULE_AUTHOR("Steve Underwood <steveu at coppice.org>");
 MODULE_LICENSE("GPL");
 
 module_init(mod_init);
 module_exit(mod_exit);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/dahdi_echocan_sec2.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_echocan_sec2.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_echocan_sec2.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_echocan_sec2.c Wed Sep  1 13:11:41 2010
@@ -354,36 +354,17 @@
 SYSCTL_NODE(_dahdi_echocan, OID_AUTO, sec2, CTLFLAG_RW, 0, "DAHDI 'SEC2' Echo Canceler");
 #define MODULE_PARAM_PREFIX "dahdi.echocan.sec2"
 #define MODULE_PARAM_PARENT _dahdi_echocan_sec2
-#endif
-
-module_param(debug, int, S_IRUGO | S_IWUSR);
-
-#if defined(__FreeBSD__)
-static int
-echocan_sec2_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	int res;
-
-	switch (type) {
-	case MOD_LOAD:
-		res = mod_init();
-		return (-res);
-	case MOD_UNLOAD:
-		mod_exit();
-		return (0);
-	default:
-		return (EOPNOTSUPP);
-	}
-}
-
-DAHDI_DEV_MODULE(dahdi_echocan_sec2, echocan_sec2_modevent, NULL);
+
+DAHDI_DEV_MODULE(dahdi_echocan_sec2);
 MODULE_VERSION(dahdi_echocan_sec2, 1);
 MODULE_DEPEND(dahdi_echocan_sec2, dahdi, 1, 1, 1);
-#else /* !__FreeBSD__ */
+#endif /* __FreeBSD__ */
+
+module_param(debug, int, S_IRUGO | S_IWUSR);
+
 MODULE_DESCRIPTION("DAHDI 'SEC2' Echo Canceler");
 MODULE_AUTHOR("Steve Underwood <steveu at coppice.org>");
 MODULE_LICENSE("GPL");
 
 module_init(mod_init);
 module_exit(mod_exit);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/dahdi_transcode.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi_transcode.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi_transcode.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi_transcode.c Wed Sep  1 13:11:41 2010
@@ -516,32 +516,14 @@
 SYSCTL_NODE(_dahdi, OID_AUTO, transcode, CTLFLAG_RW, 0, "DAHDI Transcoder Support");
 #define MODULE_PARAM_PREFIX "dahdi.transcode"
 #define MODULE_PARAM_PARENT _dahdi_transcode
-#endif /* __FreeBSD__ */
-
-module_param(debug, int, S_IRUGO | S_IWUSR);
-
-#if defined(__FreeBSD__)
-static int
-transcode_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	int res;
-
-	switch (type) {
-	case MOD_LOAD:
-		res = dahdi_transcode_init();
-		return (-res);
-	case MOD_UNLOAD:
-		dahdi_transcode_cleanup();
-		return (0);
-	default:
-		return (EOPNOTSUPP);
-	}
-}
-
-DAHDI_DEV_MODULE(dahdi_transcode, transcode_modevent, NULL);
+
+DAHDI_DEV_MODULE(dahdi_transcode);
 MODULE_VERSION(dahdi_transcode, 1);
 MODULE_DEPEND(dahdi_transcode, dahdi, 1, 1, 1);
-#else /* !__FreeBSD__ */
+#endif /* __FreeBSD__ */
+
+module_param(debug, int, S_IRUGO | S_IWUSR);
+
 MODULE_DESCRIPTION("DAHDI Transcoder Support");
 MODULE_AUTHOR("Mark Spencer <markster at digium.com>");
 #ifdef MODULE_LICENSE
@@ -550,4 +532,3 @@
 
 module_init(dahdi_transcode_init);
 module_exit(dahdi_transcode_cleanup);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/voicebus/voicebus.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/voicebus/voicebus.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/voicebus/voicebus.c (original)
+++ freebsd/trunk/drivers/dahdi/voicebus/voicebus.c Wed Sep  1 13:11:41 2010
@@ -2330,31 +2330,14 @@
 }
 
 #if defined(__FreeBSD__)
-static int
-dahdi_voicebus_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	int res;
-
-	switch (type) {
-	case MOD_LOAD:
-		res = voicebus_module_init();
-		return -res;
-	case MOD_UNLOAD:
-		voicebus_module_cleanup();
-		return 0;
-	default:
-		return EOPNOTSUPP;
-	}
-}
-
-DAHDI_DEV_MODULE(dahdi_voicebus, dahdi_voicebus_modevent, NULL);
+DAHDI_DEV_MODULE(dahdi_voicebus);
 MODULE_VERSION(dahdi_voicebus, 1);
 MODULE_DEPEND(dahdi_voicebus, dahdi, 1, 1, 1);
-#else /* !__FreeBSD__ */
+#endif /* __FreeBSD__ */
+
 MODULE_DESCRIPTION("Voicebus Interface w/VPMADT032 support");
 MODULE_AUTHOR("Digium Incorporated <support at digium.com>");
 MODULE_LICENSE("GPL");
 
 module_init(voicebus_module_init);
 module_exit(voicebus_module_cleanup);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c (original)
+++ freebsd/trunk/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c Wed Sep  1 13:11:41 2010
@@ -189,24 +189,7 @@
 #define MODULE_PARAM_PREFIX "dahdi.vpmadt032_loader"
 #define MODULE_PARAM_PARENT _dahdi_vpmadt032_loader
 
-static int
-dahdi_vpmadt032_loader_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	int res;
-
-	switch (type) {
-	case MOD_LOAD:
-		res = vpmadt032_loader_init();
-		return (-res);
-	case MOD_UNLOAD:
-		vpmadt032_loader_exit();
-		return (0);
-	default:
-		return (EOPNOTSUPP);
-	}
-}
-
-DAHDI_DEV_MODULE(dahdi_vpmadt032_loader, dahdi_vpmadt032_loader_modevent, NULL);
+DAHDI_DEV_MODULE(dahdi_vpmadt032_loader);
 MODULE_VERSION(dahdi_vpmadt032_loader, 1);
 MODULE_DEPEND(dahdi_vpmadt032_loader, dahdi, 1, 1, 1);
 MODULE_DEPEND(dahdi_vpmadt032_loader, dahdi_voicebus, 1, 1, 1);
@@ -214,11 +197,9 @@
 
 module_param(debug, int, S_IRUGO | S_IWUSR);
 
-#if !defined(__FreeBSD__)
 MODULE_DESCRIPTION("DAHDI VPMADT032 (Hardware Echo Canceller) Firmware Loader");
 MODULE_AUTHOR("Digium Incorporated <support at digium.com>");
 MODULE_LICENSE("Digium Commercial");
 
 module_init(vpmadt032_loader_init);
 module_exit(vpmadt032_loader_exit);
-#endif

Modified: freebsd/trunk/drivers/dahdi/wcb4xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wcb4xxp/base.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/wcb4xxp/base.c (original)
+++ freebsd/trunk/drivers/dahdi/wcb4xxp/base.c Wed Sep  1 13:11:41 2010
@@ -3170,7 +3170,7 @@
 
 static devclass_t b4xxp_devclass;
 
-DAHDI_DRIVER_MODULE(wcb4xxp, pci, b4xxp_pci_driver, b4xxp_devclass, 0, 0);
+DAHDI_DRIVER_MODULE(wcb4xxp, pci, b4xxp_pci_driver, b4xxp_devclass);
 MODULE_DEPEND(wcb4xxp, pci, 1, 1, 1);
 MODULE_DEPEND(wcb4xxp, dahdi, 1, 1, 1);
 
@@ -3324,7 +3324,6 @@
 module_param(timer_3_ms, int, S_IRUGO | S_IWUSR);
 module_param(companding, charp, S_IRUGO);
 
-#if !defined(__FreeBSD__)
 MODULE_PARM_DESC(debug, "bitmap: 1=general 2=dtmf 4=regops 8=fops 16=ec 32=st state 64=hdlc 128=alarm");
 MODULE_PARM_DESC(spanfilter, "debug filter for spans. bitmap: 1=port 1, 2=port 2, 4=port 3, 8=port 4");
 #ifdef LOOKBACK_SUPPORTED
@@ -3344,6 +3343,7 @@
 MODULE_DESCRIPTION("B410P & Similars multi-port BRI module driver.");
 MODULE_LICENSE("GPL");
 
+#if !defined(__FreeBSD__)
 MODULE_DEVICE_TABLE(pci, b4xx_ids);
 
 module_init(b4xx_init);

Modified: freebsd/trunk/drivers/dahdi/wcfxo.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wcfxo.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/wcfxo.c (original)
+++ freebsd/trunk/drivers/dahdi/wcfxo.c Wed Sep  1 13:11:41 2010
@@ -1333,7 +1333,7 @@
 
 static devclass_t wcfxo_devclass;
 
-DAHDI_DRIVER_MODULE(wcfxo, pci, wcfxo_pci_driver, wcfxo_devclass, 0, 0);
+DAHDI_DRIVER_MODULE(wcfxo, pci, wcfxo_pci_driver, wcfxo_devclass);
 MODULE_DEPEND(wcfxo, pci, 1, 1, 1);
 MODULE_DEPEND(wcfxo, dahdi, 1, 1, 1);
 #else /* !__FreeBSD__ */
@@ -1364,6 +1364,9 @@
 {
 	pci_unregister_driver(&wcfxo_driver);
 }
+
+module_init(wcfxo_init);
+module_exit(wcfxo_cleanup);
 #endif /* !__FreeBSD__ */
 
 module_param(debug, int, 0644);
@@ -1372,11 +1375,6 @@
 module_param(monitor, int, 0444);
 module_param(opermode, int, 0444);
 
-#if !defined(__FreeBSD__)
 MODULE_DESCRIPTION("Wildcard X100P Driver");
 MODULE_AUTHOR("Mark Spencer <markster at digium.com>");
 MODULE_LICENSE("GPL v2");
-
-module_init(wcfxo_init);
-module_exit(wcfxo_cleanup);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/wct4xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wct4xxp/base.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/wct4xxp/base.c (original)
+++ freebsd/trunk/drivers/dahdi/wct4xxp/base.c Wed Sep  1 13:11:41 2010
@@ -5132,7 +5132,7 @@
 
 static devclass_t t4_devclass;
 
-DAHDI_DRIVER_MODULE(wct4xxp, pci, t4_pci_driver, t4_devclass, 0, 0);
+DAHDI_DRIVER_MODULE(wct4xxp, pci, t4_pci_driver, t4_devclass);
 MODULE_DEPEND(wct4xxp, pci, 1, 1, 1);
 MODULE_DEPEND(wct4xxp, dahdi, 1, 1, 1);
 MODULE_DEPEND(wct4xxp, firmware, 1, 1, 1);

Modified: freebsd/trunk/drivers/dahdi/wctc4xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wctc4xxp/base.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/wctc4xxp/base.c (original)
+++ freebsd/trunk/drivers/dahdi/wctc4xxp/base.c Wed Sep  1 13:11:41 2010
@@ -4249,6 +4249,11 @@
 	sizeof(struct wcdte)
 };
 
+static devclass_t wctc4xxp_devclass;
+
+DAHDI_DRIVER_MODULE(wctc4xxp, pci, wctc4xxp_pci_driver, wctc4xxp_devclass);
+MODULE_DEPEND(wctc4xxp, dahdi, 1, 1, 1);
+MODULE_DEPEND(wctc4xxp, dahdi_transcode, 1, 1, 1);
 #else /* !__FreeBSD__ */
 MODULE_DEVICE_TABLE(pci, wctc4xxp_pci_tbl);
 
@@ -4313,30 +4318,6 @@
 module_param(debug, int, S_IRUGO | S_IWUSR);
 module_param(mode, charp, S_IRUGO | S_IWUSR);
 
-#if defined(__FreeBSD__)
-static devclass_t wctc4xxp_devclass;
-
-static int
-wctc4xxp_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	int res;
-
-	switch (type) {
-	case MOD_LOAD:
-		res = wctc4xxp_init();
-		return (-res);
-	case MOD_UNLOAD:
-		wctc4xxp_cleanup();
-		return (0);
-	default:
-		return (EOPNOTSUPP);
-	}
-}
-
-DAHDI_DRIVER_MODULE(wctc4xxp, pci, wctc4xxp_pci_driver, wctc4xxp_devclass, wctc4xxp_modevent, 0);
-MODULE_DEPEND(wctc4xxp, dahdi, 1, 1, 1);
-MODULE_DEPEND(wctc4xxp, dahdi_transcode, 1, 1, 1);
-#else /* !__FreeBSD__ */
 MODULE_PARM_DESC(mode, "'g729', 'g723.1', or 'any'.  Default 'any'.");
 MODULE_DESCRIPTION("Wildcard TC400P+TC400M Driver");
 MODULE_AUTHOR("Digium Incorporated <support at digium.com>");
@@ -4344,4 +4325,3 @@
 
 module_init(wctc4xxp_init);
 module_exit(wctc4xxp_cleanup);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/wctdm.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wctdm.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/wctdm.c (original)
+++ freebsd/trunk/drivers/dahdi/wctdm.c Wed Sep  1 13:11:41 2010
@@ -3112,7 +3112,7 @@
 
 static devclass_t wctdm_devclass;
 
-DAHDI_DRIVER_MODULE(wctdm, pci, wctdm_pci_driver, wctdm_devclass, 0, 0);
+DAHDI_DRIVER_MODULE(wctdm, pci, wctdm_pci_driver, wctdm_devclass);
 MODULE_DEPEND(wctdm, pci, 1, 1, 1);
 MODULE_DEPEND(wctdm, dahdi, 1, 1, 1);
 #else /* !__FreeBSD__ */
@@ -3145,6 +3145,9 @@
 {
 	pci_unregister_driver(&wctdm_driver);
 }
+
+module_init(wctdm_init);
+module_exit(wctdm_cleanup);
 #endif /* !__FreeBSD__ */
 
 module_param(debug, int, 0600);
@@ -3171,12 +3174,7 @@
 module_param(fxstxgain, int, 0600);
 module_param(fxsrxgain, int, 0600);
 
-#if !defined(__FreeBSD__)
 MODULE_DESCRIPTION("Wildcard TDM400P Driver");
 MODULE_AUTHOR("Mark Spencer <markster at digium.com>");
 MODULE_ALIAS("wcfxs");
 MODULE_LICENSE("GPL v2");
-
-module_init(wctdm_init);
-module_exit(wctdm_cleanup);
-#endif

Modified: freebsd/trunk/drivers/dahdi/wctdm24xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/wctdm24xxp/base.c (original)
+++ freebsd/trunk/drivers/dahdi/wctdm24xxp/base.c Wed Sep  1 13:11:41 2010
@@ -5474,23 +5474,6 @@
 	return (0);
 }
 
-static int
-wctdm_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	int res;
-
-	switch (type) {
-	case MOD_LOAD:
-		res = wctdm_init();
-		return (-res);
-	case MOD_UNLOAD:
-		wctdm_cleanup();
-		return (0);
-	default:
-		return (EOPNOTSUPP);
-	}
-}
-
 static device_method_t wctdm_methods[] = {
 	DEVMETHOD(device_probe,     wctdm_device_probe),
 	DEVMETHOD(device_attach,    wctdm_device_attach),
@@ -5506,12 +5489,13 @@
 
 static devclass_t wctdm_devclass;
 
-DAHDI_DRIVER_MODULE(wctdm24xxp, pci, wctdm_pci_driver, wctdm_devclass, wctdm_modevent, 0);
+DAHDI_DRIVER_MODULE(wctdm24xxp, pci, wctdm_pci_driver, wctdm_devclass);
 MODULE_DEPEND(wctdm24xxp, pci, 1, 1, 1);
 MODULE_DEPEND(wctdm24xxp, dahdi, 1, 1, 1);
 MODULE_DEPEND(wctdm24xxp, dahdi_voicebus, 1, 1, 1);
 MODULE_DEPEND(wctdm24xxp, firmware, 1, 1, 1);
-#else
+#endif /* __FreeBSD__ */
+
 MODULE_DESCRIPTION("VoiceBus Driver for Wildcard Analog and Hybrid Cards");
 MODULE_AUTHOR("Digium Incorporated <support at digium.com>");
 MODULE_ALIAS("wctdm8xxp");
@@ -5523,4 +5507,3 @@
 
 module_init(wctdm_init);
 module_exit(wctdm_cleanup);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/wcte11xp.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wcte11xp.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/wcte11xp.c (original)
+++ freebsd/trunk/drivers/dahdi/wcte11xp.c Wed Sep  1 13:11:41 2010
@@ -1860,7 +1860,7 @@
 
 static devclass_t t1xxp_devclass;
 
-DAHDI_DRIVER_MODULE(t1xxp, pci, t1xxp_pci_driver, t1xxp_devclass, 0, 0);
+DAHDI_DRIVER_MODULE(t1xxp, pci, t1xxp_pci_driver, t1xxp_devclass);
 MODULE_DEPEND(t1xxp, pci, 1, 1, 1);
 MODULE_DEPEND(t1xxp, dahdi, 1, 1, 1);
 #else /* !__FreeBSD__ */
@@ -1898,11 +1898,11 @@
 module_param(debug, int, 0600);
 module_param(j1mode, int, 0600);
 
-#if !defined(__FreeBSD__)
 MODULE_DESCRIPTION("Wildcard TE110P Driver");
 MODULE_AUTHOR("Mark Spencer <markster at digium.com>");
 MODULE_LICENSE("GPL v2");
 
+#if !defined(__FreeBSD__)
 module_init(t1xxp_init);
 module_exit(t1xxp_cleanup);
 #endif /* !__FreeBSD__ */

Modified: freebsd/trunk/drivers/dahdi/wcte12xp/base.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/wcte12xp/base.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/drivers/dahdi/wcte12xp/base.c (original)
+++ freebsd/trunk/drivers/dahdi/wcte12xp/base.c Wed Sep  1 13:11:41 2010
@@ -2533,20 +2533,6 @@
 	uma_zdestroy(cmd_cache);
 }
 
-static int
-te12xp_modevent(module_t mod __unused, int type, void *data __unused)
-{
-	switch (type) {
-	case MOD_LOAD:
-		return te12xp_init();
-	case MOD_UNLOAD:
-		te12xp_cleanup();
-		return (0);
-	default:
-		return (EOPNOTSUPP);
-	}
-}
-
 static device_method_t te12xp_methods[] = {
 	DEVMETHOD(device_probe,     te12xp_device_probe),
 	DEVMETHOD(device_attach,    te12xp_device_attach),
@@ -2562,7 +2548,7 @@
 
 static devclass_t te12xp_devclass;
 
-DAHDI_DRIVER_MODULE(te12xp, pci, te12xp_pci_driver, te12xp_devclass, te12xp_modevent, 0);
+DAHDI_DRIVER_MODULE(te12xp, pci, te12xp_pci_driver, te12xp_devclass);
 MODULE_DEPEND(te12xp, pci, 1, 1, 1);
 MODULE_DEPEND(te12xp, dahdi, 1, 1, 1);
 MODULE_DEPEND(te12xp, dahdi_voicebus, 1, 1, 1);
@@ -2640,11 +2626,9 @@
 module_param(vpmnlpmaxsupp, int, S_IRUGO);
 #endif
 
-#if !defined(__FreeBSD__)
 MODULE_DESCRIPTION("Wildcard VoiceBus Digital Card Driver");
 MODULE_AUTHOR("Digium Incorporated <support at digium.com>");
 MODULE_LICENSE("GPL v2");
 
 module_init(te12xp_init);
 module_exit(te12xp_cleanup);
-#endif /* !__FreeBSD__ */

Modified: freebsd/trunk/freebsd/dahdi/bsd-compat.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/freebsd/dahdi/bsd-compat.c?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/freebsd/dahdi/bsd-compat.c (original)
+++ freebsd/trunk/freebsd/dahdi/bsd-compat.c Wed Sep  1 13:11:41 2010
@@ -376,6 +376,24 @@
  * Kernel module API
  */
 int
+try_module_get(struct module *m)
+{
+	atomic_inc(&m->refcount);
+	return (0);
+}
+
+void module_put(struct module *m)
+{
+	atomic_dec(&m->refcount);
+}
+
+void _module_ptr_sysinit(void *arg)
+{
+	struct module_ptr_args *args = (struct module_ptr_args *) arg;
+	*args->pfield = args->value;
+}
+
+int
 request_module(const char *fmt, ...)
 {
 	va_list ap;

Modified: freebsd/trunk/include/dahdi/compat/bsd.h
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/include/dahdi/compat/bsd.h?view=diff&rev=9249&r1=9248&r2=9249
==============================================================================
--- freebsd/trunk/include/dahdi/compat/bsd.h (original)
+++ freebsd/trunk/include/dahdi/compat/bsd.h Wed Sep  1 13:11:41 2010
@@ -413,27 +413,77 @@
 #define __devexit
 #define __devinitdata
 
-#define try_module_get(m)	(1)
-#define module_put(m)		((void) (m))
-
 struct module {
 	const char *name;
-};
+	const char *description;
+	const char *author;
+	const char *license;
+	atomic_t refcount;
+	int (*init)(void);
+	void (*exit)(void);
+};
+
+int try_module_get(struct module *);
+void module_put(struct module *);
 
 extern struct module _this_module;
 
 #define THIS_MODULE (&_this_module)
 
-#define DAHDI_MODULE(name)				\
+#define _DAHDI_MODULE_EVH(name)	__CONCAT(name, _modevent)
+#define _DAHDI_MODULE(name)						\
+	static int							\
+	_DAHDI_MODULE_EVH(name)(module_t mod, int type, void *data)	\
+	{								\
+		int res = 0;						\
+									\
+		switch (type) {						\
+		case MOD_LOAD:						\
+			if (THIS_MODULE->init)				\
+				res = THIS_MODULE->init();		\
+			return (-res);					\
+		case MOD_UNLOAD:					\
+			if (atomic_read(&(THIS_MODULE->refcount)))	\
+				return (EBUSY);				\
+			if (THIS_MODULE->exit)				\
+				THIS_MODULE->exit();			\
+			return (0);					\
+		default:						\
+			return (EOPNOTSUPP);				\
+		}							\
+	}								\
 	struct module _this_module = { #name }
 
-#define DAHDI_DEV_MODULE(name, evh, arg)		\
-	DEV_MODULE(name, evh, arg);			\
-	DAHDI_MODULE(name)
-
-#define DAHDI_DRIVER_MODULE(name, busname, driver, devclass, evh, arg)	\
-	DRIVER_MODULE(name, busname, driver, devclass, evh, arg);	\
-	DAHDI_MODULE(name)
+#define DAHDI_DEV_MODULE(name)						\
+	_DAHDI_MODULE(name);						\
+	DEV_MODULE(name, _DAHDI_MODULE_EVH(name), 0)
+
+#define DAHDI_DRIVER_MODULE(name, busname, driver, devclass)		\
+	_DAHDI_MODULE(name);						\
+	DRIVER_MODULE(name, busname, driver, devclass, _DAHDI_MODULE_EVH(name), 0);
+
+struct module_ptr_args {
+	const void **pfield;
+	void *value;
+};
+
+void _module_ptr_sysinit(void *arg);
+
+#define _module_ptr_args	__CONCAT(_module_ptr_args_, __LINE__)
+#define _module_ptr_init(field, val)					\
+	static struct module_ptr_args _module_ptr_args = {		\
+		(const void **) &(THIS_MODULE->field), val		\
+	};								\
+	SYSINIT(__CONCAT(_module_ptr_args, _init),			\
+		SI_SUB_KLD, SI_ORDER_FIRST,				\
+		_module_ptr_sysinit, &_module_ptr_args)
+
+#define module_init(f)		_module_ptr_init(init, f)
+#define module_exit(f)		_module_ptr_init(exit, f)
+#define MODULE_DESCRIPTION(s)	_module_ptr_init(description, s)
+#define MODULE_AUTHOR(s)	_module_ptr_init(author, s)
+#define MODULE_LICENSE(s)	_module_ptr_init(license, s)
+#define MODULE_ALIAS(n)
 
 int request_module(const char *fmt, ...);
 




More information about the svn-commits mailing list