net:wireless:Support eswin usb wifi ECR6600U
[platform/kernel/linux-starfive.git] / drivers / net / wireless / eswin / fullmac / ecrnx_p2p.c
1 /**
2  ****************************************************************************************
3  *
4  * @file rwnx_p2p.c
5  *
6  * 
7  *
8  ****************************************************************************************
9  */
10
11 /**
12  * INCLUDE FILES
13  ****************************************************************************************
14  */
15
16 #include "ecrnx_p2p.h"
17 #include "ecrnx_msg_tx.h"
18
19
20 /**
21  * FUNCTION DEFINITIONS
22  ****************************************************************************************
23  */
24
25 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
26 static void ecrnx_p2p_discovery_timer_fn(struct timer_list *t)
27 #else
28 static void ecrnx_p2p_discovery_timer_fn(ulong x)
29 #endif
30 {
31 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
32         struct ecrnx_hw *ecrnx_hw = from_timer(ecrnx_hw, t, p2p_listen.listen_timer);
33 #else
34         struct ecrnx_hw *ecrnx_hw = (void *)x;
35 #endif
36         ECRNX_PRINT("ecrnx_p2p_discovery_timer_fn\n");
37
38         schedule_work(&ecrnx_hw->p2p_listen.listen_expired_work);
39
40 }
41
42 void ecrnx_p2p_listen_init(struct ecrnx_p2p_listen *p2p_listen)
43 {
44         struct ecrnx_hw *ecrnx_hw = container_of(p2p_listen, struct ecrnx_hw, p2p_listen);
45 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
46         timer_setup(&p2p_listen->listen_timer, ecrnx_p2p_discovery_timer_fn, 0);
47 #else
48         setup_timer(&p2p_listen->listen_timer, ecrnx_p2p_discovery_timer_fn, (ulong)ecrnx_hw);
49 #endif
50         INIT_WORK(&p2p_listen->listen_expired_work, ecrnx_p2p_listen_expired);
51
52     init_waitqueue_head(&p2p_listen->rxdataq);
53 }
54
55 void ecrnx_p2p_listen_expired(struct work_struct *work)
56 {
57         struct ecrnx_p2p_listen *p2p_listen = container_of(work, struct ecrnx_p2p_listen, listen_expired_work);
58         struct ecrnx_hw *ecrnx_hw = container_of(p2p_listen, struct ecrnx_hw, p2p_listen);
59
60         ECRNX_PRINT("p2p_listen_expired\n");
61
62         if (p2p_listen->listen_started)
63         {
64                 del_timer_sync(&p2p_listen->listen_timer);
65                 ecrnx_send_p2p_cancel_listen_req(ecrnx_hw, p2p_listen->ecrnx_vif);
66         }
67         else
68         {
69                 return;
70         }
71 }
72