diff options
| author | Daniel Mack <daniel@caiaq.de> | 2010-04-12 07:17:25 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-04-30 12:25:12 -0400 |
| commit | 073900a28d95c75a706bf40ebf092ea048c7b236 (patch) | |
| tree | 01e8bb7856ebf1e989a1eb693704435fc4032118 | |
| parent | 75181f386f9a80ed6f87763ac6cf05826e253ccd (diff) | |
USB: rename usb_buffer_alloc() and usb_buffer_free()
For more clearance what the functions actually do,
usb_buffer_alloc() is renamed to usb_alloc_coherent()
usb_buffer_free() is renamed to usb_free_coherent()
They should only be used in code which really needs DMA coherency.
[added compatibility macros so we can convert things easier - gregkh]
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Pedro Ribeiro <pedrib@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| -rw-r--r-- | drivers/usb/core/usb.c | 20 | ||||
| -rw-r--r-- | include/linux/usb.h | 18 |
2 files changed, 25 insertions, 13 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 1297e9b16a51..0561430f2ede 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
| @@ -718,7 +718,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, | |||
| 718 | EXPORT_SYMBOL_GPL(__usb_get_extra_descriptor); | 718 | EXPORT_SYMBOL_GPL(__usb_get_extra_descriptor); |
| 719 | 719 | ||
| 720 | /** | 720 | /** |
| 721 | * usb_buffer_alloc - allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP | 721 | * usb_alloc_coherent - allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP |
| 722 | * @dev: device the buffer will be used with | 722 | * @dev: device the buffer will be used with |
| 723 | * @size: requested buffer size | 723 | * @size: requested buffer size |
| 724 | * @mem_flags: affect whether allocation may block | 724 | * @mem_flags: affect whether allocation may block |
| @@ -737,30 +737,30 @@ EXPORT_SYMBOL_GPL(__usb_get_extra_descriptor); | |||
| 737 | * architectures where CPU caches are not DMA-coherent. On systems without | 737 | * architectures where CPU caches are not DMA-coherent. On systems without |
| 738 | * bus-snooping caches, these buffers are uncached. | 738 | * bus-snooping caches, these buffers are uncached. |
| 739 | * | 739 | * |
| 740 | * When the buffer is no longer used, free it with usb_buffer_free(). | 740 | * When the buffer is no longer used, free it with usb_free_coherent(). |
| 741 | */ | 741 | */ |
| 742 | void *usb_buffer_alloc(struct usb_device *dev, size_t size, gfp_t mem_flags, | 742 | void *usb_alloc_coherent(struct usb_device *dev, size_t size, gfp_t mem_flags, |
| 743 | dma_addr_t *dma) | 743 | dma_addr_t *dma) |
| 744 | { | 744 | { |
| 745 | if (!dev || !dev->bus) | 745 | if (!dev || !dev->bus) |
| 746 | return NULL; | 746 | return NULL; |
| 747 | return hcd_buffer_alloc(dev->bus, size, mem_flags, dma); | 747 | return hcd_buffer_alloc(dev->bus, size, mem_flags, dma); |
| 748 | } | 748 | } |
| 749 | EXPORT_SYMBOL_GPL(usb_buffer_alloc); | 749 | EXPORT_SYMBOL_GPL(usb_alloc_coherent); |
| 750 | 750 | ||
| 751 | /** | 751 | /** |
| 752 | * usb_buffer_free - free memory allocated with usb_buffer_alloc() | 752 | * usb_free_coherent - free memory allocated with usb_alloc_coherent() |
| 753 | * @dev: device the buffer was used with | 753 | * @dev: device the buffer was used with |
| 754 | * @size: requested buffer size | 754 | * @size: requested buffer size |
| 755 | * @addr: CPU address of buffer | 755 | * @addr: CPU address of buffer |
| 756 | * @dma: DMA address of buffer | 756 | * @dma: DMA address of buffer |
| 757 | * | 757 | * |
| 758 | * This reclaims an I/O buffer, letting it be reused. The memory must have | 758 | * This reclaims an I/O buffer, letting it be reused. The memory must have |
| 759 | * been allocated using usb_buffer_alloc(), and the parameters must match | 759 | * been allocated using usb_alloc_coherent(), and the parameters must match |
| 760 | * those provided in that allocation request. | 760 | * those provided in that allocation request. |
| 761 | */ | 761 | */ |
| 762 | void usb_buffer_free(struct usb_device *dev, size_t size, void *addr, | 762 | void usb_free_coherent(struct usb_device *dev, size_t size, void *addr, |
| 763 | dma_addr_t dma) | 763 | dma_addr_t dma) |
| 764 | { | 764 | { |
| 765 | if (!dev || !dev->bus) | 765 | if (!dev || !dev->bus) |
| 766 | return; | 766 | return; |
| @@ -768,7 +768,7 @@ void usb_buffer_free(struct usb_device *dev, size_t size, void *addr, | |||
| 768 | return; | 768 | return; |
| 769 | hcd_buffer_free(dev->bus, size, addr, dma); | 769 | hcd_buffer_free(dev->bus, size, addr, dma); |
| 770 | } | 770 | } |
| 771 | EXPORT_SYMBOL_GPL(usb_buffer_free); | 771 | EXPORT_SYMBOL_GPL(usb_free_coherent); |
| 772 | 772 | ||
| 773 | /** | 773 | /** |
| 774 | * usb_buffer_map - create DMA mapping(s) for an urb | 774 | * usb_buffer_map - create DMA mapping(s) for an urb |
diff --git a/include/linux/usb.h b/include/linux/usb.h index ce1323c4e47c..739f1fd1cc15 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
| @@ -1085,7 +1085,7 @@ typedef void (*usb_complete_t)(struct urb *); | |||
| 1085 | * Alternatively, drivers may pass the URB_NO_xxx_DMA_MAP transfer flags, | 1085 | * Alternatively, drivers may pass the URB_NO_xxx_DMA_MAP transfer flags, |
| 1086 | * which tell the host controller driver that no such mapping is needed since | 1086 | * which tell the host controller driver that no such mapping is needed since |
| 1087 | * the device driver is DMA-aware. For example, a device driver might | 1087 | * the device driver is DMA-aware. For example, a device driver might |
| 1088 | * allocate a DMA buffer with usb_buffer_alloc() or call usb_buffer_map(). | 1088 | * allocate a DMA buffer with usb_alloc_coherent() or call usb_buffer_map(). |
| 1089 | * When these transfer flags are provided, host controller drivers will | 1089 | * When these transfer flags are provided, host controller drivers will |
| 1090 | * attempt to use the dma addresses found in the transfer_dma and/or | 1090 | * attempt to use the dma addresses found in the transfer_dma and/or |
| 1091 | * setup_dma fields rather than determining a dma address themselves. | 1091 | * setup_dma fields rather than determining a dma address themselves. |
| @@ -1366,11 +1366,23 @@ static inline int usb_urb_dir_out(struct urb *urb) | |||
| 1366 | return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; | 1366 | return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; |
| 1367 | } | 1367 | } |
| 1368 | 1368 | ||
| 1369 | void *usb_buffer_alloc(struct usb_device *dev, size_t size, | 1369 | void *usb_alloc_coherent(struct usb_device *dev, size_t size, |
| 1370 | gfp_t mem_flags, dma_addr_t *dma); | 1370 | gfp_t mem_flags, dma_addr_t *dma); |
| 1371 | void usb_buffer_free(struct usb_device *dev, size_t size, | 1371 | void usb_free_coherent(struct usb_device *dev, size_t size, |
| 1372 | void *addr, dma_addr_t dma); | 1372 | void *addr, dma_addr_t dma); |
| 1373 | 1373 | ||
| 1374 | /* Compatible macros while we switch over */ | ||
| 1375 | static inline void *usb_buffer_alloc(struct usb_device *dev, size_t size, | ||
| 1376 | gfp_t mem_flags, dma_addr_t *dma) | ||
| 1377 | { | ||
| 1378 | return usb_alloc_coherent(dev, size, mem_flags, dma); | ||
| 1379 | } | ||
| 1380 | static inline void usb_buffer_free(struct usb_device *dev, size_t size, | ||
| 1381 | void *addr, dma_addr_t dma) | ||
| 1382 | { | ||
| 1383 | return usb_free_coherent(dev, size, addr, dma); | ||
| 1384 | } | ||
| 1385 | |||
| 1374 | #if 0 | 1386 | #if 0 |
| 1375 | struct urb *usb_buffer_map(struct urb *urb); | 1387 | struct urb *usb_buffer_map(struct urb *urb); |
| 1376 | void usb_buffer_dmasync(struct urb *urb); | 1388 | void usb_buffer_dmasync(struct urb *urb); |
