diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2023-01-30 12:28:30 +0100 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2023-02-10 07:07:45 +0100 |
commit | a1beaa50b583a4f137048ff6e55bd2328a4e4362 (patch) | |
tree | 2fcf15a57c4283d1e9047ea960c2ef23bad24e30 | |
parent | dmaengine: use sysfs_emit() to instead of scnprintf() (diff) | |
download | linux-a1beaa50b583a4f137048ff6e55bd2328a4e4362.tar.xz linux-a1beaa50b583a4f137048ff6e55bd2328a4e4362.zip |
dmaengine: Simplify dmaenginem_async_device_register() function
Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230130112830.52353-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
-rw-r--r-- | drivers/dma/dmaengine.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 1ebbf22756bb..ed28be3b1fc7 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -1322,11 +1322,8 @@ 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) +static void dmaenginem_async_device_unregister(void *device) { - struct dma_device *device; - - device = *(struct dma_device **)res; dma_async_device_unregister(device); } @@ -1338,22 +1335,13 @@ static void dmam_device_release(struct device *dev, void *res) */ 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); - } + if (ret) + return ret; - return ret; + return devm_add_action(device->dev, dmaenginem_async_device_unregister, device); } EXPORT_SYMBOL(dmaenginem_async_device_register); |