diff options
Diffstat (limited to 'drivers/net/ieee802154/fakelb.c')
-rw-r--r-- | drivers/net/ieee802154/fakelb.c | 91 |
1 files changed, 40 insertions, 51 deletions
diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c index 27d83207d24c..96947d724189 100644 --- a/drivers/net/ieee802154/fakelb.c +++ b/drivers/net/ieee802154/fakelb.c | |||
@@ -12,10 +12,6 @@ | |||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | * | ||
19 | * Written by: | 15 | * Written by: |
20 | * Sergey Lapin <slapin@ossfans.org> | 16 | * Sergey Lapin <slapin@ossfans.org> |
21 | * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 17 | * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> |
@@ -29,12 +25,12 @@ | |||
29 | #include <linux/device.h> | 25 | #include <linux/device.h> |
30 | #include <linux/spinlock.h> | 26 | #include <linux/spinlock.h> |
31 | #include <net/mac802154.h> | 27 | #include <net/mac802154.h> |
32 | #include <net/wpan-phy.h> | 28 | #include <net/cfg802154.h> |
33 | 29 | ||
34 | static int numlbs = 1; | 30 | static int numlbs = 1; |
35 | 31 | ||
36 | struct fakelb_dev_priv { | 32 | struct fakelb_dev_priv { |
37 | struct ieee802154_dev *dev; | 33 | struct ieee802154_hw *hw; |
38 | 34 | ||
39 | struct list_head list; | 35 | struct list_head list; |
40 | struct fakelb_priv *fake; | 36 | struct fakelb_priv *fake; |
@@ -49,9 +45,8 @@ struct fakelb_priv { | |||
49 | }; | 45 | }; |
50 | 46 | ||
51 | static int | 47 | static int |
52 | fakelb_hw_ed(struct ieee802154_dev *dev, u8 *level) | 48 | fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level) |
53 | { | 49 | { |
54 | might_sleep(); | ||
55 | BUG_ON(!level); | 50 | BUG_ON(!level); |
56 | *level = 0xbe; | 51 | *level = 0xbe; |
57 | 52 | ||
@@ -59,14 +54,10 @@ fakelb_hw_ed(struct ieee802154_dev *dev, u8 *level) | |||
59 | } | 54 | } |
60 | 55 | ||
61 | static int | 56 | static int |
62 | fakelb_hw_channel(struct ieee802154_dev *dev, int page, int channel) | 57 | fakelb_hw_channel(struct ieee802154_hw *hw, u8 page, u8 channel) |
63 | { | 58 | { |
64 | pr_debug("set channel to %d\n", channel); | 59 | pr_debug("set channel to %d\n", channel); |
65 | 60 | ||
66 | might_sleep(); | ||
67 | dev->phy->current_page = page; | ||
68 | dev->phy->current_channel = channel; | ||
69 | |||
70 | return 0; | 61 | return 0; |
71 | } | 62 | } |
72 | 63 | ||
@@ -78,19 +69,17 @@ fakelb_hw_deliver(struct fakelb_dev_priv *priv, struct sk_buff *skb) | |||
78 | spin_lock(&priv->lock); | 69 | spin_lock(&priv->lock); |
79 | if (priv->working) { | 70 | if (priv->working) { |
80 | newskb = pskb_copy(skb, GFP_ATOMIC); | 71 | newskb = pskb_copy(skb, GFP_ATOMIC); |
81 | ieee802154_rx_irqsafe(priv->dev, newskb, 0xcc); | 72 | ieee802154_rx_irqsafe(priv->hw, newskb, 0xcc); |
82 | } | 73 | } |
83 | spin_unlock(&priv->lock); | 74 | spin_unlock(&priv->lock); |
84 | } | 75 | } |
85 | 76 | ||
86 | static int | 77 | static int |
87 | fakelb_hw_xmit(struct ieee802154_dev *dev, struct sk_buff *skb) | 78 | fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) |
88 | { | 79 | { |
89 | struct fakelb_dev_priv *priv = dev->priv; | 80 | struct fakelb_dev_priv *priv = hw->priv; |
90 | struct fakelb_priv *fake = priv->fake; | 81 | struct fakelb_priv *fake = priv->fake; |
91 | 82 | ||
92 | might_sleep(); | ||
93 | |||
94 | read_lock_bh(&fake->lock); | 83 | read_lock_bh(&fake->lock); |
95 | if (priv->list.next == priv->list.prev) { | 84 | if (priv->list.next == priv->list.prev) { |
96 | /* we are the only one device */ | 85 | /* we are the only one device */ |
@@ -99,8 +88,8 @@ fakelb_hw_xmit(struct ieee802154_dev *dev, struct sk_buff *skb) | |||
99 | struct fakelb_dev_priv *dp; | 88 | struct fakelb_dev_priv *dp; |
100 | list_for_each_entry(dp, &priv->fake->list, list) { | 89 | list_for_each_entry(dp, &priv->fake->list, list) { |
101 | if (dp != priv && | 90 | if (dp != priv && |
102 | (dp->dev->phy->current_channel == | 91 | (dp->hw->phy->current_channel == |
103 | priv->dev->phy->current_channel)) | 92 | priv->hw->phy->current_channel)) |
104 | fakelb_hw_deliver(dp, skb); | 93 | fakelb_hw_deliver(dp, skb); |
105 | } | 94 | } |
106 | } | 95 | } |
@@ -110,8 +99,8 @@ fakelb_hw_xmit(struct ieee802154_dev *dev, struct sk_buff *skb) | |||
110 | } | 99 | } |
111 | 100 | ||
112 | static int | 101 | static int |
113 | fakelb_hw_start(struct ieee802154_dev *dev) { | 102 | fakelb_hw_start(struct ieee802154_hw *hw) { |
114 | struct fakelb_dev_priv *priv = dev->priv; | 103 | struct fakelb_dev_priv *priv = hw->priv; |
115 | int ret = 0; | 104 | int ret = 0; |
116 | 105 | ||
117 | spin_lock(&priv->lock); | 106 | spin_lock(&priv->lock); |
@@ -125,17 +114,17 @@ fakelb_hw_start(struct ieee802154_dev *dev) { | |||
125 | } | 114 | } |
126 | 115 | ||
127 | static void | 116 | static void |
128 | fakelb_hw_stop(struct ieee802154_dev *dev) { | 117 | fakelb_hw_stop(struct ieee802154_hw *hw) { |
129 | struct fakelb_dev_priv *priv = dev->priv; | 118 | struct fakelb_dev_priv *priv = hw->priv; |
130 | 119 | ||
131 | spin_lock(&priv->lock); | 120 | spin_lock(&priv->lock); |
132 | priv->working = 0; | 121 | priv->working = 0; |
133 | spin_unlock(&priv->lock); | 122 | spin_unlock(&priv->lock); |
134 | } | 123 | } |
135 | 124 | ||
136 | static struct ieee802154_ops fakelb_ops = { | 125 | static const struct ieee802154_ops fakelb_ops = { |
137 | .owner = THIS_MODULE, | 126 | .owner = THIS_MODULE, |
138 | .xmit = fakelb_hw_xmit, | 127 | .xmit_sync = fakelb_hw_xmit, |
139 | .ed = fakelb_hw_ed, | 128 | .ed = fakelb_hw_ed, |
140 | .set_channel = fakelb_hw_channel, | 129 | .set_channel = fakelb_hw_channel, |
141 | .start = fakelb_hw_start, | 130 | .start = fakelb_hw_start, |
@@ -150,54 +139,54 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) | |||
150 | { | 139 | { |
151 | struct fakelb_dev_priv *priv; | 140 | struct fakelb_dev_priv *priv; |
152 | int err; | 141 | int err; |
153 | struct ieee802154_dev *ieee; | 142 | struct ieee802154_hw *hw; |
154 | 143 | ||
155 | ieee = ieee802154_alloc_device(sizeof(*priv), &fakelb_ops); | 144 | hw = ieee802154_alloc_hw(sizeof(*priv), &fakelb_ops); |
156 | if (!ieee) | 145 | if (!hw) |
157 | return -ENOMEM; | 146 | return -ENOMEM; |
158 | 147 | ||
159 | priv = ieee->priv; | 148 | priv = hw->priv; |
160 | priv->dev = ieee; | 149 | priv->hw = hw; |
161 | 150 | ||
162 | /* 868 MHz BPSK 802.15.4-2003 */ | 151 | /* 868 MHz BPSK 802.15.4-2003 */ |
163 | ieee->phy->channels_supported[0] |= 1; | 152 | hw->phy->channels_supported[0] |= 1; |
164 | /* 915 MHz BPSK 802.15.4-2003 */ | 153 | /* 915 MHz BPSK 802.15.4-2003 */ |
165 | ieee->phy->channels_supported[0] |= 0x7fe; | 154 | hw->phy->channels_supported[0] |= 0x7fe; |
166 | /* 2.4 GHz O-QPSK 802.15.4-2003 */ | 155 | /* 2.4 GHz O-QPSK 802.15.4-2003 */ |
167 | ieee->phy->channels_supported[0] |= 0x7FFF800; | 156 | hw->phy->channels_supported[0] |= 0x7FFF800; |
168 | /* 868 MHz ASK 802.15.4-2006 */ | 157 | /* 868 MHz ASK 802.15.4-2006 */ |
169 | ieee->phy->channels_supported[1] |= 1; | 158 | hw->phy->channels_supported[1] |= 1; |
170 | /* 915 MHz ASK 802.15.4-2006 */ | 159 | /* 915 MHz ASK 802.15.4-2006 */ |
171 | ieee->phy->channels_supported[1] |= 0x7fe; | 160 | hw->phy->channels_supported[1] |= 0x7fe; |
172 | /* 868 MHz O-QPSK 802.15.4-2006 */ | 161 | /* 868 MHz O-QPSK 802.15.4-2006 */ |
173 | ieee->phy->channels_supported[2] |= 1; | 162 | hw->phy->channels_supported[2] |= 1; |
174 | /* 915 MHz O-QPSK 802.15.4-2006 */ | 163 | /* 915 MHz O-QPSK 802.15.4-2006 */ |
175 | ieee->phy->channels_supported[2] |= 0x7fe; | 164 | hw->phy->channels_supported[2] |= 0x7fe; |
176 | /* 2.4 GHz CSS 802.15.4a-2007 */ | 165 | /* 2.4 GHz CSS 802.15.4a-2007 */ |
177 | ieee->phy->channels_supported[3] |= 0x3fff; | 166 | hw->phy->channels_supported[3] |= 0x3fff; |
178 | /* UWB Sub-gigahertz 802.15.4a-2007 */ | 167 | /* UWB Sub-gigahertz 802.15.4a-2007 */ |
179 | ieee->phy->channels_supported[4] |= 1; | 168 | hw->phy->channels_supported[4] |= 1; |
180 | /* UWB Low band 802.15.4a-2007 */ | 169 | /* UWB Low band 802.15.4a-2007 */ |
181 | ieee->phy->channels_supported[4] |= 0x1e; | 170 | hw->phy->channels_supported[4] |= 0x1e; |
182 | /* UWB High band 802.15.4a-2007 */ | 171 | /* UWB High band 802.15.4a-2007 */ |
183 | ieee->phy->channels_supported[4] |= 0xffe0; | 172 | hw->phy->channels_supported[4] |= 0xffe0; |
184 | /* 750 MHz O-QPSK 802.15.4c-2009 */ | 173 | /* 750 MHz O-QPSK 802.15.4c-2009 */ |
185 | ieee->phy->channels_supported[5] |= 0xf; | 174 | hw->phy->channels_supported[5] |= 0xf; |
186 | /* 750 MHz MPSK 802.15.4c-2009 */ | 175 | /* 750 MHz MPSK 802.15.4c-2009 */ |
187 | ieee->phy->channels_supported[5] |= 0xf0; | 176 | hw->phy->channels_supported[5] |= 0xf0; |
188 | /* 950 MHz BPSK 802.15.4d-2009 */ | 177 | /* 950 MHz BPSK 802.15.4d-2009 */ |
189 | ieee->phy->channels_supported[6] |= 0x3ff; | 178 | hw->phy->channels_supported[6] |= 0x3ff; |
190 | /* 950 MHz GFSK 802.15.4d-2009 */ | 179 | /* 950 MHz GFSK 802.15.4d-2009 */ |
191 | ieee->phy->channels_supported[6] |= 0x3ffc00; | 180 | hw->phy->channels_supported[6] |= 0x3ffc00; |
192 | 181 | ||
193 | INIT_LIST_HEAD(&priv->list); | 182 | INIT_LIST_HEAD(&priv->list); |
194 | priv->fake = fake; | 183 | priv->fake = fake; |
195 | 184 | ||
196 | spin_lock_init(&priv->lock); | 185 | spin_lock_init(&priv->lock); |
197 | 186 | ||
198 | ieee->parent = dev; | 187 | hw->parent = dev; |
199 | 188 | ||
200 | err = ieee802154_register_device(ieee); | 189 | err = ieee802154_register_hw(hw); |
201 | if (err) | 190 | if (err) |
202 | goto err_reg; | 191 | goto err_reg; |
203 | 192 | ||
@@ -208,7 +197,7 @@ static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) | |||
208 | return 0; | 197 | return 0; |
209 | 198 | ||
210 | err_reg: | 199 | err_reg: |
211 | ieee802154_free_device(priv->dev); | 200 | ieee802154_free_hw(priv->hw); |
212 | return err; | 201 | return err; |
213 | } | 202 | } |
214 | 203 | ||
@@ -218,8 +207,8 @@ static void fakelb_del(struct fakelb_dev_priv *priv) | |||
218 | list_del(&priv->list); | 207 | list_del(&priv->list); |
219 | write_unlock_bh(&priv->fake->lock); | 208 | write_unlock_bh(&priv->fake->lock); |
220 | 209 | ||
221 | ieee802154_unregister_device(priv->dev); | 210 | ieee802154_unregister_hw(priv->hw); |
222 | ieee802154_free_device(priv->dev); | 211 | ieee802154_free_hw(priv->hw); |
223 | } | 212 | } |
224 | 213 | ||
225 | static int fakelb_probe(struct platform_device *pdev) | 214 | static int fakelb_probe(struct platform_device *pdev) |