Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where has init_MUTEX gone in linux kernel version 3.2?

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?

like image 336
Douglas Su Avatar asked Jan 06 '15 15:01

Douglas Su


People also ask

Where can I find Linux kernel source code?

The current Linux source code is always available in both a complete tarball (an archive created with the tar command) and an incremental patch from the official home of the Linux kernel, http://www.kernel.org.

What is the current version of Linux kernel?

The Linux kernel 5.7 is finally here as the latest stable version of kernel for Unix-like operating systems. The new kernel comes with many significant updates and new features.

How do I find my old Linux kernel version?

To check which kernel is currently running on your system, use the uname command with the “release” or -r switch. This will output the kernel version (release) number.


2 Answers

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}()
like image 137
askb Avatar answered Sep 24 '22 20:09

askb


Use mutex_init() instead:

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

mutex_init(&(lptr->device.mutex));
like image 27
CL. Avatar answered Sep 25 '22 20:09

CL.