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