Search

error: ‘SPIN_LOCK_UNLOCKED’ undeclared here (not in a function)

While writing a kernel module using the spin locks in linux, we might hit the error



This might happen if we are trying to compile the module for kernel version below 3.0 Because before kernel version 3.0 SPIN_LOCK_UNLOCKED was defined in spinlock.h



But this definition is no longer available, and is replaced by DEFINE_SPINLOCK in spinlock_types.h



Thus in the module remove the initialization with SPIN_LOCK_UNLOCKED and add the macro DEFINE_SPINLOCK to get around the error.

Follow by Email