Skip to contentSkip to conversation

dmaengine: Simplify dmaenginem_async_device_register() function

PATCH Applied Andy Shevchenko 2 participants 2 messages Jan 30, 2023 – Feb 10, 2023 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/dma/dmaengine.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/dma/dmaengine.c +4 -16
index 4957f811d390..c24bca210104 100644
@@ -1323,11 +1323,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);
 }
 
@@ -1339,22 +1336,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);
 
Signature · 1 line
2.39.0
maintainer Applied
#1 lore raw
Quoted 3 lines · Andy Shevchenko

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.

Applied, thanks

Signature · 1 line
~Vinod