diff options
author | Huang Shijie <sjhuang@iluvatar.ai> | 2018-07-26 02:45:53 -0400 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2018-07-30 01:20:22 -0400 |
commit | f39b948dbeaf9da0dfd17e68704f38fe4237788f (patch) | |
tree | 398e038a9d6dad68808d424deedf6ec13dfefd54 | |
parent | ec8ca8e3b4809bf603814a8834bfd3891e1ccf74 (diff) |
dmaengine: add a new helper dmaenginem_async_device_register
This patch adds the dmaenginem_async_device_register for DMA code.
Use the Devres to call the release for the DMA engine driver.
Signed-off-by: Huang Shijie <sjhuang@iluvatar.ai>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
-rw-r--r-- | Documentation/driver-model/devres.txt | 1 | ||||
-rw-r--r-- | drivers/dma/dmaengine.c | 35 | ||||
-rw-r--r-- | include/linux/dmaengine.h | 1 |
3 files changed, 37 insertions, 0 deletions
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 7c1bb3d0c222..43681ca0837f 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt | |||
@@ -240,6 +240,7 @@ CLOCK | |||
240 | devm_of_clk_add_hw_provider() | 240 | devm_of_clk_add_hw_provider() |
241 | 241 | ||
242 | DMA | 242 | DMA |
243 | dmaenginem_async_device_register() | ||
243 | dmam_alloc_coherent() | 244 | dmam_alloc_coherent() |
244 | dmam_alloc_attrs() | 245 | dmam_alloc_attrs() |
245 | dmam_declare_coherent_memory() | 246 | dmam_declare_coherent_memory() |
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 504420f213ff..272bed6c8ba7 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c | |||
@@ -1141,6 +1141,41 @@ void dma_async_device_unregister(struct dma_device *device) | |||
1141 | } | 1141 | } |
1142 | EXPORT_SYMBOL(dma_async_device_unregister); | 1142 | EXPORT_SYMBOL(dma_async_device_unregister); |
1143 | 1143 | ||
1144 | static void dmam_device_release(struct device *dev, void *res) | ||
1145 | { | ||
1146 | struct dma_device *device; | ||
1147 | |||
1148 | device = *(struct dma_device **)res; | ||
1149 | dma_async_device_unregister(device); | ||
1150 | } | ||
1151 | |||
1152 | /** | ||
1153 | * dmaenginem_async_device_register - registers DMA devices found | ||
1154 | * @device: &dma_device | ||
1155 | * | ||
1156 | * The operation is managed and will be undone on driver detach. | ||
1157 | */ | ||
1158 | int dmaenginem_async_device_register(struct dma_device *device) | ||
1159 | { | ||
1160 | void *p; | ||
1161 | int ret; | ||
1162 | |||
1163 | p = devres_alloc(dmam_device_release, sizeof(void *), GFP_KERNEL); | ||
1164 | if (!p) | ||
1165 | return -ENOMEM; | ||
1166 | |||
1167 | ret = dma_async_device_register(device); | ||
1168 | if (!ret) { | ||
1169 | *(struct dma_device **)p = device; | ||
1170 | devres_add(device->dev, p); | ||
1171 | } else { | ||
1172 | devres_free(p); | ||
1173 | } | ||
1174 | |||
1175 | return ret; | ||
1176 | } | ||
1177 | EXPORT_SYMBOL(dmaenginem_async_device_register); | ||
1178 | |||
1144 | struct dmaengine_unmap_pool { | 1179 | struct dmaengine_unmap_pool { |
1145 | struct kmem_cache *cache; | 1180 | struct kmem_cache *cache; |
1146 | const char *name; | 1181 | const char *name; |
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index c8c3a7a93802..d49ec5c31944 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h | |||
@@ -1406,6 +1406,7 @@ static inline int dmaengine_desc_free(struct dma_async_tx_descriptor *desc) | |||
1406 | /* --- DMA device --- */ | 1406 | /* --- DMA device --- */ |
1407 | 1407 | ||
1408 | int dma_async_device_register(struct dma_device *device); | 1408 | int dma_async_device_register(struct dma_device *device); |
1409 | int dmaenginem_async_device_register(struct dma_device *device); | ||
1409 | void dma_async_device_unregister(struct dma_device *device); | 1410 | void dma_async_device_unregister(struct dma_device *device); |
1410 | void dma_run_dependencies(struct dma_async_tx_descriptor *tx); | 1411 | void dma_run_dependencies(struct dma_async_tx_descriptor *tx); |
1411 | struct dma_chan *dma_get_slave_channel(struct dma_chan *chan); | 1412 | struct dma_chan *dma_get_slave_channel(struct dma_chan *chan); |