diff options
author | Alexander Aring <alex.aring@gmail.com> | 2015-05-17 15:45:03 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-05-19 05:44:45 -0400 |
commit | b82b99f16bc207291b14228441cfffbfd23d5f49 (patch) | |
tree | 826d990af67ad1b48977f97b9997342da3c48ea4 /drivers/net | |
parent | 3335d98c69b1b09b963d09c8475c40bd8988c994 (diff) |
fakelb: declare fakelb list static
This patch moves the fakelb list of all registered phy's in a static
declaration in the fakelb driver.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ieee802154/fakelb.c | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c index 43370fb48cf6..c7e7d506224f 100644 --- a/drivers/net/ieee802154/fakelb.c +++ b/drivers/net/ieee802154/fakelb.c | |||
@@ -29,21 +29,17 @@ | |||
29 | 29 | ||
30 | static int numlbs = 2; | 30 | static int numlbs = 2; |
31 | static DEFINE_RWLOCK(fakelb_lock); | 31 | static DEFINE_RWLOCK(fakelb_lock); |
32 | static LIST_HEAD(fakelb_phys); | ||
32 | 33 | ||
33 | struct fakelb_phy { | 34 | struct fakelb_phy { |
34 | struct ieee802154_hw *hw; | 35 | struct ieee802154_hw *hw; |
35 | 36 | ||
36 | struct list_head list; | 37 | struct list_head list; |
37 | struct fakelb_priv *fake; | ||
38 | 38 | ||
39 | spinlock_t lock; | 39 | spinlock_t lock; |
40 | bool working; | 40 | bool working; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | struct fakelb_priv { | ||
44 | struct list_head list; | ||
45 | }; | ||
46 | |||
47 | static int | 43 | static int |
48 | fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level) | 44 | fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level) |
49 | { | 45 | { |
@@ -82,7 +78,7 @@ fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) | |||
82 | struct fakelb_phy *phy; | 78 | struct fakelb_phy *phy; |
83 | 79 | ||
84 | read_lock_bh(&fakelb_lock); | 80 | read_lock_bh(&fakelb_lock); |
85 | list_for_each_entry(phy, ¤t_phy->fake->list, list) { | 81 | list_for_each_entry(phy, &fakelb_phys, list) { |
86 | if (current_phy == phy) | 82 | if (current_phy == phy) |
87 | continue; | 83 | continue; |
88 | 84 | ||
@@ -132,7 +128,7 @@ static const struct ieee802154_ops fakelb_ops = { | |||
132 | module_param(numlbs, int, 0); | 128 | module_param(numlbs, int, 0); |
133 | MODULE_PARM_DESC(numlbs, " number of pseudo devices"); | 129 | MODULE_PARM_DESC(numlbs, " number of pseudo devices"); |
134 | 130 | ||
135 | static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) | 131 | static int fakelb_add_one(struct device *dev) |
136 | { | 132 | { |
137 | struct fakelb_phy *phy; | 133 | struct fakelb_phy *phy; |
138 | int err; | 134 | int err; |
@@ -176,9 +172,6 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) | |||
176 | /* 950 MHz GFSK 802.15.4d-2009 */ | 172 | /* 950 MHz GFSK 802.15.4d-2009 */ |
177 | hw->phy->supported.channels[6] |= 0x3ffc00; | 173 | hw->phy->supported.channels[6] |= 0x3ffc00; |
178 | 174 | ||
179 | INIT_LIST_HEAD(&phy->list); | ||
180 | phy->fake = fake; | ||
181 | |||
182 | spin_lock_init(&phy->lock); | 175 | spin_lock_init(&phy->lock); |
183 | 176 | ||
184 | hw->parent = dev; | 177 | hw->parent = dev; |
@@ -188,7 +181,7 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) | |||
188 | goto err_reg; | 181 | goto err_reg; |
189 | 182 | ||
190 | write_lock_bh(&fakelb_lock); | 183 | write_lock_bh(&fakelb_lock); |
191 | list_add_tail(&phy->list, &fake->list); | 184 | list_add_tail(&phy->list, &fakelb_phys); |
192 | write_unlock_bh(&fakelb_lock); | 185 | write_unlock_bh(&fakelb_lock); |
193 | 186 | ||
194 | return 0; | 187 | return 0; |
@@ -210,41 +203,30 @@ static void fakelb_del(struct fakelb_phy *phy) | |||
210 | 203 | ||
211 | static int fakelb_probe(struct platform_device *pdev) | 204 | static int fakelb_probe(struct platform_device *pdev) |
212 | { | 205 | { |
213 | struct fakelb_priv *priv; | ||
214 | struct fakelb_phy *phy, *tmp; | 206 | struct fakelb_phy *phy, *tmp; |
215 | int err = -ENOMEM; | 207 | int err = -ENOMEM; |
216 | int i; | 208 | int i; |
217 | 209 | ||
218 | priv = devm_kzalloc(&pdev->dev, sizeof(struct fakelb_priv), | ||
219 | GFP_KERNEL); | ||
220 | if (!priv) | ||
221 | goto err_alloc; | ||
222 | |||
223 | INIT_LIST_HEAD(&priv->list); | ||
224 | |||
225 | for (i = 0; i < numlbs; i++) { | 210 | for (i = 0; i < numlbs; i++) { |
226 | err = fakelb_add_one(&pdev->dev, priv); | 211 | err = fakelb_add_one(&pdev->dev); |
227 | if (err < 0) | 212 | if (err < 0) |
228 | goto err_slave; | 213 | goto err_slave; |
229 | } | 214 | } |
230 | 215 | ||
231 | platform_set_drvdata(pdev, priv); | ||
232 | dev_info(&pdev->dev, "added ieee802154 hardware\n"); | 216 | dev_info(&pdev->dev, "added ieee802154 hardware\n"); |
233 | return 0; | 217 | return 0; |
234 | 218 | ||
235 | err_slave: | 219 | err_slave: |
236 | list_for_each_entry_safe(phy, tmp, &priv->list, list) | 220 | list_for_each_entry_safe(phy, tmp, &fakelb_phys, list) |
237 | fakelb_del(phy); | 221 | fakelb_del(phy); |
238 | err_alloc: | ||
239 | return err; | 222 | return err; |
240 | } | 223 | } |
241 | 224 | ||
242 | static int fakelb_remove(struct platform_device *pdev) | 225 | static int fakelb_remove(struct platform_device *pdev) |
243 | { | 226 | { |
244 | struct fakelb_priv *priv = platform_get_drvdata(pdev); | ||
245 | struct fakelb_phy *phy, *temp; | 227 | struct fakelb_phy *phy, *temp; |
246 | 228 | ||
247 | list_for_each_entry_safe(phy, temp, &priv->list, list) | 229 | list_for_each_entry_safe(phy, temp, &fakelb_phys, list) |
248 | fakelb_del(phy); | 230 | fakelb_del(phy); |
249 | 231 | ||
250 | return 0; | 232 | return 0; |