.. | .. |
---|
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 | |
---|
.. | .. |
---|
210 | 208 | EXPORT_SYMBOL_GPL(usb_find_common_endpoints_reverse); |
---|
211 | 209 | |
---|
212 | 210 | /** |
---|
| 211 | + * usb_find_endpoint() - Given an endpoint address, search for the endpoint's |
---|
| 212 | + * usb_host_endpoint structure in an interface's current altsetting. |
---|
| 213 | + * @intf: the interface whose current altsetting should be searched |
---|
| 214 | + * @ep_addr: the endpoint address (number and direction) to find |
---|
| 215 | + * |
---|
| 216 | + * Search the altsetting's list of endpoints for one with the specified address. |
---|
| 217 | + * |
---|
| 218 | + * Return: Pointer to the usb_host_endpoint if found, %NULL otherwise. |
---|
| 219 | + */ |
---|
| 220 | +static const struct usb_host_endpoint *usb_find_endpoint( |
---|
| 221 | + const struct usb_interface *intf, unsigned int ep_addr) |
---|
| 222 | +{ |
---|
| 223 | + int n; |
---|
| 224 | + const struct usb_host_endpoint *ep; |
---|
| 225 | + |
---|
| 226 | + n = intf->cur_altsetting->desc.bNumEndpoints; |
---|
| 227 | + ep = intf->cur_altsetting->endpoint; |
---|
| 228 | + for (; n > 0; (--n, ++ep)) { |
---|
| 229 | + if (ep->desc.bEndpointAddress == ep_addr) |
---|
| 230 | + return ep; |
---|
| 231 | + } |
---|
| 232 | + return NULL; |
---|
| 233 | +} |
---|
| 234 | + |
---|
| 235 | +/** |
---|
| 236 | + * usb_check_bulk_endpoints - Check whether an interface's current altsetting |
---|
| 237 | + * contains a set of bulk endpoints with the given addresses. |
---|
| 238 | + * @intf: the interface whose current altsetting should be searched |
---|
| 239 | + * @ep_addrs: 0-terminated array of the endpoint addresses (number and |
---|
| 240 | + * direction) to look for |
---|
| 241 | + * |
---|
| 242 | + * Search for endpoints with the specified addresses and check their types. |
---|
| 243 | + * |
---|
| 244 | + * Return: %true if all the endpoints are found and are bulk, %false otherwise. |
---|
| 245 | + */ |
---|
| 246 | +bool usb_check_bulk_endpoints( |
---|
| 247 | + const struct usb_interface *intf, const u8 *ep_addrs) |
---|
| 248 | +{ |
---|
| 249 | + const struct usb_host_endpoint *ep; |
---|
| 250 | + |
---|
| 251 | + for (; *ep_addrs; ++ep_addrs) { |
---|
| 252 | + ep = usb_find_endpoint(intf, *ep_addrs); |
---|
| 253 | + if (!ep || !usb_endpoint_xfer_bulk(&ep->desc)) |
---|
| 254 | + return false; |
---|
| 255 | + } |
---|
| 256 | + return true; |
---|
| 257 | +} |
---|
| 258 | +EXPORT_SYMBOL_GPL(usb_check_bulk_endpoints); |
---|
| 259 | + |
---|
| 260 | +/** |
---|
| 261 | + * usb_check_int_endpoints - Check whether an interface's current altsetting |
---|
| 262 | + * contains a set of interrupt endpoints with the given addresses. |
---|
| 263 | + * @intf: the interface whose current altsetting should be searched |
---|
| 264 | + * @ep_addrs: 0-terminated array of the endpoint addresses (number and |
---|
| 265 | + * direction) to look for |
---|
| 266 | + * |
---|
| 267 | + * Search for endpoints with the specified addresses and check their types. |
---|
| 268 | + * |
---|
| 269 | + * Return: %true if all the endpoints are found and are interrupt, |
---|
| 270 | + * %false otherwise. |
---|
| 271 | + */ |
---|
| 272 | +bool usb_check_int_endpoints( |
---|
| 273 | + const struct usb_interface *intf, const u8 *ep_addrs) |
---|
| 274 | +{ |
---|
| 275 | + const struct usb_host_endpoint *ep; |
---|
| 276 | + |
---|
| 277 | + for (; *ep_addrs; ++ep_addrs) { |
---|
| 278 | + ep = usb_find_endpoint(intf, *ep_addrs); |
---|
| 279 | + if (!ep || !usb_endpoint_xfer_int(&ep->desc)) |
---|
| 280 | + return false; |
---|
| 281 | + } |
---|
| 282 | + return true; |
---|
| 283 | +} |
---|
| 284 | +EXPORT_SYMBOL_GPL(usb_check_int_endpoints); |
---|
| 285 | + |
---|
| 286 | +/** |
---|
213 | 287 | * usb_find_alt_setting() - Given a configuration, find the alternate setting |
---|
214 | 288 | * for the given interface. |
---|
215 | 289 | * @config: the configuration to search (not necessarily the current config). |
---|
.. | .. |
---|
326 | 400 | struct device_driver *drv; |
---|
327 | 401 | }; |
---|
328 | 402 | |
---|
329 | | -static int __find_interface(struct device *dev, void *data) |
---|
| 403 | +static int __find_interface(struct device *dev, const void *data) |
---|
330 | 404 | { |
---|
331 | | - struct find_interface_arg *arg = data; |
---|
| 405 | + const struct find_interface_arg *arg = data; |
---|
332 | 406 | struct usb_interface *intf; |
---|
333 | 407 | |
---|
334 | 408 | if (!is_usb_interface(dev)) |
---|
.. | .. |
---|
536 | 610 | return hcd->wireless; |
---|
537 | 611 | } |
---|
538 | 612 | |
---|
| 613 | +static bool usb_dev_authorized(struct usb_device *dev, struct usb_hcd *hcd) |
---|
| 614 | +{ |
---|
| 615 | + struct usb_hub *hub; |
---|
| 616 | + |
---|
| 617 | + if (!dev->parent) |
---|
| 618 | + return true; /* Root hub always ok [and always wired] */ |
---|
| 619 | + |
---|
| 620 | + switch (hcd->dev_policy) { |
---|
| 621 | + case USB_DEVICE_AUTHORIZE_NONE: |
---|
| 622 | + default: |
---|
| 623 | + return false; |
---|
| 624 | + |
---|
| 625 | + case USB_DEVICE_AUTHORIZE_ALL: |
---|
| 626 | + return true; |
---|
| 627 | + |
---|
| 628 | + case USB_DEVICE_AUTHORIZE_INTERNAL: |
---|
| 629 | + hub = usb_hub_to_struct_hub(dev->parent); |
---|
| 630 | + return hub->ports[dev->portnum - 1]->connect_type == |
---|
| 631 | + USB_PORT_CONNECT_TYPE_HARD_WIRED; |
---|
| 632 | + } |
---|
| 633 | +} |
---|
539 | 634 | |
---|
540 | 635 | /** |
---|
541 | 636 | * usb_alloc_dev - usb device constructor (usbcore-internal) |
---|
.. | .. |
---|
580 | 675 | dev->dev.bus = &usb_bus_type; |
---|
581 | 676 | dev->dev.type = &usb_device_type; |
---|
582 | 677 | 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 | 678 | set_dev_node(&dev->dev, dev_to_node(bus->sysdev)); |
---|
596 | 679 | dev->state = USB_STATE_ATTACHED; |
---|
597 | 680 | dev->lpm_disable_count = 1; |
---|
.. | .. |
---|
663 | 746 | dev->connect_time = jiffies; |
---|
664 | 747 | dev->active_duration = -jiffies; |
---|
665 | 748 | #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); |
---|
| 749 | + |
---|
| 750 | + dev->authorized = usb_dev_authorized(dev, usb_hcd); |
---|
| 751 | + if (!root_hub) |
---|
670 | 752 | dev->wusb = usb_bus_is_wusb(bus) ? 1 : 0; |
---|
671 | | - } |
---|
| 753 | + |
---|
672 | 754 | return dev; |
---|
673 | 755 | } |
---|
674 | 756 | EXPORT_SYMBOL_GPL(usb_alloc_dev); |
---|
.. | .. |
---|
741 | 823 | put_device(&intf->dev); |
---|
742 | 824 | } |
---|
743 | 825 | EXPORT_SYMBOL_GPL(usb_put_intf); |
---|
| 826 | + |
---|
| 827 | +/** |
---|
| 828 | + * usb_intf_get_dma_device - acquire a reference on the usb interface's DMA endpoint |
---|
| 829 | + * @intf: the usb interface |
---|
| 830 | + * |
---|
| 831 | + * While a USB device cannot perform DMA operations by itself, many USB |
---|
| 832 | + * controllers can. A call to usb_intf_get_dma_device() returns the DMA endpoint |
---|
| 833 | + * for the given USB interface, if any. The returned device structure must be |
---|
| 834 | + * released with put_device(). |
---|
| 835 | + * |
---|
| 836 | + * See also usb_get_dma_device(). |
---|
| 837 | + * |
---|
| 838 | + * Returns: A reference to the usb interface's DMA endpoint; or NULL if none |
---|
| 839 | + * exists. |
---|
| 840 | + */ |
---|
| 841 | +struct device *usb_intf_get_dma_device(struct usb_interface *intf) |
---|
| 842 | +{ |
---|
| 843 | + struct usb_device *udev = interface_to_usbdev(intf); |
---|
| 844 | + struct device *dmadev; |
---|
| 845 | + |
---|
| 846 | + if (!udev->bus) |
---|
| 847 | + return NULL; |
---|
| 848 | + |
---|
| 849 | + dmadev = get_device(udev->bus->sysdev); |
---|
| 850 | + if (!dmadev || !dmadev->dma_mask) { |
---|
| 851 | + put_device(dmadev); |
---|
| 852 | + return NULL; |
---|
| 853 | + } |
---|
| 854 | + |
---|
| 855 | + return dmadev; |
---|
| 856 | +} |
---|
| 857 | +EXPORT_SYMBOL_GPL(usb_intf_get_dma_device); |
---|
744 | 858 | |
---|
745 | 859 | /* USB device locking |
---|
746 | 860 | * |
---|
.. | .. |
---|
824 | 938 | return usb_hcd_get_frame_number(dev); |
---|
825 | 939 | } |
---|
826 | 940 | 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 | 941 | |
---|
885 | 942 | /*-------------------------------------------------------------------*/ |
---|
886 | 943 | /* |
---|
.. | .. |
---|
971 | 1028 | } |
---|
972 | 1029 | EXPORT_SYMBOL_GPL(usb_free_coherent); |
---|
973 | 1030 | |
---|
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 | 1031 | /* |
---|
1197 | 1032 | * Notifications of device and interface registration |
---|
1198 | 1033 | */ |
---|
.. | .. |
---|
1223 | 1058 | .notifier_call = usb_bus_notify, |
---|
1224 | 1059 | }; |
---|
1225 | 1060 | |
---|
1226 | | -struct dentry *usb_debug_root; |
---|
1227 | | -EXPORT_SYMBOL_GPL(usb_debug_root); |
---|
| 1061 | +static struct dentry *usb_devices_root; |
---|
1228 | 1062 | |
---|
1229 | 1063 | static void usb_debugfs_init(void) |
---|
1230 | 1064 | { |
---|
1231 | | - usb_debug_root = debugfs_create_dir("usb", NULL); |
---|
1232 | | - debugfs_create_file("devices", 0444, usb_debug_root, NULL, |
---|
1233 | | - &usbfs_devices_fops); |
---|
| 1065 | + usb_devices_root = debugfs_create_file("devices", 0444, usb_debug_root, |
---|
| 1066 | + NULL, &usbfs_devices_fops); |
---|
1234 | 1067 | } |
---|
1235 | 1068 | |
---|
1236 | 1069 | static void usb_debugfs_cleanup(void) |
---|
1237 | 1070 | { |
---|
1238 | | - debugfs_remove_recursive(usb_debug_root); |
---|
| 1071 | + debugfs_remove(usb_devices_root); |
---|
1239 | 1072 | } |
---|
1240 | 1073 | |
---|
1241 | 1074 | /* |
---|