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