]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/staging/wilc1000/wilc_semaphore.c
staging: wilc1000: simplify semaphore wrapper
[karo-tx-linux.git] / drivers / staging / wilc1000 / wilc_semaphore.c
1
2 #include "wilc_oswrapper.h"
3
4 WILC_ErrNo WILC_SemaphoreCreate(WILC_SemaphoreHandle *pHandle,
5                                 tstrWILC_SemaphoreAttrs *pstrAttrs)
6 {
7         tstrWILC_SemaphoreAttrs strDefaultAttrs;
8         if (pstrAttrs == WILC_NULL) {
9                 WILC_SemaphoreFillDefault(&strDefaultAttrs);
10                 pstrAttrs = &strDefaultAttrs;
11         }
12
13         sema_init(pHandle, pstrAttrs->u32InitCount);
14         return WILC_SUCCESS;
15
16 }
17
18
19 WILC_ErrNo WILC_SemaphoreDestroy(WILC_SemaphoreHandle *pHandle,
20                                  tstrWILC_SemaphoreAttrs *pstrAttrs)
21 {
22         /* nothing to be done ! */
23
24         return WILC_SUCCESS;
25
26 }
27
28
29 WILC_ErrNo WILC_SemaphoreAcquire(WILC_SemaphoreHandle *pHandle,
30                                  tstrWILC_SemaphoreAttrs *pstrAttrs)
31 {
32         WILC_ErrNo s32RetStatus = WILC_SUCCESS;
33
34         while (down_interruptible(pHandle))
35                 ;
36
37         if (s32RetStatus == 0) {
38                 return WILC_SUCCESS;
39         } else if (s32RetStatus == -ETIME)   {
40                 return WILC_TIMEOUT;
41         } else {
42                 return WILC_FAIL;
43         }
44
45         return WILC_SUCCESS;
46
47 }
48
49 WILC_ErrNo WILC_SemaphoreRelease(WILC_SemaphoreHandle *pHandle,
50                                  tstrWILC_SemaphoreAttrs *pstrAttrs)
51 {
52
53         up(pHandle);
54         return WILC_SUCCESS;
55
56 }