For all the spinlock APIs, you must include the relevant header file; that is, include <linux/spinlock.h>.
Similar to the mutex lock, you must declare and initialize the spinlock to the unlocked state before use. The spinlock is an "object" that's declared via the typedef data type named spinlock_t (internally, it's a structure defined in include/linux/spinlock_types.h). It can be initialized dynamically via the spin_lock_init() macro:
spinlock_t lock;
spin_lock_init(&lock);
Alternatively, this can be performed statically (declared and initialized) with DEFINE_SPINLOCK(lock);.
As with the mutex, declaring a spinlock within the (global/static) data structure is meant to protect against concurrent access, and is typically a very good idea. As we mentioned earlier, this very idea is made use of within the kernel often; as an example, the data structure representing an open file on the Linux kernel...