1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef __RSI_COMMON_H__
18#define __RSI_COMMON_H__
19
20#include <linux/kthread.h>
21
22#define EVENT_WAIT_FOREVER 0
23#define TA_LOAD_ADDRESS 0x00
24#define FIRMWARE_RSI9113 "rsi_91x.fw"
25#define QUEUE_NOT_FULL 1
26#define QUEUE_FULL 0
27
28static inline int rsi_init_event(struct rsi_event *pevent)
29{
30 atomic_set(&pevent->event_condition, 1);
31 init_waitqueue_head(&pevent->event_queue);
32 return 0;
33}
34
35static inline int rsi_wait_event(struct rsi_event *event, u32 timeout)
36{
37 int status = 0;
38
39 if (!timeout)
40 status = wait_event_interruptible(event->event_queue,
41 (atomic_read(&event->event_condition) == 0));
42 else
43 status = wait_event_interruptible_timeout(event->event_queue,
44 (atomic_read(&event->event_condition) == 0),
45 timeout);
46 return status;
47}
48
49static inline void rsi_set_event(struct rsi_event *event)
50{
51 atomic_set(&event->event_condition, 0);
52 wake_up_interruptible(&event->event_queue);
53}
54
55static inline void rsi_reset_event(struct rsi_event *event)
56{
57 atomic_set(&event->event_condition, 1);
58}
59
60static inline int rsi_create_kthread(struct rsi_common *common,
61 struct rsi_thread *thread,
62 void *func_ptr,
63 u8 *name)
64{
65 init_completion(&thread->completion);
66 thread->task = kthread_run(func_ptr, common, "%s", name);
67 if (IS_ERR(thread->task))
68 return (int)PTR_ERR(thread->task);
69
70 return 0;
71}
72
73static inline int rsi_kill_thread(struct rsi_thread *handle)
74{
75 atomic_inc(&handle->thread_done);
76 rsi_set_event(&handle->event);
77
78 wait_for_completion(&handle->completion);
79 return kthread_stop(handle->task);
80}
81
82void rsi_mac80211_detach(struct rsi_hw *hw);
83u16 rsi_get_connected_channel(struct rsi_hw *adapter);
84struct rsi_hw *rsi_91x_init(void);
85void rsi_91x_deinit(struct rsi_hw *adapter);
86int rsi_read_pkt(struct rsi_common *common, s32 rcv_pkt_len);
87#endif
88