ASoC: omap-mcpdm: Convert to use devm_*
Switch to use devm_* te make the probe/remove code more cleaner. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
Родитель
3c6c2a9977
Коммит
d77ae33292
|
@ -445,9 +445,8 @@ static __devinit int asoc_mcpdm_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct omap_mcpdm *mcpdm;
|
struct omap_mcpdm *mcpdm;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
mcpdm = kzalloc(sizeof(struct omap_mcpdm), GFP_KERNEL);
|
mcpdm = devm_kzalloc(&pdev->dev, sizeof(struct omap_mcpdm), GFP_KERNEL);
|
||||||
if (!mcpdm)
|
if (!mcpdm)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -456,55 +455,30 @@ static __devinit int asoc_mcpdm_probe(struct platform_device *pdev)
|
||||||
mutex_init(&mcpdm->mutex);
|
mutex_init(&mcpdm->mutex);
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
if (res == NULL) {
|
if (res == NULL)
|
||||||
dev_err(&pdev->dev, "no resource\n");
|
return -ENOMEM;
|
||||||
goto err_res;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!request_mem_region(res->start, resource_size(res), "McPDM")) {
|
if (!devm_request_mem_region(&pdev->dev, res->start,
|
||||||
ret = -EBUSY;
|
resource_size(res), "McPDM"))
|
||||||
goto err_res;
|
return -EBUSY;
|
||||||
}
|
|
||||||
|
|
||||||
mcpdm->io_base = ioremap(res->start, resource_size(res));
|
mcpdm->io_base = devm_ioremap(&pdev->dev, res->start,
|
||||||
if (!mcpdm->io_base) {
|
resource_size(res));
|
||||||
ret = -ENOMEM;
|
if (!mcpdm->io_base)
|
||||||
goto err_iomap;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
mcpdm->irq = platform_get_irq(pdev, 0);
|
mcpdm->irq = platform_get_irq(pdev, 0);
|
||||||
if (mcpdm->irq < 0) {
|
if (mcpdm->irq < 0)
|
||||||
ret = mcpdm->irq;
|
return mcpdm->irq;
|
||||||
goto err_irq;
|
|
||||||
}
|
|
||||||
|
|
||||||
mcpdm->dev = &pdev->dev;
|
mcpdm->dev = &pdev->dev;
|
||||||
|
|
||||||
ret = snd_soc_register_dai(&pdev->dev, &omap_mcpdm_dai);
|
return snd_soc_register_dai(&pdev->dev, &omap_mcpdm_dai);
|
||||||
if (!ret)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
err_irq:
|
|
||||||
iounmap(mcpdm->io_base);
|
|
||||||
err_iomap:
|
|
||||||
release_mem_region(res->start, resource_size(res));
|
|
||||||
err_res:
|
|
||||||
kfree(mcpdm);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __devexit asoc_mcpdm_remove(struct platform_device *pdev)
|
static int __devexit asoc_mcpdm_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct omap_mcpdm *mcpdm = platform_get_drvdata(pdev);
|
|
||||||
struct resource *res;
|
|
||||||
|
|
||||||
snd_soc_unregister_dai(&pdev->dev);
|
snd_soc_unregister_dai(&pdev->dev);
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
||||||
iounmap(mcpdm->io_base);
|
|
||||||
release_mem_region(res->start, resource_size(res));
|
|
||||||
|
|
||||||
kfree(mcpdm);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче