5
votes

I am following the Linux Device Drivers (3rd edition). When I try to imitate the scull example in chapter 6 , an error is reported. It says that:

    error: implicit declaration of function ‘init_MUTEX’ [-Werror=implicit-function-declaration]

Can anyone tell me where has init_MUTEX gone? By the way, Is there a list that I can check all the kernel API changes?

2
My development platform is Debian wheezy with kernel version 3.2.0-4. I know that the examples in this book is targeting at kernel 2.6. But I want to try all the instances in kernel 3.2 for studying.Douglas Su
The old semaphore-based mutexes were replaced by the new Mutex API like others said. Look at Documentation/locking/mutex-design.txt for more infos.tux3

2 Answers

7
votes

init_MUTEX{_LOCKED}() was initially implemented as a semaphore. Semaphores were only in older 2.6.16 kernels, now mutex replace with earlier semaphores implementation, check the below api's and linux/mutex.h header

struct mutex { ...
};

mutex_{init,lock,trylock,unlock,lock_interruptible}()
2
votes

Use mutex_init() instead:

struct scull_pipe {
    ...
    struct mutex mutex;
    ...
};

mutex_init(&(lptr->device.mutex));