This source file includes following definitions.
- wimax_id_table_add
- wimax_dev_get_by_genl_info
- wimax_id_table_rm
- wimax_id_table_release
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 #include <linux/device.h>
28 #include <net/genetlink.h>
29 #include <linux/netdevice.h>
30 #include <linux/list.h>
31 #include <linux/wimax.h>
32 #include "wimax-internal.h"
33
34
35 #define D_SUBMODULE id_table
36 #include "debug-levels.h"
37
38
39 static DEFINE_SPINLOCK(wimax_id_table_lock);
40 static struct list_head wimax_id_table = LIST_HEAD_INIT(wimax_id_table);
41
42
43
44
45
46
47
48
49
50
51
52 void wimax_id_table_add(struct wimax_dev *wimax_dev)
53 {
54 d_fnstart(3, NULL, "(wimax_dev %p)\n", wimax_dev);
55 spin_lock(&wimax_id_table_lock);
56 list_add(&wimax_dev->id_table_node, &wimax_id_table);
57 spin_unlock(&wimax_id_table_lock);
58 d_fnend(3, NULL, "(wimax_dev %p)\n", wimax_dev);
59 }
60
61
62
63
64
65
66
67
68
69
70
71
72 struct wimax_dev *wimax_dev_get_by_genl_info(
73 struct genl_info *info, int ifindex)
74 {
75 struct wimax_dev *wimax_dev = NULL;
76
77 d_fnstart(3, NULL, "(info %p ifindex %d)\n", info, ifindex);
78 spin_lock(&wimax_id_table_lock);
79 list_for_each_entry(wimax_dev, &wimax_id_table, id_table_node) {
80 if (wimax_dev->net_dev->ifindex == ifindex) {
81 dev_hold(wimax_dev->net_dev);
82 goto found;
83 }
84 }
85 wimax_dev = NULL;
86 d_printf(1, NULL, "wimax: no devices found with ifindex %d\n",
87 ifindex);
88 found:
89 spin_unlock(&wimax_id_table_lock);
90 d_fnend(3, NULL, "(info %p ifindex %d) = %p\n",
91 info, ifindex, wimax_dev);
92 return wimax_dev;
93 }
94
95
96
97
98
99
100
101 void wimax_id_table_rm(struct wimax_dev *wimax_dev)
102 {
103 spin_lock(&wimax_id_table_lock);
104 list_del_init(&wimax_dev->id_table_node);
105 spin_unlock(&wimax_id_table_lock);
106 }
107
108
109
110
111
112
113
114
115
116 void wimax_id_table_release(void)
117 {
118 struct wimax_dev *wimax_dev;
119
120 #ifndef CONFIG_BUG
121 return;
122 #endif
123 spin_lock(&wimax_id_table_lock);
124 list_for_each_entry(wimax_dev, &wimax_id_table, id_table_node) {
125 pr_err("BUG: %s wimax_dev %p ifindex %d not cleared\n",
126 __func__, wimax_dev, wimax_dev->net_dev->ifindex);
127 WARN_ON(1);
128 }
129 spin_unlock(&wimax_id_table_lock);
130 }