1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <linux/module.h>
25#include <linux/moduleparam.h>
26#include <linux/string.h>
27#include <linux/bitops.h>
28#include <linux/slab.h>
29#include <linux/interrupt.h>
30#include <linux/kmod.h>
31#include <linux/init.h>
32#include <linux/spinlock.h>
33#include <linux/errno.h>
34#include <linux/usb.h>
35#include <linux/usb/hcd.h>
36#include <linux/mutex.h>
37#include <linux/workqueue.h>
38#include <linux/debugfs.h>
39
40#include <asm/io.h>
41#include <linux/scatterlist.h>
42#include <linux/mm.h>
43#include <linux/dma-mapping.h>
44
45#include "usb.h"
46
47
48const char *usbcore_name = "usbcore";
49
50static bool nousb;
51
52
53#ifdef MODULE
54module_param(nousb, bool, 0444);
55#else
56core_param(nousb, nousb, bool, 0444);
57#endif
58
59
60
61
62int usb_disabled(void)
63{
64 return nousb;
65}
66EXPORT_SYMBOL_GPL(usb_disabled);
67
68#ifdef CONFIG_PM
69static int usb_autosuspend_delay = 2;
70
71module_param_named(autosuspend, usb_autosuspend_delay, int, 0644);
72MODULE_PARM_DESC(autosuspend, "default autosuspend delay");
73
74#else
75#define usb_autosuspend_delay 0
76#endif
77
78
79
80
81
82
83
84
85
86
87
88
89
90struct usb_host_interface *usb_find_alt_setting(
91 struct usb_host_config *config,
92 unsigned int iface_num,
93 unsigned int alt_num)
94{
95 struct usb_interface_cache *intf_cache = NULL;
96 int i;
97
98 for (i = 0; i < config->desc.bNumInterfaces; i++) {
99 if (config->intf_cache[i]->altsetting[0].desc.bInterfaceNumber
100 == iface_num) {
101 intf_cache = config->intf_cache[i];
102 break;
103 }
104 }
105 if (!intf_cache)
106 return NULL;
107 for (i = 0; i < intf_cache->num_altsetting; i++)
108 if (intf_cache->altsetting[i].desc.bAlternateSetting == alt_num)
109 return &intf_cache->altsetting[i];
110
111 printk(KERN_DEBUG "Did not find alt setting %u for intf %u, "
112 "config %u\n", alt_num, iface_num,
113 config->desc.bConfigurationValue);
114 return NULL;
115}
116EXPORT_SYMBOL_GPL(usb_find_alt_setting);
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev,
140 unsigned ifnum)
141{
142 struct usb_host_config *config = dev->actconfig;
143 int i;
144
145 if (!config)
146 return NULL;
147 for (i = 0; i < config->desc.bNumInterfaces; i++)
148 if (config->interface[i]->altsetting[0]
149 .desc.bInterfaceNumber == ifnum)
150 return config->interface[i];
151
152 return NULL;
153}
154EXPORT_SYMBOL_GPL(usb_ifnum_to_if);
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175struct usb_host_interface *usb_altnum_to_altsetting(
176 const struct usb_interface *intf,
177 unsigned int altnum)
178{
179 int i;
180
181 for (i = 0; i < intf->num_altsetting; i++) {
182 if (intf->altsetting[i].desc.bAlternateSetting == altnum)
183 return &intf->altsetting[i];
184 }
185 return NULL;
186}
187EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting);
188
189struct find_interface_arg {
190 int minor;
191 struct device_driver *drv;
192};
193
194static int __find_interface(struct device *dev, void *data)
195{
196 struct find_interface_arg *arg = data;
197 struct usb_interface *intf;
198
199 if (!is_usb_interface(dev))
200 return 0;
201
202 if (dev->driver != arg->drv)
203 return 0;
204 intf = to_usb_interface(dev);
205 return intf->minor == arg->minor;
206}
207
208
209
210
211
212
213
214
215
216
217
218
219struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
220{
221 struct find_interface_arg argb;
222 struct device *dev;
223
224 argb.minor = minor;
225 argb.drv = &drv->drvwrap.driver;
226
227 dev = bus_find_device(&usb_bus_type, NULL, &argb, __find_interface);
228
229
230 put_device(dev);
231
232 return dev ? to_usb_interface(dev) : NULL;
233}
234EXPORT_SYMBOL_GPL(usb_find_interface);
235
236struct each_dev_arg {
237 void *data;
238 int (*fn)(struct usb_device *, void *);
239};
240
241static int __each_dev(struct device *dev, void *data)
242{
243 struct each_dev_arg *arg = (struct each_dev_arg *)data;
244
245
246 if (!is_usb_device(dev))
247 return 0;
248
249 return arg->fn(container_of(dev, struct usb_device, dev), arg->data);
250}
251
252
253
254
255
256
257
258
259
260
261int usb_for_each_dev(void *data, int (*fn)(struct usb_device *, void *))
262{
263 struct each_dev_arg arg = {data, fn};
264
265 return bus_for_each_dev(&usb_bus_type, NULL, &arg, __each_dev);
266}
267EXPORT_SYMBOL_GPL(usb_for_each_dev);
268
269
270
271
272
273
274
275
276static void usb_release_dev(struct device *dev)
277{
278 struct usb_device *udev;
279 struct usb_hcd *hcd;
280
281 udev = to_usb_device(dev);
282 hcd = bus_to_hcd(udev->bus);
283
284 usb_destroy_configuration(udev);
285 usb_release_bos_descriptor(udev);
286 usb_put_hcd(hcd);
287 kfree(udev->product);
288 kfree(udev->manufacturer);
289 kfree(udev->serial);
290 kfree(udev);
291}
292
293static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
294{
295 struct usb_device *usb_dev;
296
297 usb_dev = to_usb_device(dev);
298
299 if (add_uevent_var(env, "BUSNUM=%03d", usb_dev->bus->busnum))
300 return -ENOMEM;
301
302 if (add_uevent_var(env, "DEVNUM=%03d", usb_dev->devnum))
303 return -ENOMEM;
304
305 return 0;
306}
307
308#ifdef CONFIG_PM
309
310
311
312
313
314
315
316
317static int usb_dev_prepare(struct device *dev)
318{
319 return 0;
320}
321
322static void usb_dev_complete(struct device *dev)
323{
324
325 usb_resume_complete(dev);
326}
327
328static int usb_dev_suspend(struct device *dev)
329{
330 return usb_suspend(dev, PMSG_SUSPEND);
331}
332
333static int usb_dev_resume(struct device *dev)
334{
335 return usb_resume(dev, PMSG_RESUME);
336}
337
338static int usb_dev_freeze(struct device *dev)
339{
340 return usb_suspend(dev, PMSG_FREEZE);
341}
342
343static int usb_dev_thaw(struct device *dev)
344{
345 return usb_resume(dev, PMSG_THAW);
346}
347
348static int usb_dev_poweroff(struct device *dev)
349{
350 return usb_suspend(dev, PMSG_HIBERNATE);
351}
352
353static int usb_dev_restore(struct device *dev)
354{
355 return usb_resume(dev, PMSG_RESTORE);
356}
357
358static const struct dev_pm_ops usb_device_pm_ops = {
359 .prepare = usb_dev_prepare,
360 .complete = usb_dev_complete,
361 .suspend = usb_dev_suspend,
362 .resume = usb_dev_resume,
363 .freeze = usb_dev_freeze,
364 .thaw = usb_dev_thaw,
365 .poweroff = usb_dev_poweroff,
366 .restore = usb_dev_restore,
367 .runtime_suspend = usb_runtime_suspend,
368 .runtime_resume = usb_runtime_resume,
369 .runtime_idle = usb_runtime_idle,
370};
371
372#endif
373
374
375static char *usb_devnode(struct device *dev,
376 umode_t *mode, kuid_t *uid, kgid_t *gid)
377{
378 struct usb_device *usb_dev;
379
380 usb_dev = to_usb_device(dev);
381 return kasprintf(GFP_KERNEL, "bus/usb/%03d/%03d",
382 usb_dev->bus->busnum, usb_dev->devnum);
383}
384
385struct device_type usb_device_type = {
386 .name = "usb_device",
387 .release = usb_release_dev,
388 .uevent = usb_dev_uevent,
389 .devnode = usb_devnode,
390#ifdef CONFIG_PM
391 .pm = &usb_device_pm_ops,
392#endif
393};
394
395
396
397static unsigned usb_bus_is_wusb(struct usb_bus *bus)
398{
399 struct usb_hcd *hcd = container_of(bus, struct usb_hcd, self);
400 return hcd->wireless;
401}
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419struct usb_device *usb_alloc_dev(struct usb_device *parent,
420 struct usb_bus *bus, unsigned port1)
421{
422 struct usb_device *dev;
423 struct usb_hcd *usb_hcd = bus_to_hcd(bus);
424 unsigned root_hub = 0;
425
426 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
427 if (!dev)
428 return NULL;
429
430 if (!usb_get_hcd(usb_hcd)) {
431 kfree(dev);
432 return NULL;
433 }
434
435 if (usb_hcd->driver->alloc_dev && parent &&
436 !usb_hcd->driver->alloc_dev(usb_hcd, dev)) {
437 usb_put_hcd(bus_to_hcd(bus));
438 kfree(dev);
439 return NULL;
440 }
441
442 device_initialize(&dev->dev);
443 dev->dev.bus = &usb_bus_type;
444 dev->dev.type = &usb_device_type;
445 dev->dev.groups = usb_device_groups;
446 dev->dev.dma_mask = bus->controller->dma_mask;
447 set_dev_node(&dev->dev, dev_to_node(bus->controller));
448 dev->state = USB_STATE_ATTACHED;
449 dev->lpm_disable_count = 1;
450 atomic_set(&dev->urbnum, 0);
451
452 INIT_LIST_HEAD(&dev->ep0.urb_list);
453 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
454 dev->ep0.desc.bDescriptorType = USB_DT_ENDPOINT;
455
456 usb_enable_endpoint(dev, &dev->ep0, false);
457 dev->can_submit = 1;
458
459
460
461
462
463
464
465
466
467 if (unlikely(!parent)) {
468 dev->devpath[0] = '0';
469 dev->route = 0;
470
471 dev->dev.parent = bus->controller;
472 dev_set_name(&dev->dev, "usb%d", bus->busnum);
473 root_hub = 1;
474 } else {
475
476 if (parent->devpath[0] == '0') {
477 snprintf(dev->devpath, sizeof dev->devpath,
478 "%d", port1);
479
480 dev->route = 0;
481 } else {
482 snprintf(dev->devpath, sizeof dev->devpath,
483 "%s.%d", parent->devpath, port1);
484
485 if (port1 < 15)
486 dev->route = parent->route +
487 (port1 << ((parent->level - 1)*4));
488 else
489 dev->route = parent->route +
490 (15 << ((parent->level - 1)*4));
491 }
492
493 dev->dev.parent = &parent->dev;
494 dev_set_name(&dev->dev, "%d-%s", bus->busnum, dev->devpath);
495
496
497 }
498
499 dev->portnum = port1;
500 dev->bus = bus;
501 dev->parent = parent;
502 INIT_LIST_HEAD(&dev->filelist);
503
504#ifdef CONFIG_PM
505 pm_runtime_set_autosuspend_delay(&dev->dev,
506 usb_autosuspend_delay * 1000);
507 dev->connect_time = jiffies;
508 dev->active_duration = -jiffies;
509#endif
510 if (root_hub)
511 dev->authorized = 1;
512 else {
513 dev->authorized = usb_hcd->authorized_default;
514 dev->wusb = usb_bus_is_wusb(bus) ? 1 : 0;
515 }
516 return dev;
517}
518EXPORT_SYMBOL_GPL(usb_alloc_dev);
519
520
521
522
523
524
525
526
527
528
529
530
531
532struct usb_device *usb_get_dev(struct usb_device *dev)
533{
534 if (dev)
535 get_device(&dev->dev);
536 return dev;
537}
538EXPORT_SYMBOL_GPL(usb_get_dev);
539
540
541
542
543
544
545
546
547void usb_put_dev(struct usb_device *dev)
548{
549 if (dev)
550 put_device(&dev->dev);
551}
552EXPORT_SYMBOL_GPL(usb_put_dev);
553
554
555
556
557
558
559
560
561
562
563
564
565
566struct usb_interface *usb_get_intf(struct usb_interface *intf)
567{
568 if (intf)
569 get_device(&intf->dev);
570 return intf;
571}
572EXPORT_SYMBOL_GPL(usb_get_intf);
573
574
575
576
577
578
579
580
581
582void usb_put_intf(struct usb_interface *intf)
583{
584 if (intf)
585 put_device(&intf->dev);
586}
587EXPORT_SYMBOL_GPL(usb_put_intf);
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619int usb_lock_device_for_reset(struct usb_device *udev,
620 const struct usb_interface *iface)
621{
622 unsigned long jiffies_expire = jiffies + HZ;
623
624 if (udev->state == USB_STATE_NOTATTACHED)
625 return -ENODEV;
626 if (udev->state == USB_STATE_SUSPENDED)
627 return -EHOSTUNREACH;
628 if (iface && (iface->condition == USB_INTERFACE_UNBINDING ||
629 iface->condition == USB_INTERFACE_UNBOUND))
630 return -EINTR;
631
632 while (!usb_trylock_device(udev)) {
633
634
635
636 if (time_after(jiffies, jiffies_expire))
637 return -EBUSY;
638
639 msleep(15);
640 if (udev->state == USB_STATE_NOTATTACHED)
641 return -ENODEV;
642 if (udev->state == USB_STATE_SUSPENDED)
643 return -EHOSTUNREACH;
644 if (iface && (iface->condition == USB_INTERFACE_UNBINDING ||
645 iface->condition == USB_INTERFACE_UNBOUND))
646 return -EINTR;
647 }
648 return 0;
649}
650EXPORT_SYMBOL_GPL(usb_lock_device_for_reset);
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666int usb_get_current_frame_number(struct usb_device *dev)
667{
668 return usb_hcd_get_frame_number(dev);
669}
670EXPORT_SYMBOL_GPL(usb_get_current_frame_number);
671
672
673
674
675
676
677
678int __usb_get_extra_descriptor(char *buffer, unsigned size,
679 unsigned char type, void **ptr)
680{
681 struct usb_descriptor_header *header;
682
683 while (size >= sizeof(struct usb_descriptor_header)) {
684 header = (struct usb_descriptor_header *)buffer;
685
686 if (header->bLength < 2) {
687 printk(KERN_ERR
688 "%s: bogus descriptor, type %d length %d\n",
689 usbcore_name,
690 header->bDescriptorType,
691 header->bLength);
692 return -1;
693 }
694
695 if (header->bDescriptorType == type) {
696 *ptr = header;
697 return 0;
698 }
699
700 buffer += header->bLength;
701 size -= header->bLength;
702 }
703 return -1;
704}
705EXPORT_SYMBOL_GPL(__usb_get_extra_descriptor);
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730void *usb_alloc_coherent(struct usb_device *dev, size_t size, gfp_t mem_flags,
731 dma_addr_t *dma)
732{
733 if (!dev || !dev->bus)
734 return NULL;
735 return hcd_buffer_alloc(dev->bus, size, mem_flags, dma);
736}
737EXPORT_SYMBOL_GPL(usb_alloc_coherent);
738
739
740
741
742
743
744
745
746
747
748
749
750void usb_free_coherent(struct usb_device *dev, size_t size, void *addr,
751 dma_addr_t dma)
752{
753 if (!dev || !dev->bus)
754 return;
755 if (!addr)
756 return;
757 hcd_buffer_free(dev->bus, size, addr, dma);
758}
759EXPORT_SYMBOL_GPL(usb_free_coherent);
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778#if 0
779struct urb *usb_buffer_map(struct urb *urb)
780{
781 struct usb_bus *bus;
782 struct device *controller;
783
784 if (!urb
785 || !urb->dev
786 || !(bus = urb->dev->bus)
787 || !(controller = bus->controller))
788 return NULL;
789
790 if (controller->dma_mask) {
791 urb->transfer_dma = dma_map_single(controller,
792 urb->transfer_buffer, urb->transfer_buffer_length,
793 usb_pipein(urb->pipe)
794 ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
795
796
797 } else
798 urb->transfer_dma = ~0;
799 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
800 return urb;
801}
802EXPORT_SYMBOL_GPL(usb_buffer_map);
803#endif
804
805
806
807
808
809
810#if 0
811
812
813
814
815
816void usb_buffer_dmasync(struct urb *urb)
817{
818 struct usb_bus *bus;
819 struct device *controller;
820
821 if (!urb
822 || !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)
823 || !urb->dev
824 || !(bus = urb->dev->bus)
825 || !(controller = bus->controller))
826 return;
827
828 if (controller->dma_mask) {
829 dma_sync_single_for_cpu(controller,
830 urb->transfer_dma, urb->transfer_buffer_length,
831 usb_pipein(urb->pipe)
832 ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
833 if (usb_pipecontrol(urb->pipe))
834 dma_sync_single_for_cpu(controller,
835 urb->setup_dma,
836 sizeof(struct usb_ctrlrequest),
837 DMA_TO_DEVICE);
838 }
839}
840EXPORT_SYMBOL_GPL(usb_buffer_dmasync);
841#endif
842
843
844
845
846
847
848
849#if 0
850void usb_buffer_unmap(struct urb *urb)
851{
852 struct usb_bus *bus;
853 struct device *controller;
854
855 if (!urb
856 || !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)
857 || !urb->dev
858 || !(bus = urb->dev->bus)
859 || !(controller = bus->controller))
860 return;
861
862 if (controller->dma_mask) {
863 dma_unmap_single(controller,
864 urb->transfer_dma, urb->transfer_buffer_length,
865 usb_pipein(urb->pipe)
866 ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
867 }
868 urb->transfer_flags &= ~URB_NO_TRANSFER_DMA_MAP;
869}
870EXPORT_SYMBOL_GPL(usb_buffer_unmap);
871#endif
872
873#if 0
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901int usb_buffer_map_sg(const struct usb_device *dev, int is_in,
902 struct scatterlist *sg, int nents)
903{
904 struct usb_bus *bus;
905 struct device *controller;
906
907 if (!dev
908 || !(bus = dev->bus)
909 || !(controller = bus->controller)
910 || !controller->dma_mask)
911 return -EINVAL;
912
913
914 return dma_map_sg(controller, sg, nents,
915 is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE) ? : -ENOMEM;
916}
917EXPORT_SYMBOL_GPL(usb_buffer_map_sg);
918#endif
919
920
921
922
923
924
925#if 0
926
927
928
929
930
931
932
933
934
935
936
937void usb_buffer_dmasync_sg(const struct usb_device *dev, int is_in,
938 struct scatterlist *sg, int n_hw_ents)
939{
940 struct usb_bus *bus;
941 struct device *controller;
942
943 if (!dev
944 || !(bus = dev->bus)
945 || !(controller = bus->controller)
946 || !controller->dma_mask)
947 return;
948
949 dma_sync_sg_for_cpu(controller, sg, n_hw_ents,
950 is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
951}
952EXPORT_SYMBOL_GPL(usb_buffer_dmasync_sg);
953#endif
954
955#if 0
956
957
958
959
960
961
962
963
964
965void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
966 struct scatterlist *sg, int n_hw_ents)
967{
968 struct usb_bus *bus;
969 struct device *controller;
970
971 if (!dev
972 || !(bus = dev->bus)
973 || !(controller = bus->controller)
974 || !controller->dma_mask)
975 return;
976
977 dma_unmap_sg(controller, sg, n_hw_ents,
978 is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
979}
980EXPORT_SYMBOL_GPL(usb_buffer_unmap_sg);
981#endif
982
983
984
985
986static int usb_bus_notify(struct notifier_block *nb, unsigned long action,
987 void *data)
988{
989 struct device *dev = data;
990
991 switch (action) {
992 case BUS_NOTIFY_ADD_DEVICE:
993 if (dev->type == &usb_device_type)
994 (void) usb_create_sysfs_dev_files(to_usb_device(dev));
995 else if (dev->type == &usb_if_device_type)
996 usb_create_sysfs_intf_files(to_usb_interface(dev));
997 break;
998
999 case BUS_NOTIFY_DEL_DEVICE:
1000 if (dev->type == &usb_device_type)
1001 usb_remove_sysfs_dev_files(to_usb_device(dev));
1002 else if (dev->type == &usb_if_device_type)
1003 usb_remove_sysfs_intf_files(to_usb_interface(dev));
1004 break;
1005 }
1006 return 0;
1007}
1008
1009static struct notifier_block usb_bus_nb = {
1010 .notifier_call = usb_bus_notify,
1011};
1012
1013struct dentry *usb_debug_root;
1014EXPORT_SYMBOL_GPL(usb_debug_root);
1015
1016static struct dentry *usb_debug_devices;
1017
1018static int usb_debugfs_init(void)
1019{
1020 usb_debug_root = debugfs_create_dir("usb", NULL);
1021 if (!usb_debug_root)
1022 return -ENOENT;
1023
1024 usb_debug_devices = debugfs_create_file("devices", 0444,
1025 usb_debug_root, NULL,
1026 &usbfs_devices_fops);
1027 if (!usb_debug_devices) {
1028 debugfs_remove(usb_debug_root);
1029 usb_debug_root = NULL;
1030 return -ENOENT;
1031 }
1032
1033 return 0;
1034}
1035
1036static void usb_debugfs_cleanup(void)
1037{
1038 debugfs_remove(usb_debug_devices);
1039 debugfs_remove(usb_debug_root);
1040}
1041
1042
1043
1044
1045static int __init usb_init(void)
1046{
1047 int retval;
1048 if (usb_disabled()) {
1049 pr_info("%s: USB support disabled\n", usbcore_name);
1050 return 0;
1051 }
1052 usb_init_pool_max();
1053
1054 retval = usb_debugfs_init();
1055 if (retval)
1056 goto out;
1057
1058 usb_acpi_register();
1059 retval = bus_register(&usb_bus_type);
1060 if (retval)
1061 goto bus_register_failed;
1062 retval = bus_register_notifier(&usb_bus_type, &usb_bus_nb);
1063 if (retval)
1064 goto bus_notifier_failed;
1065 retval = usb_major_init();
1066 if (retval)
1067 goto major_init_failed;
1068 retval = usb_register(&usbfs_driver);
1069 if (retval)
1070 goto driver_register_failed;
1071 retval = usb_devio_init();
1072 if (retval)
1073 goto usb_devio_init_failed;
1074 retval = usb_hub_init();
1075 if (retval)
1076 goto hub_init_failed;
1077 retval = usb_register_device_driver(&usb_generic_driver, THIS_MODULE);
1078 if (!retval)
1079 goto out;
1080
1081 usb_hub_cleanup();
1082hub_init_failed:
1083 usb_devio_cleanup();
1084usb_devio_init_failed:
1085 usb_deregister(&usbfs_driver);
1086driver_register_failed:
1087 usb_major_cleanup();
1088major_init_failed:
1089 bus_unregister_notifier(&usb_bus_type, &usb_bus_nb);
1090bus_notifier_failed:
1091 bus_unregister(&usb_bus_type);
1092bus_register_failed:
1093 usb_acpi_unregister();
1094 usb_debugfs_cleanup();
1095out:
1096 return retval;
1097}
1098
1099
1100
1101
1102static void __exit usb_exit(void)
1103{
1104
1105 if (usb_disabled())
1106 return;
1107
1108 usb_deregister_device_driver(&usb_generic_driver);
1109 usb_major_cleanup();
1110 usb_deregister(&usbfs_driver);
1111 usb_devio_cleanup();
1112 usb_hub_cleanup();
1113 bus_unregister_notifier(&usb_bus_type, &usb_bus_nb);
1114 bus_unregister(&usb_bus_type);
1115 usb_acpi_unregister();
1116 usb_debugfs_cleanup();
1117}
1118
1119subsys_initcall(usb_init);
1120module_exit(usb_exit);
1121MODULE_LICENSE("GPL");
1122