diff options
author | Alexander Aring <alex.aring@gmail.com> | 2015-05-17 15:45:00 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-05-19 05:44:45 -0400 |
commit | db3f5d0df9af1e5965e64595595a6a719c42fcf3 (patch) | |
tree | 7cdf0810fe94d47175d03b1764b92c64d3df80cb /drivers/net | |
parent | 3186d3d7aec3b2f242abbc0a0219226e7705c905 (diff) |
fakelb: rename fakelb_dev_priv to fakelb_phy
This patch renames fakelb_dev_priv to fakelb_phy. We don't faking
devices here, we fake wpan phys. This avoids also confusing with the
variable priv, which is used several times in this driver to represent
this structure.
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 | 93 |
1 files changed, 47 insertions, 46 deletions
diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c index 66f99c4f9768..5c4fbb861eb0 100644 --- a/drivers/net/ieee802154/fakelb.c +++ b/drivers/net/ieee802154/fakelb.c | |||
@@ -29,7 +29,7 @@ | |||
29 | 29 | ||
30 | static int numlbs = 2; | 30 | static int numlbs = 2; |
31 | 31 | ||
32 | struct fakelb_dev_priv { | 32 | struct fakelb_phy { |
33 | struct ieee802154_hw *hw; | 33 | struct ieee802154_hw *hw; |
34 | 34 | ||
35 | struct list_head list; | 35 | struct list_head list; |
@@ -62,36 +62,37 @@ fakelb_hw_channel(struct ieee802154_hw *hw, u8 page, u8 channel) | |||
62 | } | 62 | } |
63 | 63 | ||
64 | static void | 64 | static void |
65 | fakelb_hw_deliver(struct fakelb_dev_priv *priv, struct sk_buff *skb) | 65 | fakelb_hw_deliver(struct fakelb_phy *phy, struct sk_buff *skb) |
66 | { | 66 | { |
67 | struct sk_buff *newskb; | 67 | struct sk_buff *newskb; |
68 | 68 | ||
69 | spin_lock(&priv->lock); | 69 | spin_lock(&phy->lock); |
70 | if (priv->working) { | 70 | if (phy->working) { |
71 | newskb = pskb_copy(skb, GFP_ATOMIC); | 71 | newskb = pskb_copy(skb, GFP_ATOMIC); |
72 | if (newskb) | 72 | if (newskb) |
73 | ieee802154_rx_irqsafe(priv->hw, newskb, 0xcc); | 73 | ieee802154_rx_irqsafe(phy->hw, newskb, 0xcc); |
74 | } | 74 | } |
75 | spin_unlock(&priv->lock); | 75 | spin_unlock(&phy->lock); |
76 | } | 76 | } |
77 | 77 | ||
78 | static int | 78 | static int |
79 | fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) | 79 | fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) |
80 | { | 80 | { |
81 | struct fakelb_dev_priv *priv = hw->priv; | 81 | struct fakelb_phy *current_phy = hw->priv; |
82 | struct fakelb_priv *fake = priv->fake; | 82 | struct fakelb_priv *fake = current_phy->fake; |
83 | 83 | ||
84 | read_lock_bh(&fake->lock); | 84 | read_lock_bh(&fake->lock); |
85 | if (priv->list.next == priv->list.prev) { | 85 | if (current_phy->list.next == current_phy->list.prev) { |
86 | /* we are the only one device */ | 86 | /* we are the only one device */ |
87 | fakelb_hw_deliver(priv, skb); | 87 | fakelb_hw_deliver(current_phy, skb); |
88 | } else { | 88 | } else { |
89 | struct fakelb_dev_priv *dp; | 89 | struct fakelb_phy *phy; |
90 | list_for_each_entry(dp, &priv->fake->list, list) { | 90 | |
91 | if (dp != priv && | 91 | list_for_each_entry(phy, ¤t_phy->fake->list, list) { |
92 | (dp->hw->phy->current_channel == | 92 | if (current_phy != phy && |
93 | priv->hw->phy->current_channel)) | 93 | (phy->hw->phy->current_channel == |
94 | fakelb_hw_deliver(dp, skb); | 94 | current_phy->hw->phy->current_channel)) |
95 | fakelb_hw_deliver(phy, skb); | ||
95 | } | 96 | } |
96 | } | 97 | } |
97 | read_unlock_bh(&fake->lock); | 98 | read_unlock_bh(&fake->lock); |
@@ -101,26 +102,26 @@ fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) | |||
101 | 102 | ||
102 | static int | 103 | static int |
103 | fakelb_hw_start(struct ieee802154_hw *hw) { | 104 | fakelb_hw_start(struct ieee802154_hw *hw) { |
104 | struct fakelb_dev_priv *priv = hw->priv; | 105 | struct fakelb_phy *phy = hw->priv; |
105 | int ret = 0; | 106 | int ret = 0; |
106 | 107 | ||
107 | spin_lock(&priv->lock); | 108 | spin_lock(&phy->lock); |
108 | if (priv->working) | 109 | if (phy->working) |
109 | ret = -EBUSY; | 110 | ret = -EBUSY; |
110 | else | 111 | else |
111 | priv->working = 1; | 112 | phy->working = 1; |
112 | spin_unlock(&priv->lock); | 113 | spin_unlock(&phy->lock); |
113 | 114 | ||
114 | return ret; | 115 | return ret; |
115 | } | 116 | } |
116 | 117 | ||
117 | static void | 118 | static void |
118 | fakelb_hw_stop(struct ieee802154_hw *hw) { | 119 | fakelb_hw_stop(struct ieee802154_hw *hw) { |
119 | struct fakelb_dev_priv *priv = hw->priv; | 120 | struct fakelb_phy *phy = hw->priv; |
120 | 121 | ||
121 | spin_lock(&priv->lock); | 122 | spin_lock(&phy->lock); |
122 | priv->working = 0; | 123 | phy->working = 0; |
123 | spin_unlock(&priv->lock); | 124 | spin_unlock(&phy->lock); |
124 | } | 125 | } |
125 | 126 | ||
126 | static const struct ieee802154_ops fakelb_ops = { | 127 | static const struct ieee802154_ops fakelb_ops = { |
@@ -138,16 +139,16 @@ MODULE_PARM_DESC(numlbs, " number of pseudo devices"); | |||
138 | 139 | ||
139 | static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) | 140 | static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) |
140 | { | 141 | { |
141 | struct fakelb_dev_priv *priv; | 142 | struct fakelb_phy *phy; |
142 | int err; | 143 | int err; |
143 | struct ieee802154_hw *hw; | 144 | struct ieee802154_hw *hw; |
144 | 145 | ||
145 | hw = ieee802154_alloc_hw(sizeof(*priv), &fakelb_ops); | 146 | hw = ieee802154_alloc_hw(sizeof(*phy), &fakelb_ops); |
146 | if (!hw) | 147 | if (!hw) |
147 | return -ENOMEM; | 148 | return -ENOMEM; |
148 | 149 | ||
149 | priv = hw->priv; | 150 | phy = hw->priv; |
150 | priv->hw = hw; | 151 | phy->hw = hw; |
151 | 152 | ||
152 | /* 868 MHz BPSK 802.15.4-2003 */ | 153 | /* 868 MHz BPSK 802.15.4-2003 */ |
153 | hw->phy->supported.channels[0] |= 1; | 154 | hw->phy->supported.channels[0] |= 1; |
@@ -180,10 +181,10 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) | |||
180 | /* 950 MHz GFSK 802.15.4d-2009 */ | 181 | /* 950 MHz GFSK 802.15.4d-2009 */ |
181 | hw->phy->supported.channels[6] |= 0x3ffc00; | 182 | hw->phy->supported.channels[6] |= 0x3ffc00; |
182 | 183 | ||
183 | INIT_LIST_HEAD(&priv->list); | 184 | INIT_LIST_HEAD(&phy->list); |
184 | priv->fake = fake; | 185 | phy->fake = fake; |
185 | 186 | ||
186 | spin_lock_init(&priv->lock); | 187 | spin_lock_init(&phy->lock); |
187 | 188 | ||
188 | hw->parent = dev; | 189 | hw->parent = dev; |
189 | 190 | ||
@@ -192,30 +193,30 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) | |||
192 | goto err_reg; | 193 | goto err_reg; |
193 | 194 | ||
194 | write_lock_bh(&fake->lock); | 195 | write_lock_bh(&fake->lock); |
195 | list_add_tail(&priv->list, &fake->list); | 196 | list_add_tail(&phy->list, &fake->list); |
196 | write_unlock_bh(&fake->lock); | 197 | write_unlock_bh(&fake->lock); |
197 | 198 | ||
198 | return 0; | 199 | return 0; |
199 | 200 | ||
200 | err_reg: | 201 | err_reg: |
201 | ieee802154_free_hw(priv->hw); | 202 | ieee802154_free_hw(phy->hw); |
202 | return err; | 203 | return err; |
203 | } | 204 | } |
204 | 205 | ||
205 | static void fakelb_del(struct fakelb_dev_priv *priv) | 206 | static void fakelb_del(struct fakelb_phy *phy) |
206 | { | 207 | { |
207 | write_lock_bh(&priv->fake->lock); | 208 | write_lock_bh(&phy->fake->lock); |
208 | list_del(&priv->list); | 209 | list_del(&phy->list); |
209 | write_unlock_bh(&priv->fake->lock); | 210 | write_unlock_bh(&phy->fake->lock); |
210 | 211 | ||
211 | ieee802154_unregister_hw(priv->hw); | 212 | ieee802154_unregister_hw(phy->hw); |
212 | ieee802154_free_hw(priv->hw); | 213 | ieee802154_free_hw(phy->hw); |
213 | } | 214 | } |
214 | 215 | ||
215 | static int fakelb_probe(struct platform_device *pdev) | 216 | static int fakelb_probe(struct platform_device *pdev) |
216 | { | 217 | { |
217 | struct fakelb_priv *priv; | 218 | struct fakelb_priv *priv; |
218 | struct fakelb_dev_priv *dp, *tmp; | 219 | struct fakelb_phy *phy, *tmp; |
219 | int err = -ENOMEM; | 220 | int err = -ENOMEM; |
220 | int i; | 221 | int i; |
221 | 222 | ||
@@ -238,8 +239,8 @@ static int fakelb_probe(struct platform_device *pdev) | |||
238 | return 0; | 239 | return 0; |
239 | 240 | ||
240 | err_slave: | 241 | err_slave: |
241 | list_for_each_entry_safe(dp, tmp, &priv->list, list) | 242 | list_for_each_entry_safe(phy, tmp, &priv->list, list) |
242 | fakelb_del(dp); | 243 | fakelb_del(phy); |
243 | err_alloc: | 244 | err_alloc: |
244 | return err; | 245 | return err; |
245 | } | 246 | } |
@@ -247,10 +248,10 @@ err_alloc: | |||
247 | static int fakelb_remove(struct platform_device *pdev) | 248 | static int fakelb_remove(struct platform_device *pdev) |
248 | { | 249 | { |
249 | struct fakelb_priv *priv = platform_get_drvdata(pdev); | 250 | struct fakelb_priv *priv = platform_get_drvdata(pdev); |
250 | struct fakelb_dev_priv *dp, *temp; | 251 | struct fakelb_phy *phy, *temp; |
251 | 252 | ||
252 | list_for_each_entry_safe(dp, temp, &priv->list, list) | 253 | list_for_each_entry_safe(phy, temp, &priv->list, list) |
253 | fakelb_del(dp); | 254 | fakelb_del(phy); |
254 | 255 | ||
255 | return 0; | 256 | return 0; |
256 | } | 257 | } |