Commit 76fbad41 authored by Andi Shyti's avatar Andi Shyti Committed by Mark Brown

spi: s3c64xx: Use the managed spi master allocation function

Use devm_spi_alloc_master() and get rid of one goto error path
Signed-off-by: default avatarAndi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20230606012051.2139333-2-andi.shyti@kernel.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 8098a931
...@@ -1177,8 +1177,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1177,8 +1177,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
return irq; return irq;
} }
master = spi_alloc_master(&pdev->dev, master = devm_spi_alloc_master(&pdev->dev, sizeof(*sdd));
sizeof(struct s3c64xx_spi_driver_data));
if (master == NULL) { if (master == NULL) {
dev_err(&pdev->dev, "Unable to allocate SPI Master\n"); dev_err(&pdev->dev, "Unable to allocate SPI Master\n");
return -ENOMEM; return -ENOMEM;
...@@ -1197,7 +1196,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1197,7 +1196,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "failed to get alias id, errno %d\n", dev_err(&pdev->dev, "failed to get alias id, errno %d\n",
ret); ret);
goto err_deref_master; return ret;
} }
sdd->port_id = ret; sdd->port_id = ret;
} else { } else {
...@@ -1232,23 +1231,19 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1232,23 +1231,19 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
master->can_dma = s3c64xx_spi_can_dma; master->can_dma = s3c64xx_spi_can_dma;
sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res); sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res);
if (IS_ERR(sdd->regs)) { if (IS_ERR(sdd->regs))
ret = PTR_ERR(sdd->regs); return PTR_ERR(sdd->regs);
goto err_deref_master;
}
if (sci->cfg_gpio && sci->cfg_gpio()) { if (sci->cfg_gpio && sci->cfg_gpio()) {
dev_err(&pdev->dev, "Unable to config gpio\n"); dev_err(&pdev->dev, "Unable to config gpio\n");
ret = -EBUSY; return -EBUSY;
goto err_deref_master;
} }
/* Setup clocks */ /* Setup clocks */
sdd->clk = devm_clk_get_enabled(&pdev->dev, "spi"); sdd->clk = devm_clk_get_enabled(&pdev->dev, "spi");
if (IS_ERR(sdd->clk)) { if (IS_ERR(sdd->clk)) {
dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n"); dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n");
ret = PTR_ERR(sdd->clk); return PTR_ERR(sdd->clk);
goto err_deref_master;
} }
sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr); sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr);
...@@ -1256,16 +1251,14 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1256,16 +1251,14 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
if (IS_ERR(sdd->src_clk)) { if (IS_ERR(sdd->src_clk)) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Unable to acquire clock '%s'\n", clk_name); "Unable to acquire clock '%s'\n", clk_name);
ret = PTR_ERR(sdd->src_clk); return PTR_ERR(sdd->src_clk);
goto err_deref_master;
} }
if (sdd->port_conf->clk_ioclk) { if (sdd->port_conf->clk_ioclk) {
sdd->ioclk = devm_clk_get_enabled(&pdev->dev, "spi_ioclk"); sdd->ioclk = devm_clk_get_enabled(&pdev->dev, "spi_ioclk");
if (IS_ERR(sdd->ioclk)) { if (IS_ERR(sdd->ioclk)) {
dev_err(&pdev->dev, "Unable to acquire 'ioclk'\n"); dev_err(&pdev->dev, "Unable to acquire 'ioclk'\n");
ret = PTR_ERR(sdd->ioclk); return PTR_ERR(sdd->ioclk);
goto err_deref_master;
} }
} }
...@@ -1314,9 +1307,6 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) ...@@ -1314,9 +1307,6 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev); pm_runtime_set_suspended(&pdev->dev);
err_deref_master:
spi_master_put(master);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment