diff options
Diffstat (limited to 'drivers/media/video/samsung/mali/linux/mali_osk_locks.c')
-rw-r--r-- | drivers/media/video/samsung/mali/linux/mali_osk_locks.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/drivers/media/video/samsung/mali/linux/mali_osk_locks.c b/drivers/media/video/samsung/mali/linux/mali_osk_locks.c index d007d93..ee857d5 100644 --- a/drivers/media/video/samsung/mali/linux/mali_osk_locks.c +++ b/drivers/media/video/samsung/mali/linux/mali_osk_locks.c @@ -13,12 +13,19 @@ * Implemenation of the OS abstraction layer for the kernel device driver */ +/* needed to detect kernel version specific code */ +#include <linux/version.h> + #include <linux/spinlock.h> #include <linux/rwsem.h> -#include <linux/mutex.h> -#include <linux/slab.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) +#include <linux/semaphore.h> +#else /* pre 2.6.26 the file was in the arch specific location */ +#include <asm/semaphore.h> +#endif +#include <linux/slab.h> #include "mali_osk.h" #include "mali_kernel_common.h" @@ -27,9 +34,9 @@ typedef enum { _MALI_OSK_INTERNAL_LOCKTYPE_SPIN, /* Mutex, implicitly non-interruptable, use spin_lock/spin_unlock */ _MALI_OSK_INTERNAL_LOCKTYPE_SPIN_IRQ, /* Mutex, IRQ version of spinlock, use spin_lock_irqsave/spin_unlock_irqrestore */ - _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX, /* Interruptable, use mutex_unlock()/down_interruptable() */ - _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT, /* Non-Interruptable, use mutex_unlock()/down() */ - _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW, /* Non-interruptable, Reader/Writer, use {mutex_unlock,down}{read,write}() */ + _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX, /* Interruptable, use up()/down_interruptable() */ + _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT, /* Non-Interruptable, use up()/down() */ + _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW, /* Non-interruptable, Reader/Writer, use {up,down}{read,write}() */ /* Linux supports, but we do not support: * Non-Interruptable Reader/Writer spinlock mutexes - RW optimization will be switched off @@ -48,7 +55,7 @@ struct _mali_osk_lock_t_struct union { spinlock_t spinlock; - struct mutex mutex; + struct semaphore sema; struct rw_semaphore rw_sema; } obj; MALI_DEBUG_CODE( @@ -125,7 +132,7 @@ _mali_osk_lock_t *_mali_osk_lock_init( _mali_osk_lock_flags_t flags, u32 initial } /* Initially unlocked */ - mutex_init(&lock->obj.mutex); + sema_init( &lock->obj.sema, 1 ); } #ifdef DEBUG @@ -187,7 +194,7 @@ _mali_osk_errcode_t _mali_osk_lock_wait( _mali_osk_lock_t *lock, _mali_osk_lock_ break; case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX: - if (mutex_lock_interruptible(&lock->obj.mutex)) + if ( down_interruptible(&lock->obj.sema) ) { MALI_PRINT_ERROR(("Can not lock mutex\n")); err = _MALI_OSK_ERR_RESTARTSYSCALL; @@ -195,7 +202,7 @@ _mali_osk_errcode_t _mali_osk_lock_wait( _mali_osk_lock_t *lock, _mali_osk_lock_ break; case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT: - mutex_lock(&lock->obj.mutex); + down(&lock->obj.sema); break; case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW: @@ -301,7 +308,7 @@ void _mali_osk_lock_signal( _mali_osk_lock_t *lock, _mali_osk_lock_mode_t mode ) case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX: /* FALLTHROUGH */ case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT: - mutex_unlock(&lock->obj.mutex); + up(&lock->obj.sema); break; case _MALI_OSK_INTERNAL_LOCKTYPE_MUTEX_NONINT_RW: |