| .. | .. |
|---|
| 19 | 19 | * just a collection of helper routines that implement the |
|---|
| 20 | 20 | * generic USB things that the real drivers can use.. |
|---|
| 21 | 21 | * |
|---|
| 22 | | - * Think of this as a "USB library" rather than anything else. |
|---|
| 23 | | - * It should be considered a slave, with no callbacks. Callbacks |
|---|
| 24 | | - * are evil. |
|---|
| 22 | + * Think of this as a "USB library" rather than anything else, |
|---|
| 23 | + * with no callbacks. Callbacks are evil. |
|---|
| 25 | 24 | */ |
|---|
| 26 | 25 | |
|---|
| 27 | 26 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 46 | 45 | #include <linux/mm.h> |
|---|
| 47 | 46 | #include <linux/dma-mapping.h> |
|---|
| 48 | 47 | |
|---|
| 49 | | -#include "usb.h" |
|---|
| 50 | | - |
|---|
| 48 | +#include "hub.h" |
|---|
| 51 | 49 | |
|---|
| 52 | 50 | const char *usbcore_name = "usbcore"; |
|---|
| 53 | 51 | |
|---|
| .. | .. |
|---|
| 65 | 63 | EXPORT_SYMBOL_GPL(usb_disabled); |
|---|
| 66 | 64 | |
|---|
| 67 | 65 | #ifdef CONFIG_PM |
|---|
| 68 | | -static int usb_autosuspend_delay = 2; /* Default delay value, |
|---|
| 69 | | - * in seconds */ |
|---|
| 66 | +/* Default delay value, in seconds */ |
|---|
| 67 | +static int usb_autosuspend_delay = CONFIG_USB_AUTOSUSPEND_DELAY; |
|---|
| 70 | 68 | module_param_named(autosuspend, usb_autosuspend_delay, int, 0644); |
|---|
| 71 | 69 | MODULE_PARM_DESC(autosuspend, "default autosuspend delay"); |
|---|
| 72 | 70 | |
|---|
| .. | .. |
|---|
| 326 | 324 | struct device_driver *drv; |
|---|
| 327 | 325 | }; |
|---|
| 328 | 326 | |
|---|
| 329 | | -static int __find_interface(struct device *dev, void *data) |
|---|
| 327 | +static int __find_interface(struct device *dev, const void *data) |
|---|
| 330 | 328 | { |
|---|
| 331 | | - struct find_interface_arg *arg = data; |
|---|
| 329 | + const struct find_interface_arg *arg = data; |
|---|
| 332 | 330 | struct usb_interface *intf; |
|---|
| 333 | 331 | |
|---|
| 334 | 332 | if (!is_usb_interface(dev)) |
|---|
| .. | .. |
|---|
| 536 | 534 | return hcd->wireless; |
|---|
| 537 | 535 | } |
|---|
| 538 | 536 | |
|---|
| 537 | +static bool usb_dev_authorized(struct usb_device *dev, struct usb_hcd *hcd) |
|---|
| 538 | +{ |
|---|
| 539 | + struct usb_hub *hub; |
|---|
| 540 | + |
|---|
| 541 | + if (!dev->parent) |
|---|
| 542 | + return true; /* Root hub always ok [and always wired] */ |
|---|
| 543 | + |
|---|
| 544 | + switch (hcd->dev_policy) { |
|---|
| 545 | + case USB_DEVICE_AUTHORIZE_NONE: |
|---|
| 546 | + default: |
|---|
| 547 | + return false; |
|---|
| 548 | + |
|---|
| 549 | + case USB_DEVICE_AUTHORIZE_ALL: |
|---|
| 550 | + return true; |
|---|
| 551 | + |
|---|
| 552 | + case USB_DEVICE_AUTHORIZE_INTERNAL: |
|---|
| 553 | + hub = usb_hub_to_struct_hub(dev->parent); |
|---|
| 554 | + return hub->ports[dev->portnum - 1]->connect_type == |
|---|
| 555 | + USB_PORT_CONNECT_TYPE_HARD_WIRED; |
|---|
| 556 | + } |
|---|
| 557 | +} |
|---|
| 539 | 558 | |
|---|
| 540 | 559 | /** |
|---|
| 541 | 560 | * usb_alloc_dev - usb device constructor (usbcore-internal) |
|---|
| .. | .. |
|---|
| 580 | 599 | dev->dev.bus = &usb_bus_type; |
|---|
| 581 | 600 | dev->dev.type = &usb_device_type; |
|---|
| 582 | 601 | dev->dev.groups = usb_device_groups; |
|---|
| 583 | | - /* |
|---|
| 584 | | - * Fake a dma_mask/offset for the USB device: |
|---|
| 585 | | - * We cannot really use the dma-mapping API (dma_alloc_* and |
|---|
| 586 | | - * dma_map_*) for USB devices but instead need to use |
|---|
| 587 | | - * usb_alloc_coherent and pass data in 'urb's, but some subsystems |
|---|
| 588 | | - * manually look into the mask/offset pair to determine whether |
|---|
| 589 | | - * they need bounce buffers. |
|---|
| 590 | | - * Note: calling dma_set_mask() on a USB device would set the |
|---|
| 591 | | - * mask for the entire HCD, so don't do that. |
|---|
| 592 | | - */ |
|---|
| 593 | | - dev->dev.dma_mask = bus->sysdev->dma_mask; |
|---|
| 594 | | - dev->dev.dma_pfn_offset = bus->sysdev->dma_pfn_offset; |
|---|
| 595 | 602 | set_dev_node(&dev->dev, dev_to_node(bus->sysdev)); |
|---|
| 596 | 603 | dev->state = USB_STATE_ATTACHED; |
|---|
| 597 | 604 | dev->lpm_disable_count = 1; |
|---|
| .. | .. |
|---|
| 663 | 670 | dev->connect_time = jiffies; |
|---|
| 664 | 671 | dev->active_duration = -jiffies; |
|---|
| 665 | 672 | #endif |
|---|
| 666 | | - if (root_hub) /* Root hub always ok [and always wired] */ |
|---|
| 667 | | - dev->authorized = 1; |
|---|
| 668 | | - else { |
|---|
| 669 | | - dev->authorized = !!HCD_DEV_AUTHORIZED(usb_hcd); |
|---|
| 673 | + |
|---|
| 674 | + dev->authorized = usb_dev_authorized(dev, usb_hcd); |
|---|
| 675 | + if (!root_hub) |
|---|
| 670 | 676 | dev->wusb = usb_bus_is_wusb(bus) ? 1 : 0; |
|---|
| 671 | | - } |
|---|
| 677 | + |
|---|
| 672 | 678 | return dev; |
|---|
| 673 | 679 | } |
|---|
| 674 | 680 | EXPORT_SYMBOL_GPL(usb_alloc_dev); |
|---|
| .. | .. |
|---|
| 741 | 747 | put_device(&intf->dev); |
|---|
| 742 | 748 | } |
|---|
| 743 | 749 | EXPORT_SYMBOL_GPL(usb_put_intf); |
|---|
| 750 | + |
|---|
| 751 | +/** |
|---|
| 752 | + * usb_intf_get_dma_device - acquire a reference on the usb interface's DMA endpoint |
|---|
| 753 | + * @intf: the usb interface |
|---|
| 754 | + * |
|---|
| 755 | + * While a USB device cannot perform DMA operations by itself, many USB |
|---|
| 756 | + * controllers can. A call to usb_intf_get_dma_device() returns the DMA endpoint |
|---|
| 757 | + * for the given USB interface, if any. The returned device structure must be |
|---|
| 758 | + * released with put_device(). |
|---|
| 759 | + * |
|---|
| 760 | + * See also usb_get_dma_device(). |
|---|
| 761 | + * |
|---|
| 762 | + * Returns: A reference to the usb interface's DMA endpoint; or NULL if none |
|---|
| 763 | + * exists. |
|---|
| 764 | + */ |
|---|
| 765 | +struct device *usb_intf_get_dma_device(struct usb_interface *intf) |
|---|
| 766 | +{ |
|---|
| 767 | + struct usb_device *udev = interface_to_usbdev(intf); |
|---|
| 768 | + struct device *dmadev; |
|---|
| 769 | + |
|---|
| 770 | + if (!udev->bus) |
|---|
| 771 | + return NULL; |
|---|
| 772 | + |
|---|
| 773 | + dmadev = get_device(udev->bus->sysdev); |
|---|
| 774 | + if (!dmadev || !dmadev->dma_mask) { |
|---|
| 775 | + put_device(dmadev); |
|---|
| 776 | + return NULL; |
|---|
| 777 | + } |
|---|
| 778 | + |
|---|
| 779 | + return dmadev; |
|---|
| 780 | +} |
|---|
| 781 | +EXPORT_SYMBOL_GPL(usb_intf_get_dma_device); |
|---|
| 744 | 782 | |
|---|
| 745 | 783 | /* USB device locking |
|---|
| 746 | 784 | * |
|---|
| .. | .. |
|---|
| 824 | 862 | return usb_hcd_get_frame_number(dev); |
|---|
| 825 | 863 | } |
|---|
| 826 | 864 | EXPORT_SYMBOL_GPL(usb_get_current_frame_number); |
|---|
| 827 | | - |
|---|
| 828 | | -int usb_sec_event_ring_setup(struct usb_device *dev, |
|---|
| 829 | | - unsigned int intr_num) |
|---|
| 830 | | -{ |
|---|
| 831 | | - if (dev->state == USB_STATE_NOTATTACHED) |
|---|
| 832 | | - return 0; |
|---|
| 833 | | - |
|---|
| 834 | | - return usb_hcd_sec_event_ring_setup(dev, intr_num); |
|---|
| 835 | | -} |
|---|
| 836 | | -EXPORT_SYMBOL(usb_sec_event_ring_setup); |
|---|
| 837 | | - |
|---|
| 838 | | -int usb_sec_event_ring_cleanup(struct usb_device *dev, |
|---|
| 839 | | - unsigned int intr_num) |
|---|
| 840 | | -{ |
|---|
| 841 | | - return usb_hcd_sec_event_ring_cleanup(dev, intr_num); |
|---|
| 842 | | -} |
|---|
| 843 | | -EXPORT_SYMBOL(usb_sec_event_ring_cleanup); |
|---|
| 844 | | - |
|---|
| 845 | | -phys_addr_t |
|---|
| 846 | | -usb_get_sec_event_ring_phys_addr(struct usb_device *dev, |
|---|
| 847 | | - unsigned int intr_num, dma_addr_t *dma) |
|---|
| 848 | | -{ |
|---|
| 849 | | - if (dev->state == USB_STATE_NOTATTACHED) |
|---|
| 850 | | - return 0; |
|---|
| 851 | | - |
|---|
| 852 | | - return usb_hcd_get_sec_event_ring_phys_addr(dev, intr_num, dma); |
|---|
| 853 | | -} |
|---|
| 854 | | -EXPORT_SYMBOL_GPL(usb_get_sec_event_ring_phys_addr); |
|---|
| 855 | | - |
|---|
| 856 | | -phys_addr_t usb_get_xfer_ring_phys_addr(struct usb_device *dev, |
|---|
| 857 | | - struct usb_host_endpoint *ep, dma_addr_t *dma) |
|---|
| 858 | | -{ |
|---|
| 859 | | - if (dev->state == USB_STATE_NOTATTACHED) |
|---|
| 860 | | - return 0; |
|---|
| 861 | | - |
|---|
| 862 | | - return usb_hcd_get_xfer_ring_phys_addr(dev, ep, dma); |
|---|
| 863 | | -} |
|---|
| 864 | | -EXPORT_SYMBOL_GPL(usb_get_xfer_ring_phys_addr); |
|---|
| 865 | | - |
|---|
| 866 | | -/** |
|---|
| 867 | | - * usb_get_controller_id - returns the host controller id. |
|---|
| 868 | | - * @dev: the device whose host controller id is being queried. |
|---|
| 869 | | - */ |
|---|
| 870 | | -int usb_get_controller_id(struct usb_device *dev) |
|---|
| 871 | | -{ |
|---|
| 872 | | - if (dev->state == USB_STATE_NOTATTACHED) |
|---|
| 873 | | - return -EINVAL; |
|---|
| 874 | | - |
|---|
| 875 | | - return usb_hcd_get_controller_id(dev); |
|---|
| 876 | | -} |
|---|
| 877 | | -EXPORT_SYMBOL_GPL(usb_get_controller_id); |
|---|
| 878 | | - |
|---|
| 879 | | -int usb_stop_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep) |
|---|
| 880 | | -{ |
|---|
| 881 | | - return usb_hcd_stop_endpoint(dev, ep); |
|---|
| 882 | | -} |
|---|
| 883 | | -EXPORT_SYMBOL_GPL(usb_stop_endpoint); |
|---|
| 884 | 865 | |
|---|
| 885 | 866 | /*-------------------------------------------------------------------*/ |
|---|
| 886 | 867 | /* |
|---|
| .. | .. |
|---|
| 971 | 952 | } |
|---|
| 972 | 953 | EXPORT_SYMBOL_GPL(usb_free_coherent); |
|---|
| 973 | 954 | |
|---|
| 974 | | -/** |
|---|
| 975 | | - * usb_buffer_map - create DMA mapping(s) for an urb |
|---|
| 976 | | - * @urb: urb whose transfer_buffer/setup_packet will be mapped |
|---|
| 977 | | - * |
|---|
| 978 | | - * URB_NO_TRANSFER_DMA_MAP is added to urb->transfer_flags if the operation |
|---|
| 979 | | - * succeeds. If the device is connected to this system through a non-DMA |
|---|
| 980 | | - * controller, this operation always succeeds. |
|---|
| 981 | | - * |
|---|
| 982 | | - * This call would normally be used for an urb which is reused, perhaps |
|---|
| 983 | | - * as the target of a large periodic transfer, with usb_buffer_dmasync() |
|---|
| 984 | | - * calls to synchronize memory and dma state. |
|---|
| 985 | | - * |
|---|
| 986 | | - * Reverse the effect of this call with usb_buffer_unmap(). |
|---|
| 987 | | - * |
|---|
| 988 | | - * Return: Either %NULL (indicating no buffer could be mapped), or @urb. |
|---|
| 989 | | - * |
|---|
| 990 | | - */ |
|---|
| 991 | | -#if 0 |
|---|
| 992 | | -struct urb *usb_buffer_map(struct urb *urb) |
|---|
| 993 | | -{ |
|---|
| 994 | | - struct usb_bus *bus; |
|---|
| 995 | | - struct device *controller; |
|---|
| 996 | | - |
|---|
| 997 | | - if (!urb |
|---|
| 998 | | - || !urb->dev |
|---|
| 999 | | - || !(bus = urb->dev->bus) |
|---|
| 1000 | | - || !(controller = bus->sysdev)) |
|---|
| 1001 | | - return NULL; |
|---|
| 1002 | | - |
|---|
| 1003 | | - if (controller->dma_mask) { |
|---|
| 1004 | | - urb->transfer_dma = dma_map_single(controller, |
|---|
| 1005 | | - urb->transfer_buffer, urb->transfer_buffer_length, |
|---|
| 1006 | | - usb_pipein(urb->pipe) |
|---|
| 1007 | | - ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
|---|
| 1008 | | - /* FIXME generic api broken like pci, can't report errors */ |
|---|
| 1009 | | - /* if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; */ |
|---|
| 1010 | | - } else |
|---|
| 1011 | | - urb->transfer_dma = ~0; |
|---|
| 1012 | | - urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
|---|
| 1013 | | - return urb; |
|---|
| 1014 | | -} |
|---|
| 1015 | | -EXPORT_SYMBOL_GPL(usb_buffer_map); |
|---|
| 1016 | | -#endif /* 0 */ |
|---|
| 1017 | | - |
|---|
| 1018 | | -/* XXX DISABLED, no users currently. If you wish to re-enable this |
|---|
| 1019 | | - * XXX please determine whether the sync is to transfer ownership of |
|---|
| 1020 | | - * XXX the buffer from device to cpu or vice verse, and thusly use the |
|---|
| 1021 | | - * XXX appropriate _for_{cpu,device}() method. -DaveM |
|---|
| 1022 | | - */ |
|---|
| 1023 | | -#if 0 |
|---|
| 1024 | | - |
|---|
| 1025 | | -/** |
|---|
| 1026 | | - * usb_buffer_dmasync - synchronize DMA and CPU view of buffer(s) |
|---|
| 1027 | | - * @urb: urb whose transfer_buffer/setup_packet will be synchronized |
|---|
| 1028 | | - */ |
|---|
| 1029 | | -void usb_buffer_dmasync(struct urb *urb) |
|---|
| 1030 | | -{ |
|---|
| 1031 | | - struct usb_bus *bus; |
|---|
| 1032 | | - struct device *controller; |
|---|
| 1033 | | - |
|---|
| 1034 | | - if (!urb |
|---|
| 1035 | | - || !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) |
|---|
| 1036 | | - || !urb->dev |
|---|
| 1037 | | - || !(bus = urb->dev->bus) |
|---|
| 1038 | | - || !(controller = bus->sysdev)) |
|---|
| 1039 | | - return; |
|---|
| 1040 | | - |
|---|
| 1041 | | - if (controller->dma_mask) { |
|---|
| 1042 | | - dma_sync_single_for_cpu(controller, |
|---|
| 1043 | | - urb->transfer_dma, urb->transfer_buffer_length, |
|---|
| 1044 | | - usb_pipein(urb->pipe) |
|---|
| 1045 | | - ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
|---|
| 1046 | | - if (usb_pipecontrol(urb->pipe)) |
|---|
| 1047 | | - dma_sync_single_for_cpu(controller, |
|---|
| 1048 | | - urb->setup_dma, |
|---|
| 1049 | | - sizeof(struct usb_ctrlrequest), |
|---|
| 1050 | | - DMA_TO_DEVICE); |
|---|
| 1051 | | - } |
|---|
| 1052 | | -} |
|---|
| 1053 | | -EXPORT_SYMBOL_GPL(usb_buffer_dmasync); |
|---|
| 1054 | | -#endif |
|---|
| 1055 | | - |
|---|
| 1056 | | -/** |
|---|
| 1057 | | - * usb_buffer_unmap - free DMA mapping(s) for an urb |
|---|
| 1058 | | - * @urb: urb whose transfer_buffer will be unmapped |
|---|
| 1059 | | - * |
|---|
| 1060 | | - * Reverses the effect of usb_buffer_map(). |
|---|
| 1061 | | - */ |
|---|
| 1062 | | -#if 0 |
|---|
| 1063 | | -void usb_buffer_unmap(struct urb *urb) |
|---|
| 1064 | | -{ |
|---|
| 1065 | | - struct usb_bus *bus; |
|---|
| 1066 | | - struct device *controller; |
|---|
| 1067 | | - |
|---|
| 1068 | | - if (!urb |
|---|
| 1069 | | - || !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) |
|---|
| 1070 | | - || !urb->dev |
|---|
| 1071 | | - || !(bus = urb->dev->bus) |
|---|
| 1072 | | - || !(controller = bus->sysdev)) |
|---|
| 1073 | | - return; |
|---|
| 1074 | | - |
|---|
| 1075 | | - if (controller->dma_mask) { |
|---|
| 1076 | | - dma_unmap_single(controller, |
|---|
| 1077 | | - urb->transfer_dma, urb->transfer_buffer_length, |
|---|
| 1078 | | - usb_pipein(urb->pipe) |
|---|
| 1079 | | - ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
|---|
| 1080 | | - } |
|---|
| 1081 | | - urb->transfer_flags &= ~URB_NO_TRANSFER_DMA_MAP; |
|---|
| 1082 | | -} |
|---|
| 1083 | | -EXPORT_SYMBOL_GPL(usb_buffer_unmap); |
|---|
| 1084 | | -#endif /* 0 */ |
|---|
| 1085 | | - |
|---|
| 1086 | | -#if 0 |
|---|
| 1087 | | -/** |
|---|
| 1088 | | - * usb_buffer_map_sg - create scatterlist DMA mapping(s) for an endpoint |
|---|
| 1089 | | - * @dev: device to which the scatterlist will be mapped |
|---|
| 1090 | | - * @is_in: mapping transfer direction |
|---|
| 1091 | | - * @sg: the scatterlist to map |
|---|
| 1092 | | - * @nents: the number of entries in the scatterlist |
|---|
| 1093 | | - * |
|---|
| 1094 | | - * Return: Either < 0 (indicating no buffers could be mapped), or the |
|---|
| 1095 | | - * number of DMA mapping array entries in the scatterlist. |
|---|
| 1096 | | - * |
|---|
| 1097 | | - * Note: |
|---|
| 1098 | | - * The caller is responsible for placing the resulting DMA addresses from |
|---|
| 1099 | | - * the scatterlist into URB transfer buffer pointers, and for setting the |
|---|
| 1100 | | - * URB_NO_TRANSFER_DMA_MAP transfer flag in each of those URBs. |
|---|
| 1101 | | - * |
|---|
| 1102 | | - * Top I/O rates come from queuing URBs, instead of waiting for each one |
|---|
| 1103 | | - * to complete before starting the next I/O. This is particularly easy |
|---|
| 1104 | | - * to do with scatterlists. Just allocate and submit one URB for each DMA |
|---|
| 1105 | | - * mapping entry returned, stopping on the first error or when all succeed. |
|---|
| 1106 | | - * Better yet, use the usb_sg_*() calls, which do that (and more) for you. |
|---|
| 1107 | | - * |
|---|
| 1108 | | - * This call would normally be used when translating scatterlist requests, |
|---|
| 1109 | | - * rather than usb_buffer_map(), since on some hardware (with IOMMUs) it |
|---|
| 1110 | | - * may be able to coalesce mappings for improved I/O efficiency. |
|---|
| 1111 | | - * |
|---|
| 1112 | | - * Reverse the effect of this call with usb_buffer_unmap_sg(). |
|---|
| 1113 | | - */ |
|---|
| 1114 | | -int usb_buffer_map_sg(const struct usb_device *dev, int is_in, |
|---|
| 1115 | | - struct scatterlist *sg, int nents) |
|---|
| 1116 | | -{ |
|---|
| 1117 | | - struct usb_bus *bus; |
|---|
| 1118 | | - struct device *controller; |
|---|
| 1119 | | - |
|---|
| 1120 | | - if (!dev |
|---|
| 1121 | | - || !(bus = dev->bus) |
|---|
| 1122 | | - || !(controller = bus->sysdev) |
|---|
| 1123 | | - || !controller->dma_mask) |
|---|
| 1124 | | - return -EINVAL; |
|---|
| 1125 | | - |
|---|
| 1126 | | - /* FIXME generic api broken like pci, can't report errors */ |
|---|
| 1127 | | - return dma_map_sg(controller, sg, nents, |
|---|
| 1128 | | - is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE) ? : -ENOMEM; |
|---|
| 1129 | | -} |
|---|
| 1130 | | -EXPORT_SYMBOL_GPL(usb_buffer_map_sg); |
|---|
| 1131 | | -#endif |
|---|
| 1132 | | - |
|---|
| 1133 | | -/* XXX DISABLED, no users currently. If you wish to re-enable this |
|---|
| 1134 | | - * XXX please determine whether the sync is to transfer ownership of |
|---|
| 1135 | | - * XXX the buffer from device to cpu or vice verse, and thusly use the |
|---|
| 1136 | | - * XXX appropriate _for_{cpu,device}() method. -DaveM |
|---|
| 1137 | | - */ |
|---|
| 1138 | | -#if 0 |
|---|
| 1139 | | - |
|---|
| 1140 | | -/** |
|---|
| 1141 | | - * usb_buffer_dmasync_sg - synchronize DMA and CPU view of scatterlist buffer(s) |
|---|
| 1142 | | - * @dev: device to which the scatterlist will be mapped |
|---|
| 1143 | | - * @is_in: mapping transfer direction |
|---|
| 1144 | | - * @sg: the scatterlist to synchronize |
|---|
| 1145 | | - * @n_hw_ents: the positive return value from usb_buffer_map_sg |
|---|
| 1146 | | - * |
|---|
| 1147 | | - * Use this when you are re-using a scatterlist's data buffers for |
|---|
| 1148 | | - * another USB request. |
|---|
| 1149 | | - */ |
|---|
| 1150 | | -void usb_buffer_dmasync_sg(const struct usb_device *dev, int is_in, |
|---|
| 1151 | | - struct scatterlist *sg, int n_hw_ents) |
|---|
| 1152 | | -{ |
|---|
| 1153 | | - struct usb_bus *bus; |
|---|
| 1154 | | - struct device *controller; |
|---|
| 1155 | | - |
|---|
| 1156 | | - if (!dev |
|---|
| 1157 | | - || !(bus = dev->bus) |
|---|
| 1158 | | - || !(controller = bus->sysdev) |
|---|
| 1159 | | - || !controller->dma_mask) |
|---|
| 1160 | | - return; |
|---|
| 1161 | | - |
|---|
| 1162 | | - dma_sync_sg_for_cpu(controller, sg, n_hw_ents, |
|---|
| 1163 | | - is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
|---|
| 1164 | | -} |
|---|
| 1165 | | -EXPORT_SYMBOL_GPL(usb_buffer_dmasync_sg); |
|---|
| 1166 | | -#endif |
|---|
| 1167 | | - |
|---|
| 1168 | | -#if 0 |
|---|
| 1169 | | -/** |
|---|
| 1170 | | - * usb_buffer_unmap_sg - free DMA mapping(s) for a scatterlist |
|---|
| 1171 | | - * @dev: device to which the scatterlist will be mapped |
|---|
| 1172 | | - * @is_in: mapping transfer direction |
|---|
| 1173 | | - * @sg: the scatterlist to unmap |
|---|
| 1174 | | - * @n_hw_ents: the positive return value from usb_buffer_map_sg |
|---|
| 1175 | | - * |
|---|
| 1176 | | - * Reverses the effect of usb_buffer_map_sg(). |
|---|
| 1177 | | - */ |
|---|
| 1178 | | -void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in, |
|---|
| 1179 | | - struct scatterlist *sg, int n_hw_ents) |
|---|
| 1180 | | -{ |
|---|
| 1181 | | - struct usb_bus *bus; |
|---|
| 1182 | | - struct device *controller; |
|---|
| 1183 | | - |
|---|
| 1184 | | - if (!dev |
|---|
| 1185 | | - || !(bus = dev->bus) |
|---|
| 1186 | | - || !(controller = bus->sysdev) |
|---|
| 1187 | | - || !controller->dma_mask) |
|---|
| 1188 | | - return; |
|---|
| 1189 | | - |
|---|
| 1190 | | - dma_unmap_sg(controller, sg, n_hw_ents, |
|---|
| 1191 | | - is_in ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
|---|
| 1192 | | -} |
|---|
| 1193 | | -EXPORT_SYMBOL_GPL(usb_buffer_unmap_sg); |
|---|
| 1194 | | -#endif |
|---|
| 1195 | | - |
|---|
| 1196 | 955 | /* |
|---|
| 1197 | 956 | * Notifications of device and interface registration |
|---|
| 1198 | 957 | */ |
|---|
| .. | .. |
|---|
| 1223 | 982 | .notifier_call = usb_bus_notify, |
|---|
| 1224 | 983 | }; |
|---|
| 1225 | 984 | |
|---|
| 1226 | | -struct dentry *usb_debug_root; |
|---|
| 1227 | | -EXPORT_SYMBOL_GPL(usb_debug_root); |
|---|
| 985 | +static struct dentry *usb_devices_root; |
|---|
| 1228 | 986 | |
|---|
| 1229 | 987 | static void usb_debugfs_init(void) |
|---|
| 1230 | 988 | { |
|---|
| 1231 | | - usb_debug_root = debugfs_create_dir("usb", NULL); |
|---|
| 1232 | | - debugfs_create_file("devices", 0444, usb_debug_root, NULL, |
|---|
| 1233 | | - &usbfs_devices_fops); |
|---|
| 989 | + usb_devices_root = debugfs_create_file("devices", 0444, usb_debug_root, |
|---|
| 990 | + NULL, &usbfs_devices_fops); |
|---|
| 1234 | 991 | } |
|---|
| 1235 | 992 | |
|---|
| 1236 | 993 | static void usb_debugfs_cleanup(void) |
|---|
| 1237 | 994 | { |
|---|
| 1238 | | - debugfs_remove_recursive(usb_debug_root); |
|---|
| 995 | + debugfs_remove(usb_devices_root); |
|---|
| 1239 | 996 | } |
|---|
| 1240 | 997 | |
|---|
| 1241 | 998 | /* |
|---|