ASoC: atmel-ssc: use devm_xxx() managed function
Using the devm_xxx() managed function to stripdown the error and remove code. Signed-off-by: Bo Shen <voice.shen@atmel.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
6f0c0580b7
commit
2e4de7b32a
|
@ -70,37 +70,33 @@ EXPORT_SYMBOL(ssc_free);
|
||||||
|
|
||||||
static int __init ssc_probe(struct platform_device *pdev)
|
static int __init ssc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
|
||||||
struct resource *regs;
|
struct resource *regs;
|
||||||
struct ssc_device *ssc;
|
struct ssc_device *ssc;
|
||||||
|
|
||||||
ssc = kzalloc(sizeof(struct ssc_device), GFP_KERNEL);
|
ssc = devm_kzalloc(&pdev->dev, sizeof(struct ssc_device), GFP_KERNEL);
|
||||||
if (!ssc) {
|
if (!ssc) {
|
||||||
dev_dbg(&pdev->dev, "out of memory\n");
|
dev_dbg(&pdev->dev, "out of memory\n");
|
||||||
retval = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssc->pdev = pdev;
|
||||||
|
|
||||||
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
if (!regs) {
|
if (!regs) {
|
||||||
dev_dbg(&pdev->dev, "no mmio resource defined\n");
|
dev_dbg(&pdev->dev, "no mmio resource defined\n");
|
||||||
retval = -ENXIO;
|
return -ENXIO;
|
||||||
goto out_free;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ssc->clk = clk_get(&pdev->dev, "pclk");
|
ssc->regs = devm_request_and_ioremap(&pdev->dev, regs);
|
||||||
if (IS_ERR(ssc->clk)) {
|
|
||||||
dev_dbg(&pdev->dev, "no pclk clock defined\n");
|
|
||||||
retval = -ENXIO;
|
|
||||||
goto out_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
ssc->pdev = pdev;
|
|
||||||
ssc->regs = ioremap(regs->start, resource_size(regs));
|
|
||||||
if (!ssc->regs) {
|
if (!ssc->regs) {
|
||||||
dev_dbg(&pdev->dev, "ioremap failed\n");
|
dev_dbg(&pdev->dev, "ioremap failed\n");
|
||||||
retval = -EINVAL;
|
return -EINVAL;
|
||||||
goto out_clk;
|
}
|
||||||
|
|
||||||
|
ssc->clk = devm_clk_get(&pdev->dev, "pclk");
|
||||||
|
if (IS_ERR(ssc->clk)) {
|
||||||
|
dev_dbg(&pdev->dev, "no pclk clock defined\n");
|
||||||
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* disable all interrupts */
|
/* disable all interrupts */
|
||||||
|
@ -112,8 +108,7 @@ static int __init ssc_probe(struct platform_device *pdev)
|
||||||
ssc->irq = platform_get_irq(pdev, 0);
|
ssc->irq = platform_get_irq(pdev, 0);
|
||||||
if (!ssc->irq) {
|
if (!ssc->irq) {
|
||||||
dev_dbg(&pdev->dev, "could not get irq\n");
|
dev_dbg(&pdev->dev, "could not get irq\n");
|
||||||
retval = -ENXIO;
|
return -ENXIO;
|
||||||
goto out_unmap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock(&user_lock);
|
spin_lock(&user_lock);
|
||||||
|
@ -125,16 +120,7 @@ static int __init ssc_probe(struct platform_device *pdev)
|
||||||
dev_info(&pdev->dev, "Atmel SSC device at 0x%p (irq %d)\n",
|
dev_info(&pdev->dev, "Atmel SSC device at 0x%p (irq %d)\n",
|
||||||
ssc->regs, ssc->irq);
|
ssc->regs, ssc->irq);
|
||||||
|
|
||||||
goto out;
|
return 0;
|
||||||
|
|
||||||
out_unmap:
|
|
||||||
iounmap(ssc->regs);
|
|
||||||
out_clk:
|
|
||||||
clk_put(ssc->clk);
|
|
||||||
out_free:
|
|
||||||
kfree(ssc);
|
|
||||||
out:
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __devexit ssc_remove(struct platform_device *pdev)
|
static int __devexit ssc_remove(struct platform_device *pdev)
|
||||||
|
@ -142,10 +128,7 @@ static int __devexit ssc_remove(struct platform_device *pdev)
|
||||||
struct ssc_device *ssc = platform_get_drvdata(pdev);
|
struct ssc_device *ssc = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
spin_lock(&user_lock);
|
spin_lock(&user_lock);
|
||||||
iounmap(ssc->regs);
|
|
||||||
clk_put(ssc->clk);
|
|
||||||
list_del(&ssc->list);
|
list_del(&ssc->list);
|
||||||
kfree(ssc);
|
|
||||||
spin_unlock(&user_lock);
|
spin_unlock(&user_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue