diff options
author | grehan <grehan@FreeBSD.org> | 2005-08-07 02:20:35 +0000 |
---|---|---|
committer | grehan <grehan@FreeBSD.org> | 2005-08-07 02:20:35 +0000 |
commit | 449d4474b42c2ce47f7067f0435eb71eda24bd52 (patch) | |
tree | c6f2d035295a4e129e1efa946edb3848af5c7b89 | |
parent | 8b2c1e15345135ba0259b951654653fa73c718fb (diff) | |
download | FreeBSD-src-449d4474b42c2ce47f7067f0435eb71eda24bd52.zip FreeBSD-src-449d4474b42c2ce47f7067f0435eb71eda24bd52.tar.gz |
Export a routine, kobj_machdep_init(), that allows platforms
to use the kobj subsystem as soon at mutex_init() has been called
instead of having to wait for the SI_SUB_LOCK sysinit.
Reviewed by: dfr
-rw-r--r-- | sys/kern/subr_kobj.c | 13 | ||||
-rw-r--r-- | sys/sys/kobj.h | 5 |
2 files changed, 16 insertions, 2 deletions
diff --git a/sys/kern/subr_kobj.c b/sys/kern/subr_kobj.c index 1704a0f..b8528fa 100644 --- a/sys/kern/subr_kobj.c +++ b/sys/kern/subr_kobj.c @@ -57,6 +57,7 @@ SYSCTL_UINT(_kern, OID_AUTO, kobj_misses, CTLFLAG_RD, #endif static struct mtx kobj_mtx; +static int kobj_mutex_inited; static int kobj_next_id = 1; SYSCTL_UINT(_kern, OID_AUTO, kobj_methodcount, CTLFLAG_RD, @@ -65,12 +66,20 @@ SYSCTL_UINT(_kern, OID_AUTO, kobj_methodcount, CTLFLAG_RD, static void kobj_init_mutex(void *arg) { - - mtx_init(&kobj_mtx, "kobj", NULL, MTX_DEF); + if (!kobj_mutex_inited) { + mtx_init(&kobj_mtx, "kobj", NULL, MTX_DEF); + kobj_mutex_inited = 1; + } } SYSINIT(kobj, SI_SUB_LOCK, SI_ORDER_ANY, kobj_init_mutex, NULL); +void +kobj_machdep_init(void) +{ + kobj_init_mutex(NULL); +} + /* * This method structure is used to initialise new caches. Since the * desc pointer is NULL, it is guaranteed never to match any read diff --git a/sys/sys/kobj.h b/sys/sys/kobj.h index d2cd0da..86788e5 100644 --- a/sys/sys/kobj.h +++ b/sys/sys/kobj.h @@ -246,4 +246,9 @@ kobj_method_t* kobj_lookup_method(kobj_class_t cls, */ int kobj_error_method(void); +/* + * Machine-dependent initialisation call for boot-time kobj clients + */ +void kobj_machdep_init(void); + #endif /* !_SYS_KOBJ_H_ */ |