staging: csr: remove CsrMutexLock function
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / csr / csr_framework_ext.c
1 /*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
4 All rights reserved and confidential information of CSR
5
6 Refer to LICENSE.txt included with this source for details
7 on the license terms.
8
9 *****************************************************************************/
10
11 #include <linux/kernel.h>
12 #include <linux/kthread.h>
13 #include <linux/module.h>
14 #include <linux/freezer.h>
15 #include <linux/semaphore.h>
16 #include <linux/slab.h>
17 #include <linux/bitops.h>
18
19 #include "csr_framework_ext.h"
20 #include "csr_panic.h"
21
22 /*----------------------------------------------------------------------------*
23 * NAME
24 * CsrMutexCreate
25 *
26 * DESCRIPTION
27 * Create a mutex and return a handle to the created mutex.
28 *
29 * RETURNS
30 * Possible values:
31 * CSR_RESULT_SUCCESS in case of success
32 * CSR_FE_RESULT_NO_MORE_MUTEXES in case of out of mutex resources
33 * CSR_FE_RESULT_INVALID_POINTER in case the mutexHandle pointer is invalid
34 *
35 *----------------------------------------------------------------------------*/
36 CsrResult CsrMutexCreate(CsrMutexHandle *mutexHandle)
37 {
38 if (mutexHandle == NULL)
39 {
40 return CSR_FE_RESULT_INVALID_POINTER;
41 }
42
43 sema_init(mutexHandle, 1);
44
45 return CSR_RESULT_SUCCESS;
46 }
47
48 /*----------------------------------------------------------------------------*
49 * NAME
50 * CsrMutexDestroy
51 *
52 * DESCRIPTION
53 * Destroy the previously created mutex.
54 *
55 * RETURNS
56 * void
57 *
58 *----------------------------------------------------------------------------*/
59 void CsrMutexDestroy(CsrMutexHandle *mutexHandle)
60 {
61 }
62
63 /*----------------------------------------------------------------------------*
64 * NAME
65 * CsrMutexUnlock
66 *
67 * DESCRIPTION
68 * Unlock the mutex refered to by the provided handle.
69 *
70 * RETURNS
71 * Possible values:
72 * CSR_RESULT_SUCCESS in case of success
73 * CSR_FE_RESULT_INVALID_HANDLE in case the mutexHandle is invalid
74 *
75 *----------------------------------------------------------------------------*/
76 CsrResult CsrMutexUnlock(CsrMutexHandle *mutexHandle)
77 {
78 if (mutexHandle == NULL)
79 {
80 return CSR_FE_RESULT_INVALID_POINTER;
81 }
82
83 up(mutexHandle);
84
85 return CSR_RESULT_SUCCESS;
86 }
87
88 /*----------------------------------------------------------------------------*
89 * NAME
90 * CsrThreadSleep
91 *
92 * DESCRIPTION
93 * Sleep for a given period.
94 *
95 * RETURNS
96 * void
97 *
98 *----------------------------------------------------------------------------*/
99 void CsrThreadSleep(u16 sleepTimeInMs)
100 {
101 unsigned long t;
102
103 /* Convert t in ms to jiffies and round up */
104 t = ((sleepTimeInMs * HZ) + 999) / 1000;
105 schedule_timeout_uninterruptible(t);
106 }
107 EXPORT_SYMBOL_GPL(CsrThreadSleep);