1 /******************************************************************************
3 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
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.
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
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
18 * Modifications for inclusion into the Linux staging tree are
19 * Copyright(c) 2010 Larry Finger. All rights reserved.
21 * Contact information:
22 * WLAN FAE <wlanfae@realtek.com>
23 * Larry Finger <Larry.Finger@lwfinger.net>
25 ******************************************************************************/
26 #ifndef __OSDEP_SERVICE_H_
27 #define __OSDEP_SERVICE_H_
32 #include <linux/spinlock.h>
34 #include <linux/interrupt.h>
35 #include <linux/semaphore.h>
36 #include <linux/sched.h>
37 #include <linux/sem.h>
38 #include <linux/netdevice.h>
39 #include <linux/etherdevice.h>
40 #include <net/iw_handler.h>
41 #include <linux/proc_fs.h> /* Necessary because we use the proc fs */
43 #include "basic_types.h"
46 struct list_head queue;
50 #define _pkt struct sk_buff
51 #define _buffer unsigned char
52 #define thread_exit() complete_and_exit(NULL, 0)
54 #define _init_queue(pqueue) \
56 INIT_LIST_HEAD(&((pqueue)->queue)); \
57 spin_lock_init(&((pqueue)->lock)); \
60 #define LIST_CONTAINOR(ptr, type, member) \
61 ((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
63 static inline void _init_timer(struct timer_list *ptimer,
64 struct net_device *padapter,
65 void *pfunc, void *cntx)
67 ptimer->function = pfunc;
68 ptimer->data = (addr_t)cntx;
72 static inline void _set_timer(struct timer_list *ptimer, u32 delay_time)
74 mod_timer(ptimer, (jiffies+(delay_time*HZ/1000)));
77 static inline void _cancel_timer(struct timer_list *ptimer, u8 *bcancelled)
80 *bcancelled = true; /*true ==1; false==0*/
84 #define BIT(x) (1 << (x))
87 static inline u32 _down_sema(struct semaphore *sema)
89 if (down_interruptible(sema))
95 static inline u32 end_of_queue_search(struct list_head *head,
96 struct list_head *plist)
104 static inline void sleep_schedulable(int ms)
108 delta = (ms * HZ) / 1000;/*(ms)*/
111 set_current_state(TASK_INTERRUPTIBLE);
112 if (schedule_timeout(delta) != 0)
116 static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer)
118 return del_timer(ptimer);
121 static inline void flush_signals_thread(void)
123 if (signal_pending(current))
124 flush_signals(current);