#include #include #include #include #include #include #include #include "defines.h" #include "ksync.h" ///////////////////////////////////////////////////////////////////////////// static DEFINE_MUTEX(g_mtxSync); static DEFINE_MUTEX(g_mtxSPI); ///////////////////////////////////////////////////////////////////////////// void ksync_lock(void) { mutex_lock(&g_mtxSync); } ///////////////////////////////////////////////////////////////////////////// void ksync_unlock(void) { mutex_unlock(&g_mtxSync); } ///////////////////////////////////////////////////////////////////////////// int ksync_sleep_jiffies(long jiffies) { if(jiffies <= 0) return 0; set_current_state(TASK_INTERRUPTIBLE); // may return early if a signal is delivered to the current task return schedule_timeout(jiffies); } ///////////////////////////////////////////////////////////////////////////// int ksync_sleep_ms(long ms) { return ksync_sleep_jiffies(msecs_to_jiffies(ms)); } ///////////////////////////////////////////////////////////////////////////// void kfile_lock(void) { mutex_lock(&g_mtxSPI); } ///////////////////////////////////////////////////////////////////////////// void kfile_unlock(void) { mutex_unlock(&g_mtxSPI); }