[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220124120915.41292-2-angelogioacchino.delregno@collabora.com>
Date: Mon, 24 Jan 2022 13:09:14 +0100
From: AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>
To: bjorn.andersson@...aro.org
Cc: mathieu.poirier@...aro.org, matthias.bgg@...il.com,
linux-remoteproc@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, linux-kernel@...r.kernel.org,
kernel@...labora.com,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>
Subject: [PATCH 2/3] remoteproc: mtk_scp: Reorder scp_probe() sequence
Cleanup the scp_probe() function by reordering some calls in this
function, useful to reduce the usage of goto(s), and preparing
for one more usage of dev_err_probe().
In particular, we can get the clocks before mapping the memory region,
and move the mutexes initialization right before registering the ipi
handler (which is the first mutex user in this driver).
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
---
drivers/remoteproc/mtk_scp.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
index 95a40e3f11e3..e40706b0e015 100644
--- a/drivers/remoteproc/mtk_scp.c
+++ b/drivers/remoteproc/mtk_scp.c
@@ -791,24 +791,23 @@ static int scp_probe(struct platform_device *pdev)
scp->l1tcm_phys = res->start;
}
- mutex_init(&scp->send_lock);
- for (i = 0; i < SCP_IPI_MAX; i++)
- mutex_init(&scp->ipi_desc[i].lock);
-
scp->reg_base = devm_platform_ioremap_resource_byname(pdev, "cfg");
if (IS_ERR((__force void *)scp->reg_base)) {
dev_err(dev, "Failed to parse and map cfg memory\n");
- ret = PTR_ERR((__force void *)scp->reg_base);
- goto destroy_mutex;
+ return PTR_ERR((__force void *)scp->reg_base);
}
- ret = scp_map_memory_region(scp);
+ ret = scp->data->scp_clk_get(scp);
if (ret)
- goto destroy_mutex;
+ return ret;
- ret = scp->data->scp_clk_get(scp);
+ ret = scp_map_memory_region(scp);
if (ret)
- goto release_dev_mem;
+ return ret;
+
+ mutex_init(&scp->send_lock);
+ for (i = 0; i < SCP_IPI_MAX; i++)
+ mutex_init(&scp->ipi_desc[i].lock);
/* register SCP initialization IPI */
ret = scp_ipi_register(scp, SCP_IPI_INIT, scp_init_ipi_handler, scp);
@@ -842,7 +841,6 @@ static int scp_probe(struct platform_device *pdev)
scp_ipi_unregister(scp, SCP_IPI_INIT);
release_dev_mem:
scp_unmap_memory_region(scp);
-destroy_mutex:
for (i = 0; i < SCP_IPI_MAX; i++)
mutex_destroy(&scp->ipi_desc[i].lock);
mutex_destroy(&scp->send_lock);
--
2.33.1
Powered by blists - more mailing lists