From c318c90b824c59539bf2e33618e381293398616c Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Tue, 16 Apr 2024 15:02:49 +0200
Subject: [PATCH 1/6] edma_v1: rework hw_reset logic to permit rmmod and insmod

Rework hw_reset logic for edma v1 to permit rmmod and insmod by using
get_exclusive_released variant (assuming the reset control was released)
and manually acquire and release it.

This permits rmmod and insmod without triggering warning or receiving
-EBUSY errors.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 hal/dp_ops/edma_dp/edma_v1/edma_cfg.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/hal/dp_ops/edma_dp/edma_v1/edma_cfg.c
+++ b/hal/dp_ops/edma_dp/edma_v1/edma_cfg.c
@@ -719,18 +719,22 @@ int edma_hw_reset(struct edma_hw *ehw)
 	struct reset_control *rst;
 	struct platform_device *pdev = ehw->pdev;
 
-	rst = devm_reset_control_get(&pdev->dev, EDMA_HW_RESET_ID);
+	rst = devm_reset_control_get_exclusive_released(&pdev->dev, EDMA_HW_RESET_ID);
 	if (IS_ERR(rst)) {
 		pr_warn("DTS Node: %s does not exist\n", EDMA_HW_RESET_ID);
 		return -EINVAL;
 	}
 
+	reset_control_acquire(rst);
+
 	reset_control_assert(rst);
 	udelay(100);
 
 	reset_control_deassert(rst);
 	udelay(100);
 
+	reset_control_release(rst);
+
 	pr_info("EDMA HW Reset completed succesfully\n");
 
 	return 0;
