Define static kmutex_t

2012-01-15 Thread Emmanuel Dreyfus
Another DAHDI porting caveat. They use stuff like this to define a
static kmutex_t outside any function:

static DEFINE_SPINLOCK(pseudo_free_list_lock);

NetBSD needs to do this in order to initialize a mutex:

static kmutex_t pseudo_free_list_lock;
mutex_init(pseudo_free_list_lock, MUTEX_SPIN, IPL_NET)

There is no way to make this fit together, right? As I understand I need
to run a driver initilization hook to call mutex_init for all mutexes
that are defined this way in the drivers (I cound 12 occurences).

Am I correct? There Is No Alternatrive?

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
m...@netbsd.org


Re: Define static kmutex_t

2012-01-15 Thread Mindaugas Rasiukevicius
m...@netbsd.org (Emmanuel Dreyfus) wrote:
 Another DAHDI porting caveat. They use stuff like this to define a
 static kmutex_t outside any function:
 
 static DEFINE_SPINLOCK(pseudo_free_list_lock);
 
 NetBSD needs to do this in order to initialize a mutex:
 
 static kmutex_t pseudo_free_list_lock;
 mutex_init(pseudo_free_list_lock, MUTEX_SPIN, IPL_NET)
 
 There is no way to make this fit together, right? As I understand I need
 to run a driver initilization hook to call mutex_init for all mutexes
 that are defined this way in the drivers (I cound 12 occurences).

Right.  Use MUTEX_DEFAULT (instead of MUTEX_SPIN or other), though.
One also needs to mutex_destroy(9) the lock on driver detach/unload.

-- 
Mindaugas