2 * Intel Wireless WiMAX Connection 2400m
3 * Generic probe/disconnect, reset and message passing
6 * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * See i2400m.h for driver documentation. This contains helpers for
25 * the driver model glue [_setup()/_release()], handling device resets
26 * [_dev_reset_handle()], and the backends for the WiMAX stack ops
27 * reset [_op_reset()] and message from user [_op_msg_from_user()].
31 * i2400m_op_msg_from_user()
33 * wimax_msg_to_user_send()
38 * i2400m_dev_reset_handle()
39 * __i2400m_dev_reset_handle()
41 * __i2400m_dev_start()
44 * i2400m_bootrom_init()
47 * __i2400m_dev_start()
48 * i2400m_dev_bootstrap()
50 * i2400m->bus_dev_start()
51 * i2400m_firmware_check()
52 * i2400m_check_mac_addr()
59 * i2400m_dev_shutdown()
60 * i2400m->bus_dev_stop()
65 #include <linux/etherdevice.h>
66 #include <linux/wimax/i2400m.h>
67 #include <linux/module.h>
68 #include <linux/moduleparam.h>
70 #define D_SUBMODULE driver
71 #include "debug-levels.h"
74 int i2400m_idle_mode_disabled; /* 0 (idle mode enabled) by default */
75 module_param_named(idle_mode_disabled, i2400m_idle_mode_disabled, int, 0644);
76 MODULE_PARM_DESC(idle_mode_disabled,
77 "If true, the device will not enable idle mode negotiation "
78 "with the base station (when connected) to save power.");
80 int i2400m_rx_reorder_disabled; /* 0 (rx reorder enabled) by default */
81 module_param_named(rx_reorder_disabled, i2400m_rx_reorder_disabled, int, 0644);
82 MODULE_PARM_DESC(rx_reorder_disabled,
83 "If true, RX reordering will be disabled.");
85 int i2400m_power_save_disabled; /* 0 (power saving enabled) by default */
86 module_param_named(power_save_disabled, i2400m_power_save_disabled, int, 0644);
87 MODULE_PARM_DESC(power_save_disabled,
88 "If true, the driver will not tell the device to enter "
89 "power saving mode when it reports it is ready for it. "
90 "False by default (so the device is told to do power "
93 static char i2400m_debug_params[128];
94 module_param_string(debug, i2400m_debug_params, sizeof(i2400m_debug_params),
96 MODULE_PARM_DESC(debug,
97 "String of space-separated NAME:VALUE pairs, where NAMEs "
98 "are the different debug submodules and VALUE are the "
99 "initial debug value to set.");
102 * i2400m_queue_work - schedule work on a i2400m's queue
104 * @i2400m: device descriptor
106 * @fn: function to run to execute work. It gets passed a 'struct
107 * work_struct' that is wrapped in a 'struct i2400m_work'. Once
108 * done, you have to (1) i2400m_put(i2400m_work->i2400m) and then
109 * (2) kfree(i2400m_work).
111 * @gfp_flags: GFP flags for memory allocation.
113 * @pl: pointer to a payload buffer that you want to pass to the _work
114 * function. Use this to pack (for example) a struct with extra
117 * @pl_size: size of the payload buffer.
119 * We do this quite often, so this just saves typing; allocate a
120 * wrapper for a i2400m, get a ref to it, pack arguments and launch
123 * A usual workflow is:
125 * struct my_work_args {
131 * struct my_work_args my_args = {
135 * i2400m_queue_work(i2400m, 1, my_work_function, GFP_KERNEL,
136 * &args, sizeof(args))
138 * And now the work function can unpack the arguments and call the
139 * real function (or do the job itself):
142 * void my_work_fn((struct work_struct *ws)
144 * struct i2400m_work *iw =
145 * container_of(ws, struct i2400m_work, ws);
146 * struct my_work_args *my_args = (void *) iw->pl;
148 * my_work(iw->i2400m, my_args->something, my_args->whatevert);
151 int i2400m_queue_work(struct i2400m *i2400m,
152 void (*fn)(struct work_struct *), gfp_t gfp_flags,
153 const void *pl, size_t pl_size)
156 struct i2400m_work *iw;
158 BUG_ON(i2400m->work_queue == NULL);
160 iw = kzalloc(sizeof(*iw) + pl_size, gfp_flags);
163 iw->i2400m = i2400m_get(i2400m);
164 memcpy(iw->pl, pl, pl_size);
165 INIT_WORK(&iw->ws, fn);
166 result = queue_work(i2400m->work_queue, &iw->ws);
170 EXPORT_SYMBOL_GPL(i2400m_queue_work);
174 * Schedule i2400m's specific work on the system's queue.
176 * Used for a few cases where we really need it; otherwise, identical
177 * to i2400m_queue_work().
179 * Returns < 0 errno code on error, 1 if ok.
181 * If it returns zero, something really bad happened, as it means the
182 * works struct was already queued, but we have just allocated it, so
183 * it should not happen.
185 int i2400m_schedule_work(struct i2400m *i2400m,
186 void (*fn)(struct work_struct *), gfp_t gfp_flags)
189 struct i2400m_work *iw;
192 iw = kzalloc(sizeof(*iw), gfp_flags);
195 iw->i2400m = i2400m_get(i2400m);
196 INIT_WORK(&iw->ws, fn);
197 result = schedule_work(&iw->ws);
206 * WiMAX stack operation: relay a message from user space
208 * @wimax_dev: device descriptor
209 * @pipe_name: named pipe the message is for
210 * @msg_buf: pointer to the message bytes
211 * @msg_len: length of the buffer
212 * @genl_info: passed by the generic netlink layer
214 * The WiMAX stack will call this function when a message was received
217 * For the i2400m, this is an L3L4 message, as specified in
218 * include/linux/wimax/i2400m.h, and thus prefixed with a 'struct
219 * i2400m_l3l4_hdr'. Driver (and device) expect the messages to be
220 * coded in Little Endian.
222 * This function just verifies that the header declaration and the
223 * payload are consistent and then deals with it, either forwarding it
224 * to the device or procesing it locally.
226 * In the i2400m, messages are basically commands that will carry an
227 * ack, so we use i2400m_msg_to_dev() and then deliver the ack back to
228 * user space. The rx.c code might intercept the response and use it
229 * to update the driver's state, but then it will pass it on so it can
230 * be relayed back to user space.
232 * Note that asynchronous events from the device are processed and
233 * sent to user space in rx.c.
236 int i2400m_op_msg_from_user(struct wimax_dev *wimax_dev,
237 const char *pipe_name,
238 const void *msg_buf, size_t msg_len,
239 const struct genl_info *genl_info)
242 struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
243 struct device *dev = i2400m_dev(i2400m);
244 struct sk_buff *ack_skb;
246 d_fnstart(4, dev, "(wimax_dev %p [i2400m %p] msg_buf %p "
247 "msg_len %zu genl_info %p)\n", wimax_dev, i2400m,
248 msg_buf, msg_len, genl_info);
249 ack_skb = i2400m_msg_to_dev(i2400m, msg_buf, msg_len);
250 result = PTR_ERR(ack_skb);
252 goto error_msg_to_dev;
253 result = wimax_msg_send(&i2400m->wimax_dev, ack_skb);
255 d_fnend(4, dev, "(wimax_dev %p [i2400m %p] msg_buf %p msg_len %zu "
256 "genl_info %p) = %d\n", wimax_dev, i2400m, msg_buf, msg_len,
263 * Context to wait for a reset to finalize
265 struct i2400m_reset_ctx {
266 struct completion completion;
272 * WiMAX stack operation: reset a device
274 * @wimax_dev: device descriptor
276 * See the documentation for wimax_reset() and wimax_dev->op_reset for
277 * the requirements of this function. The WiMAX stack guarantees
278 * serialization on calls to this function.
280 * Do a warm reset on the device; if it fails, resort to a cold reset
281 * and return -ENODEV. On successful warm reset, we need to block
282 * until it is complete.
284 * The bus-driver implementation of reset takes care of falling back
285 * to cold reset if warm fails.
288 int i2400m_op_reset(struct wimax_dev *wimax_dev)
291 struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
292 struct device *dev = i2400m_dev(i2400m);
293 struct i2400m_reset_ctx ctx = {
294 .completion = COMPLETION_INITIALIZER_ONSTACK(ctx.completion),
298 d_fnstart(4, dev, "(wimax_dev %p)\n", wimax_dev);
299 mutex_lock(&i2400m->init_mutex);
300 i2400m->reset_ctx = &ctx;
301 mutex_unlock(&i2400m->init_mutex);
302 result = i2400m->bus_reset(i2400m, I2400M_RT_WARM);
305 result = wait_for_completion_timeout(&ctx.completion, 4*HZ);
310 /* if result < 0, pass it on */
311 mutex_lock(&i2400m->init_mutex);
312 i2400m->reset_ctx = NULL;
313 mutex_unlock(&i2400m->init_mutex);
315 d_fnend(4, dev, "(wimax_dev %p) = %d\n", wimax_dev, result);
321 * Check the MAC address we got from boot mode is ok
323 * @i2400m: device descriptor
325 * Returns: 0 if ok, < 0 errno code on error.
328 int i2400m_check_mac_addr(struct i2400m *i2400m)
331 struct device *dev = i2400m_dev(i2400m);
333 const struct i2400m_tlv_detailed_device_info *ddi;
334 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
335 const unsigned char zeromac[ETH_ALEN] = { 0 };
337 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
338 skb = i2400m_get_device_info(i2400m);
340 result = PTR_ERR(skb);
341 dev_err(dev, "Cannot verify MAC address, error reading: %d\n",
345 /* Extract MAC addresss */
346 ddi = (void *) skb->data;
347 BUILD_BUG_ON(ETH_ALEN != sizeof(ddi->mac_address));
348 d_printf(2, dev, "GET DEVICE INFO: mac addr "
349 "%02x:%02x:%02x:%02x:%02x:%02x\n",
350 ddi->mac_address[0], ddi->mac_address[1],
351 ddi->mac_address[2], ddi->mac_address[3],
352 ddi->mac_address[4], ddi->mac_address[5]);
353 if (!memcmp(net_dev->perm_addr, ddi->mac_address,
354 sizeof(ddi->mac_address)))
356 dev_warn(dev, "warning: device reports a different MAC address "
357 "to that of boot mode's\n");
358 dev_warn(dev, "device reports %02x:%02x:%02x:%02x:%02x:%02x\n",
359 ddi->mac_address[0], ddi->mac_address[1],
360 ddi->mac_address[2], ddi->mac_address[3],
361 ddi->mac_address[4], ddi->mac_address[5]);
362 dev_warn(dev, "boot mode reported %02x:%02x:%02x:%02x:%02x:%02x\n",
363 net_dev->perm_addr[0], net_dev->perm_addr[1],
364 net_dev->perm_addr[2], net_dev->perm_addr[3],
365 net_dev->perm_addr[4], net_dev->perm_addr[5]);
366 if (!memcmp(zeromac, ddi->mac_address, sizeof(zeromac)))
367 dev_err(dev, "device reports an invalid MAC address, "
370 dev_warn(dev, "updating MAC address\n");
371 net_dev->addr_len = ETH_ALEN;
372 memcpy(net_dev->perm_addr, ddi->mac_address, ETH_ALEN);
373 memcpy(net_dev->dev_addr, ddi->mac_address, ETH_ALEN);
379 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
385 * __i2400m_dev_start - Bring up driver communication with the device
387 * @i2400m: device descriptor
388 * @flags: boot mode flags
390 * Returns: 0 if ok, < 0 errno code on error.
392 * Uploads firmware and brings up all the resources needed to be able
393 * to communicate with the device.
395 * The workqueue has to be setup early, at least before RX handling
396 * (it's only real user for now) so it can process reports as they
397 * arrive. We also want to destroy it if we retry, to make sure it is
398 * flushed...easier like this.
400 * TX needs to be setup before the bus-specific code (otherwise on
401 * shutdown, the bus-tx code could try to access it).
404 int __i2400m_dev_start(struct i2400m *i2400m, enum i2400m_bri flags)
407 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
408 struct net_device *net_dev = wimax_dev->net_dev;
409 struct device *dev = i2400m_dev(i2400m);
410 int times = i2400m->bus_bm_retries;
412 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
414 result = i2400m_dev_bootstrap(i2400m, flags);
416 dev_err(dev, "cannot bootstrap device: %d\n", result);
417 goto error_bootstrap;
419 result = i2400m_tx_setup(i2400m);
422 result = i2400m_rx_setup(i2400m);
425 i2400m->work_queue = create_singlethread_workqueue(wimax_dev->name);
426 if (i2400m->work_queue == NULL) {
428 dev_err(dev, "cannot create workqueue\n");
429 goto error_create_workqueue;
431 result = i2400m->bus_dev_start(i2400m);
433 goto error_bus_dev_start;
434 result = i2400m_firmware_check(i2400m); /* fw versions ok? */
437 /* At this point is ok to send commands to the device */
438 result = i2400m_check_mac_addr(i2400m);
440 goto error_check_mac_addr;
442 wimax_state_change(wimax_dev, WIMAX_ST_UNINITIALIZED);
443 result = i2400m_dev_initialize(i2400m);
445 goto error_dev_initialize;
446 /* At this point, reports will come for the device and set it
447 * to the right state if it is different than UNINITIALIZED */
448 d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
449 net_dev, i2400m, result);
452 error_dev_initialize:
453 error_check_mac_addr:
455 i2400m->bus_dev_stop(i2400m);
457 destroy_workqueue(i2400m->work_queue);
458 error_create_workqueue:
459 i2400m_rx_release(i2400m);
461 i2400m_tx_release(i2400m);
464 if (result == -EL3RST && times-- > 0) {
465 flags = I2400M_BRI_SOFT|I2400M_BRI_MAC_REINIT;
468 d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
469 net_dev, i2400m, result);
475 int i2400m_dev_start(struct i2400m *i2400m, enum i2400m_bri bm_flags)
478 mutex_lock(&i2400m->init_mutex); /* Well, start the device */
479 result = __i2400m_dev_start(i2400m, bm_flags);
482 mutex_unlock(&i2400m->init_mutex);
488 * i2400m_dev_stop - Tear down driver communication with the device
490 * @i2400m: device descriptor
492 * Returns: 0 if ok, < 0 errno code on error.
494 * Releases all the resources allocated to communicate with the
495 * device. Note we cannot destroy the workqueue earlier as until RX is
496 * fully destroyed, it could still try to schedule jobs.
499 void __i2400m_dev_stop(struct i2400m *i2400m)
501 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
502 struct device *dev = i2400m_dev(i2400m);
504 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
505 wimax_state_change(wimax_dev, __WIMAX_ST_QUIESCING);
506 i2400m_dev_shutdown(i2400m);
508 i2400m->bus_dev_stop(i2400m);
509 destroy_workqueue(i2400m->work_queue);
510 i2400m_rx_release(i2400m);
511 i2400m_tx_release(i2400m);
512 wimax_state_change(wimax_dev, WIMAX_ST_DOWN);
513 d_fnend(3, dev, "(i2400m %p) = 0\n", i2400m);
518 * Watch out -- we only need to stop if there is a need for it. The
519 * device could have reset itself and failed to come up again (see
520 * _i2400m_dev_reset_handle()).
523 void i2400m_dev_stop(struct i2400m *i2400m)
525 mutex_lock(&i2400m->init_mutex);
526 if (i2400m->updown) {
527 __i2400m_dev_stop(i2400m);
530 mutex_unlock(&i2400m->init_mutex);
535 * The device has rebooted; fix up the device and the driver
537 * Tear down the driver communication with the device, reload the
538 * firmware and reinitialize the communication with the device.
540 * If someone calls a reset when the device's firmware is down, in
541 * theory we won't see it because we are not listening. However, just
542 * in case, leave the code to handle it.
544 * If there is a reset context, use it; this means someone is waiting
545 * for us to tell him when the reset operation is complete and the
546 * device is ready to rock again.
548 * NOTE: if we are in the process of bringing up or down the
549 * communication with the device [running i2400m_dev_start() or
550 * _stop()], don't do anything, let it fail and handle it.
552 * This function is ran always in a thread context
555 void __i2400m_dev_reset_handle(struct work_struct *ws)
558 struct i2400m_work *iw = container_of(ws, struct i2400m_work, ws);
559 struct i2400m *i2400m = iw->i2400m;
560 struct device *dev = i2400m_dev(i2400m);
561 enum wimax_st wimax_state;
562 struct i2400m_reset_ctx *ctx = i2400m->reset_ctx;
564 d_fnstart(3, dev, "(ws %p i2400m %p)\n", ws, i2400m);
566 if (mutex_trylock(&i2400m->init_mutex) == 0) {
567 /* We are still in i2400m_dev_start() [let it fail] or
568 * i2400m_dev_stop() [we are shutting down anyway, so
569 * ignore it] or we are resetting somewhere else. */
570 dev_err(dev, "device rebooted\n");
571 i2400m_msg_to_dev_cancel_wait(i2400m, -EL3RST);
572 complete(&i2400m->msg_completion);
575 wimax_state = wimax_state_get(&i2400m->wimax_dev);
576 if (wimax_state < WIMAX_ST_UNINITIALIZED) {
577 dev_info(dev, "device rebooted: it is down, ignoring\n");
578 goto out_unlock; /* ifconfig up/down wasn't called */
580 dev_err(dev, "device rebooted: reinitializing driver\n");
581 __i2400m_dev_stop(i2400m);
583 result = __i2400m_dev_start(i2400m,
584 I2400M_BRI_SOFT | I2400M_BRI_MAC_REINIT);
586 dev_err(dev, "device reboot: cannot start the device: %d\n",
588 result = i2400m->bus_reset(i2400m, I2400M_RT_BUS);
594 if (i2400m->reset_ctx) {
595 ctx->result = result;
596 complete(&ctx->completion);
598 mutex_unlock(&i2400m->init_mutex);
602 d_fnend(3, dev, "(ws %p i2400m %p) = void\n", ws, i2400m);
608 * i2400m_dev_reset_handle - Handle a device's reset in a thread context
610 * Schedule a device reset handling out on a thread context, so it
611 * is safe to call from atomic context. We can't use the i2400m's
612 * queue as we are going to destroy it and reinitialize it as part of
613 * the driver bringup/bringup process.
615 * See __i2400m_dev_reset_handle() for details; that takes care of
616 * reinitializing the driver to handle the reset, calling into the
617 * bus-specific functions ops as needed.
619 int i2400m_dev_reset_handle(struct i2400m *i2400m)
621 i2400m->boot_mode = 1;
622 wmb(); /* Make sure i2400m_msg_to_dev() sees boot_mode */
623 return i2400m_schedule_work(i2400m, __i2400m_dev_reset_handle,
626 EXPORT_SYMBOL_GPL(i2400m_dev_reset_handle);
630 * i2400m_bm_buf_alloc - Alloc the command and ack buffers for boot mode
632 * Get the buffers needed to deal with boot mode messages. These
633 * buffers need to be allocated before the sdio recieve irq is setup.
635 int i2400m_bm_buf_alloc(struct i2400m *i2400m)
640 i2400m->bm_cmd_buf = kzalloc(I2400M_BM_CMD_BUF_SIZE, GFP_KERNEL);
641 if (i2400m->bm_cmd_buf == NULL)
642 goto error_bm_cmd_kzalloc;
643 i2400m->bm_ack_buf = kzalloc(I2400M_BM_ACK_BUF_SIZE, GFP_KERNEL);
644 if (i2400m->bm_ack_buf == NULL)
645 goto error_bm_ack_buf_kzalloc;
648 error_bm_ack_buf_kzalloc:
649 kfree(i2400m->bm_cmd_buf);
650 error_bm_cmd_kzalloc:
653 EXPORT_SYMBOL_GPL(i2400m_bm_buf_alloc);
656 * i2400m_bm_buf_free - Free boot mode command and ack buffers.
658 * Free the command and ack buffers
661 void i2400m_bm_buf_free(struct i2400m *i2400m)
663 kfree(i2400m->bm_ack_buf);
664 kfree(i2400m->bm_cmd_buf);
667 EXPORT_SYMBOL_GPL(i2400m_bm_buf_free
670 * i2400m_setup - bus-generic setup function for the i2400m device
672 * @i2400m: device descriptor (bus-specific parts have been initialized)
674 * Returns: 0 if ok, < 0 errno code on error.
676 * Initializes the bus-generic parts of the i2400m driver; the
677 * bus-specific parts have been initialized, function pointers filled
678 * out by the bus-specific probe function.
680 * As well, this registers the WiMAX and net device nodes. Once this
681 * function returns, the device is operative and has to be ready to
682 * receive and send network traffic and WiMAX control operations.
684 int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags)
686 int result = -ENODEV;
687 struct device *dev = i2400m_dev(i2400m);
688 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
689 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
691 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
693 snprintf(wimax_dev->name, sizeof(wimax_dev->name),
694 "i2400m-%s:%s", dev->bus->name, dev_name(dev));
696 result = i2400m_bootrom_init(i2400m, bm_flags);
698 dev_err(dev, "read mac addr: bootrom init "
699 "failed: %d\n", result);
700 goto error_bootrom_init;
702 result = i2400m_read_mac_addr(i2400m);
704 goto error_read_mac_addr;
705 random_ether_addr(i2400m->src_mac_addr);
707 result = register_netdev(net_dev); /* Okey dokey, bring it up */
709 dev_err(dev, "cannot register i2400m network device: %d\n",
711 goto error_register_netdev;
713 netif_carrier_off(net_dev);
715 result = i2400m_dev_start(i2400m, bm_flags);
717 goto error_dev_start;
719 i2400m->wimax_dev.op_msg_from_user = i2400m_op_msg_from_user;
720 i2400m->wimax_dev.op_rfkill_sw_toggle = i2400m_op_rfkill_sw_toggle;
721 i2400m->wimax_dev.op_reset = i2400m_op_reset;
722 result = wimax_dev_add(&i2400m->wimax_dev, net_dev);
724 goto error_wimax_dev_add;
725 /* User space needs to do some init stuff */
726 wimax_state_change(wimax_dev, WIMAX_ST_UNINITIALIZED);
728 /* Now setup all that requires a registered net and wimax device. */
729 result = sysfs_create_group(&net_dev->dev.kobj, &i2400m_dev_attr_group);
731 dev_err(dev, "cannot setup i2400m's sysfs: %d\n", result);
732 goto error_sysfs_setup;
734 result = i2400m_debugfs_add(i2400m);
736 dev_err(dev, "cannot setup i2400m's debugfs: %d\n", result);
737 goto error_debugfs_setup;
739 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
743 sysfs_remove_group(&i2400m->wimax_dev.net_dev->dev.kobj,
744 &i2400m_dev_attr_group);
746 wimax_dev_rm(&i2400m->wimax_dev);
748 i2400m_dev_stop(i2400m);
750 unregister_netdev(net_dev);
751 error_register_netdev:
754 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
757 EXPORT_SYMBOL_GPL(i2400m_setup);
761 * i2400m_release - release the bus-generic driver resources
763 * Sends a disconnect message and undoes any setup done by i2400m_setup()
765 void i2400m_release(struct i2400m *i2400m)
767 struct device *dev = i2400m_dev(i2400m);
769 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
770 netif_stop_queue(i2400m->wimax_dev.net_dev);
772 i2400m_debugfs_rm(i2400m);
773 sysfs_remove_group(&i2400m->wimax_dev.net_dev->dev.kobj,
774 &i2400m_dev_attr_group);
775 wimax_dev_rm(&i2400m->wimax_dev);
776 i2400m_dev_stop(i2400m);
777 unregister_netdev(i2400m->wimax_dev.net_dev);
778 kfree(i2400m->bm_ack_buf);
779 kfree(i2400m->bm_cmd_buf);
780 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
782 EXPORT_SYMBOL_GPL(i2400m_release);
786 * Debug levels control; see debug.h
788 struct d_level D_LEVEL[] = {
789 D_SUBMODULE_DEFINE(control),
790 D_SUBMODULE_DEFINE(driver),
791 D_SUBMODULE_DEFINE(debugfs),
792 D_SUBMODULE_DEFINE(fw),
793 D_SUBMODULE_DEFINE(netdev),
794 D_SUBMODULE_DEFINE(rfkill),
795 D_SUBMODULE_DEFINE(rx),
796 D_SUBMODULE_DEFINE(sysfs),
797 D_SUBMODULE_DEFINE(tx),
799 size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
803 int __init i2400m_driver_init(void)
805 d_parse_params(D_LEVEL, D_LEVEL_SIZE, i2400m_debug_params,
809 module_init(i2400m_driver_init);
812 void __exit i2400m_driver_exit(void)
814 /* for scheds i2400m_dev_reset_handle() */
815 flush_scheduled_work();
818 module_exit(i2400m_driver_exit);
820 MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
821 MODULE_DESCRIPTION("Intel 2400M WiMAX networking bus-generic driver");
822 MODULE_LICENSE("GPL");