1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66#include "i2400m.h"
67#include <linux/etherdevice.h>
68#include <linux/wimax/i2400m.h>
69#include <linux/module.h>
70#include <linux/moduleparam.h>
71#include <linux/suspend.h>
72#include <linux/slab.h>
73
74#define D_SUBMODULE driver
75#include "debug-levels.h"
76
77
78static char i2400m_debug_params[128];
79module_param_string(debug, i2400m_debug_params, sizeof(i2400m_debug_params),
80 0644);
81MODULE_PARM_DESC(debug,
82 "String of space-separated NAME:VALUE pairs, where NAMEs "
83 "are the different debug submodules and VALUE are the "
84 "initial debug value to set.");
85
86static char i2400m_barkers_params[128];
87module_param_string(barkers, i2400m_barkers_params,
88 sizeof(i2400m_barkers_params), 0644);
89MODULE_PARM_DESC(barkers,
90 "String of comma-separated 32-bit values; each is "
91 "recognized as the value the device sends as a reboot "
92 "signal; values are appended to a list--setting one value "
93 "as zero cleans the existing list and starts a new one.");
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125static
126int i2400m_op_msg_from_user(struct wimax_dev *wimax_dev,
127 const char *pipe_name,
128 const void *msg_buf, size_t msg_len,
129 const struct genl_info *genl_info)
130{
131 int result;
132 struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
133 struct device *dev = i2400m_dev(i2400m);
134 struct sk_buff *ack_skb;
135
136 d_fnstart(4, dev, "(wimax_dev %p [i2400m %p] msg_buf %p "
137 "msg_len %zu genl_info %p)\n", wimax_dev, i2400m,
138 msg_buf, msg_len, genl_info);
139 ack_skb = i2400m_msg_to_dev(i2400m, msg_buf, msg_len);
140 result = PTR_ERR(ack_skb);
141 if (IS_ERR(ack_skb))
142 goto error_msg_to_dev;
143 result = wimax_msg_send(&i2400m->wimax_dev, ack_skb);
144error_msg_to_dev:
145 d_fnend(4, dev, "(wimax_dev %p [i2400m %p] msg_buf %p msg_len %zu "
146 "genl_info %p) = %d\n", wimax_dev, i2400m, msg_buf, msg_len,
147 genl_info, result);
148 return result;
149}
150
151
152
153
154
155struct i2400m_reset_ctx {
156 struct completion completion;
157 int result;
158};
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177static
178int i2400m_op_reset(struct wimax_dev *wimax_dev)
179{
180 int result;
181 struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
182 struct device *dev = i2400m_dev(i2400m);
183 struct i2400m_reset_ctx ctx = {
184 .completion = COMPLETION_INITIALIZER_ONSTACK(ctx.completion),
185 .result = 0,
186 };
187
188 d_fnstart(4, dev, "(wimax_dev %p)\n", wimax_dev);
189 mutex_lock(&i2400m->init_mutex);
190 i2400m->reset_ctx = &ctx;
191 mutex_unlock(&i2400m->init_mutex);
192 result = i2400m_reset(i2400m, I2400M_RT_WARM);
193 if (result < 0)
194 goto out;
195 result = wait_for_completion_timeout(&ctx.completion, 4*HZ);
196 if (result == 0)
197 result = -ETIMEDOUT;
198 else if (result > 0)
199 result = ctx.result;
200
201 mutex_lock(&i2400m->init_mutex);
202 i2400m->reset_ctx = NULL;
203 mutex_unlock(&i2400m->init_mutex);
204out:
205 d_fnend(4, dev, "(wimax_dev %p) = %d\n", wimax_dev, result);
206 return result;
207}
208
209
210
211
212
213
214
215
216
217static
218int i2400m_check_mac_addr(struct i2400m *i2400m)
219{
220 int result;
221 struct device *dev = i2400m_dev(i2400m);
222 struct sk_buff *skb;
223 const struct i2400m_tlv_detailed_device_info *ddi;
224 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
225
226 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
227 skb = i2400m_get_device_info(i2400m);
228 if (IS_ERR(skb)) {
229 result = PTR_ERR(skb);
230 dev_err(dev, "Cannot verify MAC address, error reading: %d\n",
231 result);
232 goto error;
233 }
234
235 ddi = (void *) skb->data;
236 BUILD_BUG_ON(ETH_ALEN != sizeof(ddi->mac_address));
237 d_printf(2, dev, "GET DEVICE INFO: mac addr %pM\n",
238 ddi->mac_address);
239 if (!memcmp(net_dev->perm_addr, ddi->mac_address,
240 sizeof(ddi->mac_address)))
241 goto ok;
242 dev_warn(dev, "warning: device reports a different MAC address "
243 "to that of boot mode's\n");
244 dev_warn(dev, "device reports %pM\n", ddi->mac_address);
245 dev_warn(dev, "boot mode reported %pM\n", net_dev->perm_addr);
246 if (is_zero_ether_addr(ddi->mac_address))
247 dev_err(dev, "device reports an invalid MAC address, "
248 "not updating\n");
249 else {
250 dev_warn(dev, "updating MAC address\n");
251 net_dev->addr_len = ETH_ALEN;
252 memcpy(net_dev->perm_addr, ddi->mac_address, ETH_ALEN);
253 memcpy(net_dev->dev_addr, ddi->mac_address, ETH_ALEN);
254 }
255ok:
256 result = 0;
257 kfree_skb(skb);
258error:
259 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
260 return result;
261}
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283static
284int __i2400m_dev_start(struct i2400m *i2400m, enum i2400m_bri flags)
285{
286 int result;
287 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
288 struct net_device *net_dev = wimax_dev->net_dev;
289 struct device *dev = i2400m_dev(i2400m);
290 int times = i2400m->bus_bm_retries;
291
292 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
293retry:
294 result = i2400m_dev_bootstrap(i2400m, flags);
295 if (result < 0) {
296 dev_err(dev, "cannot bootstrap device: %d\n", result);
297 goto error_bootstrap;
298 }
299 result = i2400m_tx_setup(i2400m);
300 if (result < 0)
301 goto error_tx_setup;
302 result = i2400m_rx_setup(i2400m);
303 if (result < 0)
304 goto error_rx_setup;
305 i2400m->work_queue = create_singlethread_workqueue(wimax_dev->name);
306 if (i2400m->work_queue == NULL) {
307 result = -ENOMEM;
308 dev_err(dev, "cannot create workqueue\n");
309 goto error_create_workqueue;
310 }
311 if (i2400m->bus_dev_start) {
312 result = i2400m->bus_dev_start(i2400m);
313 if (result < 0)
314 goto error_bus_dev_start;
315 }
316 i2400m->ready = 1;
317 wmb();
318
319 queue_work(i2400m->work_queue, &i2400m->rx_report_ws);
320 result = i2400m_firmware_check(i2400m);
321 if (result < 0)
322 goto error_fw_check;
323
324 result = i2400m_check_mac_addr(i2400m);
325 if (result < 0)
326 goto error_check_mac_addr;
327 result = i2400m_dev_initialize(i2400m);
328 if (result < 0)
329 goto error_dev_initialize;
330
331
332
333
334
335
336 atomic_dec(&i2400m->error_recovery);
337
338
339
340
341
342 d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
343 net_dev, i2400m, result);
344 return result;
345
346error_dev_initialize:
347error_check_mac_addr:
348error_fw_check:
349 i2400m->ready = 0;
350 wmb();
351 flush_workqueue(i2400m->work_queue);
352 if (i2400m->bus_dev_stop)
353 i2400m->bus_dev_stop(i2400m);
354error_bus_dev_start:
355 destroy_workqueue(i2400m->work_queue);
356error_create_workqueue:
357 i2400m_rx_release(i2400m);
358error_rx_setup:
359 i2400m_tx_release(i2400m);
360error_tx_setup:
361error_bootstrap:
362 if (result == -EL3RST && times-- > 0) {
363 flags = I2400M_BRI_SOFT|I2400M_BRI_MAC_REINIT;
364 goto retry;
365 }
366 d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
367 net_dev, i2400m, result);
368 return result;
369}
370
371
372static
373int i2400m_dev_start(struct i2400m *i2400m, enum i2400m_bri bm_flags)
374{
375 int result = 0;
376 mutex_lock(&i2400m->init_mutex);
377 if (i2400m->updown == 0) {
378 result = __i2400m_dev_start(i2400m, bm_flags);
379 if (result >= 0) {
380 i2400m->updown = 1;
381 i2400m->alive = 1;
382 wmb();
383 }
384 }
385 mutex_unlock(&i2400m->init_mutex);
386 return result;
387}
388
389
390
391
392
393
394
395
396
397
398
399
400
401static
402void __i2400m_dev_stop(struct i2400m *i2400m)
403{
404 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
405 struct device *dev = i2400m_dev(i2400m);
406
407 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
408 wimax_state_change(wimax_dev, __WIMAX_ST_QUIESCING);
409 i2400m_msg_to_dev_cancel_wait(i2400m, -EL3RST);
410 complete(&i2400m->msg_completion);
411 i2400m_net_wake_stop(i2400m);
412 i2400m_dev_shutdown(i2400m);
413
414
415
416
417 i2400m->ready = 0;
418 wmb();
419 flush_workqueue(i2400m->work_queue);
420
421 if (i2400m->bus_dev_stop)
422 i2400m->bus_dev_stop(i2400m);
423 destroy_workqueue(i2400m->work_queue);
424 i2400m_rx_release(i2400m);
425 i2400m_tx_release(i2400m);
426 wimax_state_change(wimax_dev, WIMAX_ST_DOWN);
427 d_fnend(3, dev, "(i2400m %p) = 0\n", i2400m);
428}
429
430
431
432
433
434
435
436static
437void i2400m_dev_stop(struct i2400m *i2400m)
438{
439 mutex_lock(&i2400m->init_mutex);
440 if (i2400m->updown) {
441 __i2400m_dev_stop(i2400m);
442 i2400m->updown = 0;
443 i2400m->alive = 0;
444 wmb();
445 }
446 mutex_unlock(&i2400m->init_mutex);
447}
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463static
464int i2400m_pm_notifier(struct notifier_block *notifier,
465 unsigned long pm_event,
466 void *unused)
467{
468 struct i2400m *i2400m =
469 container_of(notifier, struct i2400m, pm_notifier);
470 struct device *dev = i2400m_dev(i2400m);
471
472 d_fnstart(3, dev, "(i2400m %p pm_event %lx)\n", i2400m, pm_event);
473 switch (pm_event) {
474 case PM_HIBERNATION_PREPARE:
475 case PM_SUSPEND_PREPARE:
476 i2400m_fw_cache(i2400m);
477 break;
478 case PM_POST_RESTORE:
479
480
481 case PM_POST_HIBERNATION:
482 case PM_POST_SUSPEND:
483 i2400m_fw_uncache(i2400m);
484 break;
485
486 case PM_RESTORE_PREPARE:
487 default:
488 break;
489 }
490 d_fnend(3, dev, "(i2400m %p pm_event %lx) = void\n", i2400m, pm_event);
491 return NOTIFY_DONE;
492}
493
494
495
496
497
498
499
500
501int i2400m_pre_reset(struct i2400m *i2400m)
502{
503 struct device *dev = i2400m_dev(i2400m);
504
505 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
506 d_printf(1, dev, "pre-reset shut down\n");
507
508 mutex_lock(&i2400m->init_mutex);
509 if (i2400m->updown) {
510 netif_tx_disable(i2400m->wimax_dev.net_dev);
511 __i2400m_dev_stop(i2400m);
512
513
514 }
515 mutex_unlock(&i2400m->init_mutex);
516 if (i2400m->bus_release)
517 i2400m->bus_release(i2400m);
518 d_fnend(3, dev, "(i2400m %p) = 0\n", i2400m);
519 return 0;
520}
521EXPORT_SYMBOL_GPL(i2400m_pre_reset);
522
523
524
525
526
527
528
529
530
531
532int i2400m_post_reset(struct i2400m *i2400m)
533{
534 int result = 0;
535 struct device *dev = i2400m_dev(i2400m);
536
537 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
538 d_printf(1, dev, "post-reset start\n");
539 if (i2400m->bus_setup) {
540 result = i2400m->bus_setup(i2400m);
541 if (result < 0) {
542 dev_err(dev, "bus-specific setup failed: %d\n",
543 result);
544 goto error_bus_setup;
545 }
546 }
547 mutex_lock(&i2400m->init_mutex);
548 if (i2400m->updown) {
549 result = __i2400m_dev_start(
550 i2400m, I2400M_BRI_SOFT | I2400M_BRI_MAC_REINIT);
551 if (result < 0)
552 goto error_dev_start;
553 }
554 mutex_unlock(&i2400m->init_mutex);
555 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
556 return result;
557
558error_dev_start:
559 if (i2400m->bus_release)
560 i2400m->bus_release(i2400m);
561
562
563 i2400m->updown = 0;
564 wmb();
565 mutex_unlock(&i2400m->init_mutex);
566error_bus_setup:
567 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
568 return result;
569}
570EXPORT_SYMBOL_GPL(i2400m_post_reset);
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596static
597void __i2400m_dev_reset_handle(struct work_struct *ws)
598{
599 struct i2400m *i2400m = container_of(ws, struct i2400m, reset_ws);
600 const char *reason = i2400m->reset_reason;
601 struct device *dev = i2400m_dev(i2400m);
602 struct i2400m_reset_ctx *ctx = i2400m->reset_ctx;
603 int result;
604
605 d_fnstart(3, dev, "(ws %p i2400m %p reason %s)\n", ws, i2400m, reason);
606
607 i2400m->boot_mode = 1;
608 wmb();
609
610 result = 0;
611 if (mutex_trylock(&i2400m->init_mutex) == 0) {
612
613
614
615 dev_err(dev, "device rebooted somewhere else?\n");
616 i2400m_msg_to_dev_cancel_wait(i2400m, -EL3RST);
617 complete(&i2400m->msg_completion);
618 goto out;
619 }
620
621 dev_err(dev, "%s: reinitializing driver\n", reason);
622 rmb();
623 if (i2400m->updown) {
624 __i2400m_dev_stop(i2400m);
625 i2400m->updown = 0;
626 wmb();
627 }
628
629 if (i2400m->alive) {
630 result = __i2400m_dev_start(i2400m,
631 I2400M_BRI_SOFT | I2400M_BRI_MAC_REINIT);
632 if (result < 0) {
633 dev_err(dev, "%s: cannot start the device: %d\n",
634 reason, result);
635 result = -EUCLEAN;
636 if (atomic_read(&i2400m->bus_reset_retries)
637 >= I2400M_BUS_RESET_RETRIES) {
638 result = -ENODEV;
639 dev_err(dev, "tried too many times to "
640 "reset the device, giving up\n");
641 }
642 }
643 }
644
645 if (i2400m->reset_ctx) {
646 ctx->result = result;
647 complete(&ctx->completion);
648 }
649 mutex_unlock(&i2400m->init_mutex);
650 if (result == -EUCLEAN) {
651
652
653
654
655
656
657
658
659 i2400m->boot_mode = 0;
660 wmb();
661
662 atomic_inc(&i2400m->bus_reset_retries);
663
664 result = i2400m_reset(i2400m, I2400M_RT_BUS);
665 if (result >= 0)
666 result = -ENODEV;
667 } else {
668 rmb();
669 if (i2400m->alive) {
670
671
672 i2400m->updown = 1;
673 wmb();
674 atomic_set(&i2400m->bus_reset_retries, 0);
675 }
676 }
677out:
678 d_fnend(3, dev, "(ws %p i2400m %p reason %s) = void\n",
679 ws, i2400m, reason);
680}
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695int i2400m_dev_reset_handle(struct i2400m *i2400m, const char *reason)
696{
697 i2400m->reset_reason = reason;
698 return schedule_work(&i2400m->reset_ws);
699}
700EXPORT_SYMBOL_GPL(i2400m_dev_reset_handle);
701
702
703
704
705
706
707
708static
709void __i2400m_error_recovery(struct work_struct *ws)
710{
711 struct i2400m *i2400m = container_of(ws, struct i2400m, recovery_ws);
712
713 i2400m_reset(i2400m, I2400M_RT_BUS);
714}
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741void i2400m_error_recovery(struct i2400m *i2400m)
742{
743 if (atomic_add_return(1, &i2400m->error_recovery) == 1)
744 schedule_work(&i2400m->recovery_ws);
745 else
746 atomic_dec(&i2400m->error_recovery);
747}
748EXPORT_SYMBOL_GPL(i2400m_error_recovery);
749
750
751
752
753
754
755static
756int i2400m_bm_buf_alloc(struct i2400m *i2400m)
757{
758 int result;
759
760 result = -ENOMEM;
761 i2400m->bm_cmd_buf = kzalloc(I2400M_BM_CMD_BUF_SIZE, GFP_KERNEL);
762 if (i2400m->bm_cmd_buf == NULL)
763 goto error_bm_cmd_kzalloc;
764 i2400m->bm_ack_buf = kzalloc(I2400M_BM_ACK_BUF_SIZE, GFP_KERNEL);
765 if (i2400m->bm_ack_buf == NULL)
766 goto error_bm_ack_buf_kzalloc;
767 return 0;
768
769error_bm_ack_buf_kzalloc:
770 kfree(i2400m->bm_cmd_buf);
771error_bm_cmd_kzalloc:
772 return result;
773}
774
775
776
777
778
779static
780void i2400m_bm_buf_free(struct i2400m *i2400m)
781{
782 kfree(i2400m->bm_ack_buf);
783 kfree(i2400m->bm_cmd_buf);
784}
785
786
787
788
789
790
791
792void i2400m_init(struct i2400m *i2400m)
793{
794 wimax_dev_init(&i2400m->wimax_dev);
795
796 i2400m->boot_mode = 1;
797 i2400m->rx_reorder = 1;
798 init_waitqueue_head(&i2400m->state_wq);
799
800 spin_lock_init(&i2400m->tx_lock);
801 i2400m->tx_pl_min = UINT_MAX;
802 i2400m->tx_size_min = UINT_MAX;
803
804 spin_lock_init(&i2400m->rx_lock);
805 i2400m->rx_pl_min = UINT_MAX;
806 i2400m->rx_size_min = UINT_MAX;
807 INIT_LIST_HEAD(&i2400m->rx_reports);
808 INIT_WORK(&i2400m->rx_report_ws, i2400m_report_hook_work);
809
810 mutex_init(&i2400m->msg_mutex);
811 init_completion(&i2400m->msg_completion);
812
813 mutex_init(&i2400m->init_mutex);
814
815
816 INIT_WORK(&i2400m->reset_ws, __i2400m_dev_reset_handle);
817 INIT_WORK(&i2400m->recovery_ws, __i2400m_error_recovery);
818
819 atomic_set(&i2400m->bus_reset_retries, 0);
820
821 i2400m->alive = 0;
822
823
824
825 atomic_set(&i2400m->error_recovery, 1);
826}
827EXPORT_SYMBOL_GPL(i2400m_init);
828
829
830int i2400m_reset(struct i2400m *i2400m, enum i2400m_reset_type rt)
831{
832 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
833
834
835
836
837
838
839 if (net_dev->reg_state == NETREG_REGISTERED) {
840 netif_tx_disable(net_dev);
841 netif_carrier_off(net_dev);
842 }
843 return i2400m->bus_reset(i2400m, rt);
844}
845EXPORT_SYMBOL_GPL(i2400m_reset);
846
847
848
849
850
851
852
853
854
855
856
857
858
859int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags)
860{
861 int result = -ENODEV;
862 struct device *dev = i2400m_dev(i2400m);
863 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
864 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
865
866 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
867
868 snprintf(wimax_dev->name, sizeof(wimax_dev->name),
869 "i2400m-%s:%s", dev->bus->name, dev_name(dev));
870
871 result = i2400m_bm_buf_alloc(i2400m);
872 if (result < 0) {
873 dev_err(dev, "cannot allocate bootmode scratch buffers\n");
874 goto error_bm_buf_alloc;
875 }
876
877 if (i2400m->bus_setup) {
878 result = i2400m->bus_setup(i2400m);
879 if (result < 0) {
880 dev_err(dev, "bus-specific setup failed: %d\n",
881 result);
882 goto error_bus_setup;
883 }
884 }
885
886 result = i2400m_bootrom_init(i2400m, bm_flags);
887 if (result < 0) {
888 dev_err(dev, "read mac addr: bootrom init "
889 "failed: %d\n", result);
890 goto error_bootrom_init;
891 }
892 result = i2400m_read_mac_addr(i2400m);
893 if (result < 0)
894 goto error_read_mac_addr;
895 eth_random_addr(i2400m->src_mac_addr);
896
897 i2400m->pm_notifier.notifier_call = i2400m_pm_notifier;
898 register_pm_notifier(&i2400m->pm_notifier);
899
900 result = register_netdev(net_dev);
901 if (result < 0) {
902 dev_err(dev, "cannot register i2400m network device: %d\n",
903 result);
904 goto error_register_netdev;
905 }
906 netif_carrier_off(net_dev);
907
908 i2400m->wimax_dev.op_msg_from_user = i2400m_op_msg_from_user;
909 i2400m->wimax_dev.op_rfkill_sw_toggle = i2400m_op_rfkill_sw_toggle;
910 i2400m->wimax_dev.op_reset = i2400m_op_reset;
911
912 result = wimax_dev_add(&i2400m->wimax_dev, net_dev);
913 if (result < 0)
914 goto error_wimax_dev_add;
915
916
917 result = sysfs_create_group(&net_dev->dev.kobj, &i2400m_dev_attr_group);
918 if (result < 0) {
919 dev_err(dev, "cannot setup i2400m's sysfs: %d\n", result);
920 goto error_sysfs_setup;
921 }
922
923 result = i2400m_debugfs_add(i2400m);
924 if (result < 0) {
925 dev_err(dev, "cannot setup i2400m's debugfs: %d\n", result);
926 goto error_debugfs_setup;
927 }
928
929 result = i2400m_dev_start(i2400m, bm_flags);
930 if (result < 0)
931 goto error_dev_start;
932 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
933 return result;
934
935error_dev_start:
936 i2400m_debugfs_rm(i2400m);
937error_debugfs_setup:
938 sysfs_remove_group(&i2400m->wimax_dev.net_dev->dev.kobj,
939 &i2400m_dev_attr_group);
940error_sysfs_setup:
941 wimax_dev_rm(&i2400m->wimax_dev);
942error_wimax_dev_add:
943 unregister_netdev(net_dev);
944error_register_netdev:
945 unregister_pm_notifier(&i2400m->pm_notifier);
946error_read_mac_addr:
947error_bootrom_init:
948 if (i2400m->bus_release)
949 i2400m->bus_release(i2400m);
950error_bus_setup:
951 i2400m_bm_buf_free(i2400m);
952error_bm_buf_alloc:
953 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
954 return result;
955}
956EXPORT_SYMBOL_GPL(i2400m_setup);
957
958
959
960
961
962
963
964void i2400m_release(struct i2400m *i2400m)
965{
966 struct device *dev = i2400m_dev(i2400m);
967
968 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
969 netif_stop_queue(i2400m->wimax_dev.net_dev);
970
971 i2400m_dev_stop(i2400m);
972
973 cancel_work_sync(&i2400m->reset_ws);
974 cancel_work_sync(&i2400m->recovery_ws);
975
976 i2400m_debugfs_rm(i2400m);
977 sysfs_remove_group(&i2400m->wimax_dev.net_dev->dev.kobj,
978 &i2400m_dev_attr_group);
979 wimax_dev_rm(&i2400m->wimax_dev);
980 unregister_netdev(i2400m->wimax_dev.net_dev);
981 unregister_pm_notifier(&i2400m->pm_notifier);
982 if (i2400m->bus_release)
983 i2400m->bus_release(i2400m);
984 i2400m_bm_buf_free(i2400m);
985 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
986}
987EXPORT_SYMBOL_GPL(i2400m_release);
988
989
990
991
992
993struct d_level D_LEVEL[] = {
994 D_SUBMODULE_DEFINE(control),
995 D_SUBMODULE_DEFINE(driver),
996 D_SUBMODULE_DEFINE(debugfs),
997 D_SUBMODULE_DEFINE(fw),
998 D_SUBMODULE_DEFINE(netdev),
999 D_SUBMODULE_DEFINE(rfkill),
1000 D_SUBMODULE_DEFINE(rx),
1001 D_SUBMODULE_DEFINE(sysfs),
1002 D_SUBMODULE_DEFINE(tx),
1003};
1004size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
1005
1006
1007static
1008int __init i2400m_driver_init(void)
1009{
1010 d_parse_params(D_LEVEL, D_LEVEL_SIZE, i2400m_debug_params,
1011 "i2400m.debug");
1012 return i2400m_barker_db_init(i2400m_barkers_params);
1013}
1014module_init(i2400m_driver_init);
1015
1016static
1017void __exit i2400m_driver_exit(void)
1018{
1019 i2400m_barker_db_exit();
1020}
1021module_exit(i2400m_driver_exit);
1022
1023MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
1024MODULE_DESCRIPTION("Intel 2400M WiMAX networking bus-generic driver");
1025MODULE_LICENSE("GPL");
1026