Commit a6bfc42f authored by Yang Yingliang's avatar Yang Yingliang Committed by Mark Brown

spi: s3c24xx: Switch to use devm_spi_alloc_master()

Switch to use devm_spi_alloc_master() to simpify error path.
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20220920142216.3002291-1-yangyingliang@huawei.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 2d064581
...@@ -449,7 +449,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) ...@@ -449,7 +449,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
struct spi_master *master; struct spi_master *master;
int err = 0; int err = 0;
master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi)); master = devm_spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi));
if (master == NULL) { if (master == NULL) {
dev_err(&pdev->dev, "No memory for spi_master\n"); dev_err(&pdev->dev, "No memory for spi_master\n");
return -ENOMEM; return -ENOMEM;
...@@ -463,8 +463,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) ...@@ -463,8 +463,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
if (pdata == NULL) { if (pdata == NULL) {
dev_err(&pdev->dev, "No platform data supplied\n"); dev_err(&pdev->dev, "No platform data supplied\n");
err = -ENOENT; return -ENOENT;
goto err_no_pdata;
} }
platform_set_drvdata(pdev, hw); platform_set_drvdata(pdev, hw);
...@@ -499,29 +498,24 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) ...@@ -499,29 +498,24 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
/* find and map our resources */ /* find and map our resources */
hw->regs = devm_platform_ioremap_resource(pdev, 0); hw->regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(hw->regs)) { if (IS_ERR(hw->regs))
err = PTR_ERR(hw->regs); return PTR_ERR(hw->regs);
goto err_no_pdata;
}
hw->irq = platform_get_irq(pdev, 0); hw->irq = platform_get_irq(pdev, 0);
if (hw->irq < 0) { if (hw->irq < 0)
err = -ENOENT; return -ENOENT;
goto err_no_pdata;
}
err = devm_request_irq(&pdev->dev, hw->irq, s3c24xx_spi_irq, 0, err = devm_request_irq(&pdev->dev, hw->irq, s3c24xx_spi_irq, 0,
pdev->name, hw); pdev->name, hw);
if (err) { if (err) {
dev_err(&pdev->dev, "Cannot claim IRQ\n"); dev_err(&pdev->dev, "Cannot claim IRQ\n");
goto err_no_pdata; return err;
} }
hw->clk = devm_clk_get(&pdev->dev, "spi"); hw->clk = devm_clk_get(&pdev->dev, "spi");
if (IS_ERR(hw->clk)) { if (IS_ERR(hw->clk)) {
dev_err(&pdev->dev, "No clock for device\n"); dev_err(&pdev->dev, "No clock for device\n");
err = PTR_ERR(hw->clk); return PTR_ERR(hw->clk);
goto err_no_pdata;
} }
s3c24xx_spi_initialsetup(hw); s3c24xx_spi_initialsetup(hw);
...@@ -539,8 +533,6 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) ...@@ -539,8 +533,6 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
err_register: err_register:
clk_disable(hw->clk); clk_disable(hw->clk);
err_no_pdata:
spi_master_put(hw->master);
return err; return err;
} }
......
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