]>
Commit | Line | Data |
---|---|---|
cf3e6881 AB |
1 | /****************************************************************************** |
2 | * | |
3 | * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms of version 2 of the GNU General Public License as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along with | |
15 | * this program; if not, write to the Free Software Foundation, Inc., | |
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA | |
17 | * | |
18 | * Modifications for inclusion into the Linux staging tree are | |
19 | * Copyright(c) 2010 Larry Finger. All rights reserved. | |
20 | * | |
21 | * Contact information: | |
22 | * WLAN FAE <wlanfae@realtek.com> | |
23 | * Larry Finger <Larry.Finger@lwfinger.net> | |
24 | * | |
25 | ******************************************************************************/ | |
2865d42c LF |
26 | #ifndef __OSDEP_SERVICE_H_ |
27 | #define __OSDEP_SERVICE_H_ | |
28 | ||
29 | #define _SUCCESS 1 | |
30 | #define _FAIL 0 | |
31 | ||
2865d42c | 32 | #include <linux/spinlock.h> |
359140aa AB |
33 | |
34 | #include <linux/interrupt.h> | |
2865d42c | 35 | #include <linux/semaphore.h> |
359140aa | 36 | #include <linux/sched.h> |
2865d42c LF |
37 | #include <linux/sem.h> |
38 | #include <linux/netdevice.h> | |
39 | #include <linux/etherdevice.h> | |
40 | #include <net/iw_handler.h> | |
359140aa AB |
41 | #include <linux/proc_fs.h> /* Necessary because we use the proc fs */ |
42 | ||
43 | #include "basic_types.h" | |
2865d42c LF |
44 | |
45 | struct __queue { | |
46 | struct list_head queue; | |
47 | spinlock_t lock; | |
48 | }; | |
49 | ||
50 | #define _pkt struct sk_buff | |
51 | #define _buffer unsigned char | |
52 | #define thread_exit() complete_and_exit(NULL, 0) | |
2865d42c LF |
53 | |
54 | #define _init_queue(pqueue) \ | |
55 | do { \ | |
534c4acd | 56 | INIT_LIST_HEAD(&((pqueue)->queue)); \ |
2865d42c LF |
57 | spin_lock_init(&((pqueue)->lock)); \ |
58 | } while (0) | |
59 | ||
2865d42c LF |
60 | #define LIST_CONTAINOR(ptr, type, member) \ |
61 | ((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member))) | |
62 | ||
2865d42c LF |
63 | #ifndef BIT |
64 | #define BIT(x) (1 << (x)) | |
65 | #endif | |
66 | ||
2865d42c LF |
67 | static inline u32 _down_sema(struct semaphore *sema) |
68 | { | |
69 | if (down_interruptible(sema)) | |
70 | return _FAIL; | |
14ad732c | 71 | return _SUCCESS; |
2865d42c LF |
72 | } |
73 | ||
9ab3726b AO |
74 | static inline u32 end_of_queue_search(struct list_head *head, |
75 | struct list_head *plist) | |
2865d42c | 76 | { |
14ad732c | 77 | return (head == plist); |
2865d42c LF |
78 | } |
79 | ||
80 | static inline void sleep_schedulable(int ms) | |
81 | { | |
82 | u32 delta; | |
83 | ||
7dfb6d2e | 84 | delta = msecs_to_jiffies(ms);/*(ms)*/ |
2865d42c | 85 | set_current_state(TASK_INTERRUPTIBLE); |
1ba2c5a8 | 86 | schedule_timeout(delta); |
2865d42c LF |
87 | } |
88 | ||
2865d42c LF |
89 | static inline void flush_signals_thread(void) |
90 | { | |
91 | if (signal_pending(current)) | |
92 | flush_signals(current); | |
93 | } | |
94 | ||
2865d42c LF |
95 | #endif |
96 |