Skip to content

Commit 77c792b

Browse files
AngeloGioacchino Del Regnomathieupoirier
authored andcommitted
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@collabora.com> Link: https://lore.kernel.org/r/20220124120915.41292-2-angelogioacchino.delregno@collabora.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
1 parent c1407ac commit 77c792b

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

drivers/remoteproc/mtk_scp.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -791,24 +791,23 @@ static int scp_probe(struct platform_device *pdev)
791791
scp->l1tcm_phys = res->start;
792792
}
793793

794-
mutex_init(&scp->send_lock);
795-
for (i = 0; i < SCP_IPI_MAX; i++)
796-
mutex_init(&scp->ipi_desc[i].lock);
797-
798794
scp->reg_base = devm_platform_ioremap_resource_byname(pdev, "cfg");
799795
if (IS_ERR((__force void *)scp->reg_base)) {
800796
dev_err(dev, "Failed to parse and map cfg memory\n");
801-
ret = PTR_ERR((__force void *)scp->reg_base);
802-
goto destroy_mutex;
797+
return PTR_ERR((__force void *)scp->reg_base);
803798
}
804799

805-
ret = scp_map_memory_region(scp);
800+
ret = scp->data->scp_clk_get(scp);
806801
if (ret)
807-
goto destroy_mutex;
802+
return ret;
808803

809-
ret = scp->data->scp_clk_get(scp);
804+
ret = scp_map_memory_region(scp);
810805
if (ret)
811-
goto release_dev_mem;
806+
return ret;
807+
808+
mutex_init(&scp->send_lock);
809+
for (i = 0; i < SCP_IPI_MAX; i++)
810+
mutex_init(&scp->ipi_desc[i].lock);
812811

813812
/* register SCP initialization IPI */
814813
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)
842841
scp_ipi_unregister(scp, SCP_IPI_INIT);
843842
release_dev_mem:
844843
scp_unmap_memory_region(scp);
845-
destroy_mutex:
846844
for (i = 0; i < SCP_IPI_MAX; i++)
847845
mutex_destroy(&scp->ipi_desc[i].lock);
848846
mutex_destroy(&scp->send_lock);

0 commit comments

Comments
 (0)