diff options
Diffstat (limited to 'net/mac802154/ieee802154_dev.c')
-rw-r--r-- | net/mac802154/ieee802154_dev.c | 70 |
1 files changed, 53 insertions, 17 deletions
diff --git a/net/mac802154/ieee802154_dev.c b/net/mac802154/ieee802154_dev.c index 2cf66d885e68..b36b2b996578 100644 --- a/net/mac802154/ieee802154_dev.c +++ b/net/mac802154/ieee802154_dev.c | |||
@@ -143,6 +143,7 @@ static void | |||
143 | mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev) | 143 | mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev) |
144 | { | 144 | { |
145 | struct mac802154_sub_if_data *sdata; | 145 | struct mac802154_sub_if_data *sdata; |
146 | |||
146 | ASSERT_RTNL(); | 147 | ASSERT_RTNL(); |
147 | 148 | ||
148 | sdata = netdev_priv(dev); | 149 | sdata = netdev_priv(dev); |
@@ -166,11 +167,13 @@ mac802154_add_iface(struct wpan_phy *phy, const char *name, int type) | |||
166 | switch (type) { | 167 | switch (type) { |
167 | case IEEE802154_DEV_MONITOR: | 168 | case IEEE802154_DEV_MONITOR: |
168 | dev = alloc_netdev(sizeof(struct mac802154_sub_if_data), | 169 | dev = alloc_netdev(sizeof(struct mac802154_sub_if_data), |
169 | name, mac802154_monitor_setup); | 170 | name, NET_NAME_UNKNOWN, |
171 | mac802154_monitor_setup); | ||
170 | break; | 172 | break; |
171 | case IEEE802154_DEV_WPAN: | 173 | case IEEE802154_DEV_WPAN: |
172 | dev = alloc_netdev(sizeof(struct mac802154_sub_if_data), | 174 | dev = alloc_netdev(sizeof(struct mac802154_sub_if_data), |
173 | name, mac802154_wpan_setup); | 175 | name, NET_NAME_UNKNOWN, |
176 | mac802154_wpan_setup); | ||
174 | break; | 177 | break; |
175 | default: | 178 | default: |
176 | dev = NULL; | 179 | dev = NULL; |
@@ -276,7 +279,8 @@ ieee802154_alloc_device(size_t priv_data_len, struct ieee802154_ops *ops) | |||
276 | } | 279 | } |
277 | 280 | ||
278 | priv = wpan_phy_priv(phy); | 281 | priv = wpan_phy_priv(phy); |
279 | priv->hw.phy = priv->phy = phy; | 282 | priv->phy = phy; |
283 | priv->hw.phy = priv->phy; | ||
280 | priv->hw.priv = (char *)priv + ALIGN(sizeof(*priv), NETDEV_ALIGN); | 284 | priv->hw.priv = (char *)priv + ALIGN(sizeof(*priv), NETDEV_ALIGN); |
281 | priv->ops = ops; | 285 | priv->ops = ops; |
282 | 286 | ||
@@ -302,29 +306,61 @@ EXPORT_SYMBOL(ieee802154_free_device); | |||
302 | int ieee802154_register_device(struct ieee802154_dev *dev) | 306 | int ieee802154_register_device(struct ieee802154_dev *dev) |
303 | { | 307 | { |
304 | struct mac802154_priv *priv = mac802154_to_priv(dev); | 308 | struct mac802154_priv *priv = mac802154_to_priv(dev); |
305 | int rc = -ENOMEM; | 309 | int rc = -ENOSYS; |
310 | |||
311 | if (dev->flags & IEEE802154_HW_TXPOWER) { | ||
312 | if (!priv->ops->set_txpower) | ||
313 | goto out; | ||
314 | |||
315 | priv->phy->set_txpower = mac802154_set_txpower; | ||
316 | } | ||
317 | |||
318 | if (dev->flags & IEEE802154_HW_LBT) { | ||
319 | if (!priv->ops->set_lbt) | ||
320 | goto out; | ||
321 | |||
322 | priv->phy->set_lbt = mac802154_set_lbt; | ||
323 | } | ||
324 | |||
325 | if (dev->flags & IEEE802154_HW_CCA_MODE) { | ||
326 | if (!priv->ops->set_cca_mode) | ||
327 | goto out; | ||
328 | |||
329 | priv->phy->set_cca_mode = mac802154_set_cca_mode; | ||
330 | } | ||
331 | |||
332 | if (dev->flags & IEEE802154_HW_CCA_ED_LEVEL) { | ||
333 | if (!priv->ops->set_cca_ed_level) | ||
334 | goto out; | ||
335 | |||
336 | priv->phy->set_cca_ed_level = mac802154_set_cca_ed_level; | ||
337 | } | ||
338 | |||
339 | if (dev->flags & IEEE802154_HW_CSMA_PARAMS) { | ||
340 | if (!priv->ops->set_csma_params) | ||
341 | goto out; | ||
342 | |||
343 | priv->phy->set_csma_params = mac802154_set_csma_params; | ||
344 | } | ||
345 | |||
346 | if (dev->flags & IEEE802154_HW_FRAME_RETRIES) { | ||
347 | if (!priv->ops->set_frame_retries) | ||
348 | goto out; | ||
349 | |||
350 | priv->phy->set_frame_retries = mac802154_set_frame_retries; | ||
351 | } | ||
306 | 352 | ||
307 | priv->dev_workqueue = | 353 | priv->dev_workqueue = |
308 | create_singlethread_workqueue(wpan_phy_name(priv->phy)); | 354 | create_singlethread_workqueue(wpan_phy_name(priv->phy)); |
309 | if (!priv->dev_workqueue) | 355 | if (!priv->dev_workqueue) { |
356 | rc = -ENOMEM; | ||
310 | goto out; | 357 | goto out; |
358 | } | ||
311 | 359 | ||
312 | wpan_phy_set_dev(priv->phy, priv->hw.parent); | 360 | wpan_phy_set_dev(priv->phy, priv->hw.parent); |
313 | 361 | ||
314 | priv->phy->add_iface = mac802154_add_iface; | 362 | priv->phy->add_iface = mac802154_add_iface; |
315 | priv->phy->del_iface = mac802154_del_iface; | 363 | priv->phy->del_iface = mac802154_del_iface; |
316 | if (priv->ops->set_txpower) | ||
317 | priv->phy->set_txpower = mac802154_set_txpower; | ||
318 | if (priv->ops->set_lbt) | ||
319 | priv->phy->set_lbt = mac802154_set_lbt; | ||
320 | if (priv->ops->set_cca_mode) | ||
321 | priv->phy->set_cca_mode = mac802154_set_cca_mode; | ||
322 | if (priv->ops->set_cca_ed_level) | ||
323 | priv->phy->set_cca_ed_level = mac802154_set_cca_ed_level; | ||
324 | if (priv->ops->set_csma_params) | ||
325 | priv->phy->set_csma_params = mac802154_set_csma_params; | ||
326 | if (priv->ops->set_frame_retries) | ||
327 | priv->phy->set_frame_retries = mac802154_set_frame_retries; | ||
328 | 364 | ||
329 | rc = wpan_phy_register(priv->phy); | 365 | rc = wpan_phy_register(priv->phy); |
330 | if (rc < 0) | 366 | if (rc < 0) |