Commit e8e1594c8126b1b773988fa2e3bfec76cff88336
1 parent
6fae35f9ce
Exists in
master
and in
20 other branches
wlp: start/stop radio on network interface up/down
Signed-off-by: David Vrabel <david.vrabel@csr.com>
Showing 5 changed files with 27 additions and 46 deletions Side-by-side Diff
drivers/uwb/i1480/i1480u-wlp/lc.c
... | ... | @@ -206,7 +206,7 @@ |
206 | 206 | wlp->fill_device_info = i1480u_fill_device_info; |
207 | 207 | wlp->stop_queue = i1480u_stop_queue; |
208 | 208 | wlp->start_queue = i1480u_start_queue; |
209 | - result = wlp_setup(wlp, rc); | |
209 | + result = wlp_setup(wlp, rc, net_dev); | |
210 | 210 | if (result < 0) { |
211 | 211 | dev_err(&iface->dev, "Cannot setup WLP\n"); |
212 | 212 | goto error_wlp_setup; |
drivers/uwb/i1480/i1480u-wlp/netdev.c
... | ... | @@ -207,6 +207,11 @@ |
207 | 207 | result = i1480u_rx_setup(i1480u); /* Alloc RX stuff */ |
208 | 208 | if (result < 0) |
209 | 209 | goto error_rx_setup; |
210 | + | |
211 | + result = uwb_radio_start(&wlp->pal); | |
212 | + if (result < 0) | |
213 | + goto error_radio_start; | |
214 | + | |
210 | 215 | netif_wake_queue(net_dev); |
211 | 216 | #ifdef i1480u_FLOW_CONTROL |
212 | 217 | result = usb_submit_urb(i1480u->notif_urb, GFP_KERNEL);; |
213 | 218 | |
214 | 219 | |
215 | 220 | |
216 | 221 | |
... | ... | @@ -215,25 +220,20 @@ |
215 | 220 | goto error_notif_urb_submit; |
216 | 221 | } |
217 | 222 | #endif |
218 | - i1480u->uwb_notifs_handler.cb = i1480u_uwb_notifs_cb; | |
219 | - i1480u->uwb_notifs_handler.data = i1480u; | |
220 | - if (uwb_bg_joined(rc)) | |
221 | - netif_carrier_on(net_dev); | |
222 | - else | |
223 | - netif_carrier_off(net_dev); | |
224 | - uwb_notifs_register(rc, &i1480u->uwb_notifs_handler); | |
225 | 223 | /* Interface is up with an address, now we can create WSS */ |
226 | 224 | result = wlp_wss_setup(net_dev, &wlp->wss); |
227 | 225 | if (result < 0) { |
228 | 226 | dev_err(dev, "Can't create WSS: %d. \n", result); |
229 | - goto error_notif_deregister; | |
227 | + goto error_wss_setup; | |
230 | 228 | } |
231 | 229 | return 0; |
232 | -error_notif_deregister: | |
233 | - uwb_notifs_deregister(rc, &i1480u->uwb_notifs_handler); | |
230 | +error_wss_setup: | |
234 | 231 | #ifdef i1480u_FLOW_CONTROL |
232 | + usb_kill_urb(i1480u->notif_urb); | |
235 | 233 | error_notif_urb_submit: |
236 | 234 | #endif |
235 | + uwb_radio_stop(&wlp->pal); | |
236 | +error_radio_start: | |
237 | 237 | netif_stop_queue(net_dev); |
238 | 238 | i1480u_rx_release(i1480u); |
239 | 239 | error_rx_setup: |
240 | 240 | |
241 | 241 | |
... | ... | @@ -248,16 +248,15 @@ |
248 | 248 | { |
249 | 249 | struct i1480u *i1480u = netdev_priv(net_dev); |
250 | 250 | struct wlp *wlp = &i1480u->wlp; |
251 | - struct uwb_rc *rc = wlp->rc; | |
252 | 251 | |
253 | 252 | BUG_ON(wlp->rc == NULL); |
254 | 253 | wlp_wss_remove(&wlp->wss); |
255 | - uwb_notifs_deregister(rc, &i1480u->uwb_notifs_handler); | |
256 | 254 | netif_carrier_off(net_dev); |
257 | 255 | #ifdef i1480u_FLOW_CONTROL |
258 | 256 | usb_kill_urb(i1480u->notif_urb); |
259 | 257 | #endif |
260 | 258 | netif_stop_queue(net_dev); |
259 | + uwb_radio_stop(&wlp->pal); | |
261 | 260 | i1480u_rx_release(i1480u); |
262 | 261 | i1480u_tx_release(i1480u); |
263 | 262 | return 0; |
... | ... | @@ -301,34 +300,6 @@ |
301 | 300 | return -ERANGE; |
302 | 301 | net_dev->mtu = mtu; |
303 | 302 | return 0; |
304 | -} | |
305 | - | |
306 | - | |
307 | -/** | |
308 | - * Callback function to handle events from UWB | |
309 | - * When we see other devices we know the carrier is ok, | |
310 | - * if we are the only device in the beacon group we set the carrier | |
311 | - * state to off. | |
312 | - * */ | |
313 | -void i1480u_uwb_notifs_cb(void *data, struct uwb_dev *uwb_dev, | |
314 | - enum uwb_notifs event) | |
315 | -{ | |
316 | - struct i1480u *i1480u = data; | |
317 | - struct net_device *net_dev = i1480u->net_dev; | |
318 | - struct device *dev = &i1480u->usb_iface->dev; | |
319 | - switch (event) { | |
320 | - case UWB_NOTIF_BG_JOIN: | |
321 | - netif_carrier_on(net_dev); | |
322 | - dev_info(dev, "Link is up\n"); | |
323 | - break; | |
324 | - case UWB_NOTIF_BG_LEAVE: | |
325 | - netif_carrier_off(net_dev); | |
326 | - dev_info(dev, "Link is down\n"); | |
327 | - break; | |
328 | - default: | |
329 | - dev_err(dev, "don't know how to handle event %d from uwb\n", | |
330 | - event); | |
331 | - } | |
332 | 303 | } |
333 | 304 | |
334 | 305 | /** |
drivers/uwb/uwb-debug.c
... | ... | @@ -33,8 +33,6 @@ |
33 | 33 | #include <linux/seq_file.h> |
34 | 34 | |
35 | 35 | #include <linux/uwb/debug-cmd.h> |
36 | -#define D_LOCAL 0 | |
37 | -#include <linux/uwb/debug.h> | |
38 | 36 | |
39 | 37 | #include "uwb-internal.h" |
40 | 38 | |
... | ... | @@ -314,7 +312,6 @@ |
314 | 312 | |
315 | 313 | static void uwb_dbg_channel_changed(struct uwb_pal *pal, int channel) |
316 | 314 | { |
317 | - struct uwb_dbg *dbg = container_of(pal, struct uwb_dbg, pal); | |
318 | 315 | struct device *dev = &pal->rc->uwb_dev.dev; |
319 | 316 | |
320 | 317 | if (channel > 0) |
drivers/uwb/wlp/wlp-lc.c
... | ... | @@ -526,8 +526,18 @@ |
526 | 526 | } |
527 | 527 | } |
528 | 528 | |
529 | -int wlp_setup(struct wlp *wlp, struct uwb_rc *rc) | |
529 | +static void wlp_channel_changed(struct uwb_pal *pal, int channel) | |
530 | 530 | { |
531 | + struct wlp *wlp = container_of(pal, struct wlp, pal); | |
532 | + | |
533 | + if (channel < 0) | |
534 | + netif_carrier_off(wlp->ndev); | |
535 | + else | |
536 | + netif_carrier_on(wlp->ndev); | |
537 | +} | |
538 | + | |
539 | +int wlp_setup(struct wlp *wlp, struct uwb_rc *rc, struct net_device *ndev) | |
540 | +{ | |
531 | 541 | struct device *dev = &rc->uwb_dev.dev; |
532 | 542 | int result; |
533 | 543 | |
... | ... | @@ -537,6 +547,7 @@ |
537 | 547 | BUG_ON(wlp->stop_queue == NULL); |
538 | 548 | BUG_ON(wlp->start_queue == NULL); |
539 | 549 | wlp->rc = rc; |
550 | + wlp->ndev = ndev; | |
540 | 551 | wlp_eda_init(&wlp->eda);/* Set up address cache */ |
541 | 552 | wlp->uwb_notifs_handler.cb = wlp_uwb_notifs_cb; |
542 | 553 | wlp->uwb_notifs_handler.data = wlp; |
... | ... | @@ -544,6 +555,7 @@ |
544 | 555 | |
545 | 556 | uwb_pal_init(&wlp->pal); |
546 | 557 | wlp->pal.rc = rc; |
558 | + wlp->pal.channel_changed = wlp_channel_changed; | |
547 | 559 | result = uwb_pal_register(&wlp->pal); |
548 | 560 | if (result < 0) |
549 | 561 | uwb_notifs_deregister(wlp->rc, &wlp->uwb_notifs_handler); |
include/linux/wlp.h
... | ... | @@ -646,6 +646,7 @@ |
646 | 646 | struct wlp { |
647 | 647 | struct mutex mutex; |
648 | 648 | struct uwb_rc *rc; /* UWB radio controller */ |
649 | + struct net_device *ndev; | |
649 | 650 | struct uwb_pal pal; |
650 | 651 | struct wlp_eda eda; |
651 | 652 | struct wlp_uuid uuid; |
... | ... | @@ -675,7 +676,7 @@ |
675 | 676 | static struct wlp_wss_attribute wss_attr_##_name = __ATTR(_name, _mode, \ |
676 | 677 | _show, _store) |
677 | 678 | |
678 | -extern int wlp_setup(struct wlp *, struct uwb_rc *); | |
679 | +extern int wlp_setup(struct wlp *, struct uwb_rc *, struct net_device *ndev); | |
679 | 680 | extern void wlp_remove(struct wlp *); |
680 | 681 | extern ssize_t wlp_neighborhood_show(struct wlp *, char *); |
681 | 682 | extern int wlp_wss_setup(struct net_device *, struct wlp_wss *); |