diff options
author | David Vrabel <david.vrabel@csr.com> | 2008-11-17 11:16:51 -0500 |
---|---|---|
committer | David Vrabel <david.vrabel@csr.com> | 2008-11-19 09:47:04 -0500 |
commit | e8e1594c8126b1b773988fa2e3bfec76cff88336 (patch) | |
tree | afa666ce45d8652880855b04a26755e4e5182e01 /drivers/uwb/i1480/i1480u-wlp/netdev.c | |
parent | 6fae35f9cea92793a98b2d9ab21235e5ae035581 (diff) |
wlp: start/stop radio on network interface up/down
Signed-off-by: David Vrabel <david.vrabel@csr.com>
Diffstat (limited to 'drivers/uwb/i1480/i1480u-wlp/netdev.c')
-rw-r--r-- | drivers/uwb/i1480/i1480u-wlp/netdev.c | 51 |
1 files changed, 11 insertions, 40 deletions
diff --git a/drivers/uwb/i1480/i1480u-wlp/netdev.c b/drivers/uwb/i1480/i1480u-wlp/netdev.c index 8802ac43d872..2eafb973cd05 100644 --- a/drivers/uwb/i1480/i1480u-wlp/netdev.c +++ b/drivers/uwb/i1480/i1480u-wlp/netdev.c | |||
@@ -207,6 +207,11 @@ int i1480u_open(struct net_device *net_dev) | |||
207 | result = i1480u_rx_setup(i1480u); /* Alloc RX stuff */ | 207 | result = i1480u_rx_setup(i1480u); /* Alloc RX stuff */ |
208 | if (result < 0) | 208 | if (result < 0) |
209 | goto error_rx_setup; | 209 | goto error_rx_setup; |
210 | |||
211 | result = uwb_radio_start(&wlp->pal); | ||
212 | if (result < 0) | ||
213 | goto error_radio_start; | ||
214 | |||
210 | netif_wake_queue(net_dev); | 215 | netif_wake_queue(net_dev); |
211 | #ifdef i1480u_FLOW_CONTROL | 216 | #ifdef i1480u_FLOW_CONTROL |
212 | result = usb_submit_urb(i1480u->notif_urb, GFP_KERNEL);; | 217 | result = usb_submit_urb(i1480u->notif_urb, GFP_KERNEL);; |
@@ -215,25 +220,20 @@ int i1480u_open(struct net_device *net_dev) | |||
215 | goto error_notif_urb_submit; | 220 | goto error_notif_urb_submit; |
216 | } | 221 | } |
217 | #endif | 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 | /* Interface is up with an address, now we can create WSS */ | 223 | /* Interface is up with an address, now we can create WSS */ |
226 | result = wlp_wss_setup(net_dev, &wlp->wss); | 224 | result = wlp_wss_setup(net_dev, &wlp->wss); |
227 | if (result < 0) { | 225 | if (result < 0) { |
228 | dev_err(dev, "Can't create WSS: %d. \n", result); | 226 | dev_err(dev, "Can't create WSS: %d. \n", result); |
229 | goto error_notif_deregister; | 227 | goto error_wss_setup; |
230 | } | 228 | } |
231 | return 0; | 229 | return 0; |
232 | error_notif_deregister: | 230 | error_wss_setup: |
233 | uwb_notifs_deregister(rc, &i1480u->uwb_notifs_handler); | ||
234 | #ifdef i1480u_FLOW_CONTROL | 231 | #ifdef i1480u_FLOW_CONTROL |
232 | usb_kill_urb(i1480u->notif_urb); | ||
235 | error_notif_urb_submit: | 233 | error_notif_urb_submit: |
236 | #endif | 234 | #endif |
235 | uwb_radio_stop(&wlp->pal); | ||
236 | error_radio_start: | ||
237 | netif_stop_queue(net_dev); | 237 | netif_stop_queue(net_dev); |
238 | i1480u_rx_release(i1480u); | 238 | i1480u_rx_release(i1480u); |
239 | error_rx_setup: | 239 | error_rx_setup: |
@@ -248,16 +248,15 @@ int i1480u_stop(struct net_device *net_dev) | |||
248 | { | 248 | { |
249 | struct i1480u *i1480u = netdev_priv(net_dev); | 249 | struct i1480u *i1480u = netdev_priv(net_dev); |
250 | struct wlp *wlp = &i1480u->wlp; | 250 | struct wlp *wlp = &i1480u->wlp; |
251 | struct uwb_rc *rc = wlp->rc; | ||
252 | 251 | ||
253 | BUG_ON(wlp->rc == NULL); | 252 | BUG_ON(wlp->rc == NULL); |
254 | wlp_wss_remove(&wlp->wss); | 253 | wlp_wss_remove(&wlp->wss); |
255 | uwb_notifs_deregister(rc, &i1480u->uwb_notifs_handler); | ||
256 | netif_carrier_off(net_dev); | 254 | netif_carrier_off(net_dev); |
257 | #ifdef i1480u_FLOW_CONTROL | 255 | #ifdef i1480u_FLOW_CONTROL |
258 | usb_kill_urb(i1480u->notif_urb); | 256 | usb_kill_urb(i1480u->notif_urb); |
259 | #endif | 257 | #endif |
260 | netif_stop_queue(net_dev); | 258 | netif_stop_queue(net_dev); |
259 | uwb_radio_stop(&wlp->pal); | ||
261 | i1480u_rx_release(i1480u); | 260 | i1480u_rx_release(i1480u); |
262 | i1480u_tx_release(i1480u); | 261 | i1480u_tx_release(i1480u); |
263 | return 0; | 262 | return 0; |
@@ -303,34 +302,6 @@ int i1480u_change_mtu(struct net_device *net_dev, int mtu) | |||
303 | return 0; | 302 | return 0; |
304 | } | 303 | } |
305 | 304 | ||
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 | } | ||
333 | |||
334 | /** | 305 | /** |
335 | * Stop the network queue | 306 | * Stop the network queue |
336 | * | 307 | * |