[PATCH v2 03/15] iio: adc: rzg2l_adc: Use devres helpers to request pre-deasserted reset controls

Claudiu
2024-12-06T11:14:00Z

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

Starting with commit d872bed85036 ("reset: Add devres helpers to request
pre-deasserted reset controls"), devres helpers are available to simplify
the process of requesting pre-deasserted reset controls. Update the
rzg2l_adc driver to utilize these helpers, reducing complexity in this
way.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---

Changes in v2:
- rebased on top of patch 2/15 from this version
- used "failed to get/deassert" failure messages

drivers/iio/adc/rzg2l_adc.c | 37 ++++++-------------------------------
1 file changed, 6 insertions(+), 31 deletions(-)

diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c
index 8a804f81c04b..c0c13e99aa92 100644
--- a/drivers/iio/adc/rzg2l_adc.c
+++ b/drivers/iio/adc/rzg2l_adc.c
@@ -411,11 +411,6 @@ static void rzg2l_adc_pm_runtime_set_suspended(void *data)
pm_runtime_set_suspended(dev->parent);
}

-static void rzg2l_adc_reset_assert(void *data)
-{
- reset_control_assert(data);
-}
-
static int rzg2l_adc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -448,34 +443,14 @@ static int rzg2l_adc_probe(struct platform_device *pdev)
if (IS_ERR(adc->adclk))
return dev_err_probe(dev, PTR_ERR(adc->adclk), "Failed to get adclk");

- adc->adrstn = devm_reset_control_get_exclusive(dev, "adrst-n");
+ adc->adrstn = devm_reset_control_get_exclusive_deasserted(dev, "adrst-n");
if (IS_ERR(adc->adrstn))
- return dev_err_probe(dev, PTR_ERR(adc->adrstn), "failed to get adrstn\n");
-
- adc->presetn = devm_reset_control_get_exclusive(dev, "presetn");
- if (IS_ERR(adc->presetn))
- return dev_err_probe(dev, PTR_ERR(adc->presetn), "failed to get presetn\n");
-
- ret = reset_control_deassert(adc->adrstn);
- if (ret)
- return dev_err_probe(&pdev->dev, ret, "failed to deassert adrstn pin, %d\n", ret);
-
- ret = devm_add_action_or_reset(&pdev->dev,
- rzg2l_adc_reset_assert, adc->adrstn);
- if (ret) {
- return dev_err_probe(&pdev->dev, ret,
- "failed to register adrstn assert devm action, %d\n", ret);
- }
+ return dev_err_probe(dev, PTR_ERR(adc->adrstn), "failed to get/deassert adrst-n\n");

- ret = reset_control_deassert(adc->presetn);
- if (ret)
- return dev_err_probe(&pdev->dev, ret, "failed to deassert presetn pin, %d\n", ret);
-
- ret = devm_add_action_or_reset(&pdev->dev,
- rzg2l_adc_reset_assert, adc->presetn);
- if (ret) {
- return dev_err_probe(&pdev->dev, ret,
- "failed to register presetn assert devm action, %d\n", ret);
+ adc->presetn = devm_reset_control_get_exclusive_deasserted(dev, "presetn");
+ if (IS_ERR(adc->presetn)) {
+ return dev_err_probe(dev, PTR_ERR(adc->presetn),
+ "failed to get/deassert presetn\n");
}

ret = rzg2l_adc_hw_init(adc);
--
2.39.2