2 * Copyright (c) 2014 Redpine Signals Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef __RSI_COMMON_H__
18 #define __RSI_COMMON_H__
20 #include <linux/kthread.h>
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
28 static inline int rsi_init_event(struct rsi_event
*pevent
)
30 atomic_set(&pevent
->event_condition
, 1);
31 init_waitqueue_head(&pevent
->event_queue
);
35 static inline int rsi_wait_event(struct rsi_event
*event
, u32 timeout
)
40 status
= wait_event_interruptible(event
->event_queue
,
41 (atomic_read(&event
->event_condition
) == 0));
43 status
= wait_event_interruptible_timeout(event
->event_queue
,
44 (atomic_read(&event
->event_condition
) == 0),
49 static inline void rsi_set_event(struct rsi_event
*event
)
51 atomic_set(&event
->event_condition
, 0);
52 wake_up_interruptible(&event
->event_queue
);
55 static inline void rsi_reset_event(struct rsi_event
*event
)
57 atomic_set(&event
->event_condition
, 1);
60 static inline int rsi_create_kthread(struct rsi_common
*common
,
61 struct rsi_thread
*thread
,
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
);
73 static inline int rsi_kill_thread(struct rsi_thread
*handle
)
75 atomic_inc(&handle
->thread_done
);
76 rsi_set_event(&handle
->event
);
78 wait_for_completion(&handle
->completion
);
79 return kthread_stop(handle
->task
);
82 void rsi_mac80211_detach(struct rsi_hw
*hw
);
83 u16
rsi_get_connected_channel(struct rsi_hw
*adapter
);
84 struct rsi_hw
*rsi_91x_init(void);
85 void rsi_91x_deinit(struct rsi_hw
*adapter
);
86 int rsi_read_pkt(struct rsi_common
*common
, s32 rcv_pkt_len
);