spin_lock_irq is a kernel-space macro, and cannot be used from inside a user-space program (as far as I know).
A user-space program cannot disable hardware interrupts, as to do so would prevent any other programs or drivers from receiving any generated interrupts. Spinlocks do not context-shift, so they're only really useful on multi-processor systems when blocking for short periods of time; otherwise, you want to use a semaphore.
Also, you should probably be using spin_lock_irqsave rather than spin_lock_irq to save the interrupt state (see
http://www.ussg.iu.edu/hypermail/lin...06.2/0310.html)