mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-29 21:06:41 +07:00
spi: s3c24xx: Use devm_*() functions
Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
6ce4eac1f6
commit
c9f722e879
@ -78,7 +78,6 @@ struct s3c24xx_spi {
|
|||||||
unsigned char *rx;
|
unsigned char *rx;
|
||||||
|
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
struct resource *ioarea;
|
|
||||||
struct spi_master *master;
|
struct spi_master *master;
|
||||||
struct spi_device *curdev;
|
struct spi_device *curdev;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
@ -517,8 +516,7 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
|
|||||||
master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi));
|
master = 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");
|
||||||
err = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto err_nomem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hw = spi_master_get_devdata(master);
|
hw = spi_master_get_devdata(master);
|
||||||
@ -567,43 +565,34 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
|
|||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n");
|
dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n");
|
||||||
err = -ENOENT;
|
err = -ENOENT;
|
||||||
goto err_no_iores;
|
goto err_no_pdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
hw->ioarea = request_mem_region(res->start, resource_size(res),
|
hw->regs = devm_ioremap_resource(&pdev->dev, res);
|
||||||
pdev->name);
|
if (IS_ERR(hw->regs)) {
|
||||||
|
err = PTR_ERR(hw->regs);
|
||||||
if (hw->ioarea == NULL) {
|
goto err_no_pdata;
|
||||||
dev_err(&pdev->dev, "Cannot reserve region\n");
|
|
||||||
err = -ENXIO;
|
|
||||||
goto err_no_iores;
|
|
||||||
}
|
|
||||||
|
|
||||||
hw->regs = ioremap(res->start, resource_size(res));
|
|
||||||
if (hw->regs == NULL) {
|
|
||||||
dev_err(&pdev->dev, "Cannot map IO\n");
|
|
||||||
err = -ENXIO;
|
|
||||||
goto err_no_iomap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hw->irq = platform_get_irq(pdev, 0);
|
hw->irq = platform_get_irq(pdev, 0);
|
||||||
if (hw->irq < 0) {
|
if (hw->irq < 0) {
|
||||||
dev_err(&pdev->dev, "No IRQ specified\n");
|
dev_err(&pdev->dev, "No IRQ specified\n");
|
||||||
err = -ENOENT;
|
err = -ENOENT;
|
||||||
goto err_no_irq;
|
goto err_no_pdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = request_irq(hw->irq, s3c24xx_spi_irq, 0, pdev->name, hw);
|
err = devm_request_irq(&pdev->dev, hw->irq, s3c24xx_spi_irq, 0,
|
||||||
|
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_irq;
|
goto err_no_pdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
hw->clk = 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);
|
err = PTR_ERR(hw->clk);
|
||||||
goto err_no_clk;
|
goto err_no_pdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup any gpio we can */
|
/* setup any gpio we can */
|
||||||
@ -615,7 +604,8 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
|
|||||||
goto err_register;
|
goto err_register;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = gpio_request(pdata->pin_cs, dev_name(&pdev->dev));
|
err = devm_gpio_request(&pdev->dev, pdata->pin_cs,
|
||||||
|
dev_name(&pdev->dev));
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&pdev->dev, "Failed to get gpio for cs\n");
|
dev_err(&pdev->dev, "Failed to get gpio for cs\n");
|
||||||
goto err_register;
|
goto err_register;
|
||||||
@ -639,27 +629,10 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_register:
|
err_register:
|
||||||
if (hw->set_cs == s3c24xx_spi_gpiocs)
|
|
||||||
gpio_free(pdata->pin_cs);
|
|
||||||
|
|
||||||
clk_disable(hw->clk);
|
clk_disable(hw->clk);
|
||||||
clk_put(hw->clk);
|
|
||||||
|
|
||||||
err_no_clk:
|
|
||||||
free_irq(hw->irq, hw);
|
|
||||||
|
|
||||||
err_no_irq:
|
|
||||||
iounmap(hw->regs);
|
|
||||||
|
|
||||||
err_no_iomap:
|
|
||||||
release_resource(hw->ioarea);
|
|
||||||
kfree(hw->ioarea);
|
|
||||||
|
|
||||||
err_no_iores:
|
|
||||||
err_no_pdata:
|
err_no_pdata:
|
||||||
spi_master_put(hw->master);
|
spi_master_put(hw->master);
|
||||||
|
|
||||||
err_nomem:
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,19 +641,7 @@ static int s3c24xx_spi_remove(struct platform_device *dev)
|
|||||||
struct s3c24xx_spi *hw = platform_get_drvdata(dev);
|
struct s3c24xx_spi *hw = platform_get_drvdata(dev);
|
||||||
|
|
||||||
spi_bitbang_stop(&hw->bitbang);
|
spi_bitbang_stop(&hw->bitbang);
|
||||||
|
|
||||||
clk_disable(hw->clk);
|
clk_disable(hw->clk);
|
||||||
clk_put(hw->clk);
|
|
||||||
|
|
||||||
free_irq(hw->irq, hw);
|
|
||||||
iounmap(hw->regs);
|
|
||||||
|
|
||||||
if (hw->set_cs == s3c24xx_spi_gpiocs)
|
|
||||||
gpio_free(hw->pdata->pin_cs);
|
|
||||||
|
|
||||||
release_resource(hw->ioarea);
|
|
||||||
kfree(hw->ioarea);
|
|
||||||
|
|
||||||
spi_master_put(hw->master);
|
spi_master_put(hw->master);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user