diff options
author | Huang Shijie <sjhuang@iluvatar.ai> | 2018-07-26 14:45:53 +0800 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2018-07-30 10:50:22 +0530 |
commit | f39b948dbeaf9da0dfd17e68704f38fe4237788f (patch) | |
tree | 398e038a9d6dad68808d424deedf6ec13dfefd54 /drivers/dma/dmaengine.c | |
parent | ec8ca8e3b4809bf603814a8834bfd3891e1ccf74 (diff) | |
download | linux-stable-f39b948dbeaf9da0dfd17e68704f38fe4237788f.tar.gz linux-stable-f39b948dbeaf9da0dfd17e68704f38fe4237788f.tar.bz2 linux-stable-f39b948dbeaf9da0dfd17e68704f38fe4237788f.zip |
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>
Diffstat (limited to 'drivers/dma/dmaengine.c')
-rw-r--r-- | drivers/dma/dmaengine.c | 35 |
1 files changed, 35 insertions, 0 deletions
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) } EXPORT_SYMBOL(dma_async_device_unregister); +static void dmam_device_release(struct device *dev, void *res) +{ + struct dma_device *device; + + device = *(struct dma_device **)res; + dma_async_device_unregister(device); +} + +/** + * dmaenginem_async_device_register - registers DMA devices found + * @device: &dma_device + * + * The operation is managed and will be undone on driver detach. + */ +int dmaenginem_async_device_register(struct dma_device *device) +{ + void *p; + int ret; + + p = devres_alloc(dmam_device_release, sizeof(void *), GFP_KERNEL); + if (!p) + return -ENOMEM; + + ret = dma_async_device_register(device); + if (!ret) { + *(struct dma_device **)p = device; + devres_add(device->dev, p); + } else { + devres_free(p); + } + + return ret; +} +EXPORT_SYMBOL(dmaenginem_async_device_register); + struct dmaengine_unmap_pool { struct kmem_cache *cache; const char *name; |