diff options
| author | Russell King <rmk+kernel@arm.linux.org.uk> | 2013-06-27 07:21:45 -0400 |
|---|---|---|
| committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2013-10-31 10:48:46 -0400 |
| commit | fa6a8d6d65b19ab44e5244ea499bcd553cc72343 (patch) | |
| tree | 789f1db34489c2eed65718df5c4bbcb102c09b48 | |
| parent | 4ffb4318b044d175709567402a65f8ebb19f5d3b (diff) | |
DMA-API: provide a helper to setup DMA masks
Many drivers contain code such as:
dev->dma_mask = &dev->coherent_dma_mask;
dev->coherent_dma_mask = MASK;
Let's move this pattern out of drivers and have the DMA API provide a
helper for it. This helper uses dma_set_mask_and_coherent() to allow
platform issues to be properly dealt with via dma_set_mask()/
dma_is_supported().
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
| -rw-r--r-- | include/linux/dma-mapping.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index ec951f98e3d9..27d1421ad42c 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h | |||
| @@ -111,6 +111,16 @@ static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask) | |||
| 111 | return rc; | 111 | return rc; |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | /* | ||
| 115 | * Similar to the above, except it deals with the case where the device | ||
| 116 | * does not have dev->dma_mask appropriately setup. | ||
| 117 | */ | ||
| 118 | static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask) | ||
| 119 | { | ||
| 120 | dev->dma_mask = &dev->coherent_dma_mask; | ||
| 121 | return dma_set_mask_and_coherent(dev, mask); | ||
| 122 | } | ||
| 123 | |||
| 114 | extern u64 dma_get_required_mask(struct device *dev); | 124 | extern u64 dma_get_required_mask(struct device *dev); |
| 115 | 125 | ||
| 116 | static inline unsigned int dma_get_max_seg_size(struct device *dev) | 126 | static inline unsigned int dma_get_max_seg_size(struct device *dev) |
