Commit e7cff0ab authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Mark Brown

ASoC: ep93xx-ac97: use devm_* helpers to cleanup probe

Use the devm_* helpers to cleanup the probe routine. This also eliminates
having to carry the mem and irq values in the private data for the remove.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Tested-by: default avatarMika Westerberg <mika.westerberg@iki.fi>
Acked-by: default avatarMika Westerberg <mika.westerberg@iki.fi>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent b46b373f
...@@ -87,17 +87,13 @@ ...@@ -87,17 +87,13 @@
* struct ep93xx_ac97_info - EP93xx AC97 controller info structure * struct ep93xx_ac97_info - EP93xx AC97 controller info structure
* @lock: mutex serializing access to the bus (slot 1 & 2 ops) * @lock: mutex serializing access to the bus (slot 1 & 2 ops)
* @dev: pointer to the platform device dev structure * @dev: pointer to the platform device dev structure
* @mem: physical memory resource for the registers
* @regs: mapped AC97 controller registers * @regs: mapped AC97 controller registers
* @irq: AC97 interrupt number
* @done: bus ops wait here for an interrupt * @done: bus ops wait here for an interrupt
*/ */
struct ep93xx_ac97_info { struct ep93xx_ac97_info {
struct mutex lock; struct mutex lock;
struct device *dev; struct device *dev;
struct resource *mem;
void __iomem *regs; void __iomem *regs;
int irq;
struct completion done; struct completion done;
}; };
...@@ -359,66 +355,50 @@ static struct snd_soc_dai_driver ep93xx_ac97_dai = { ...@@ -359,66 +355,50 @@ static struct snd_soc_dai_driver ep93xx_ac97_dai = {
static int __devinit ep93xx_ac97_probe(struct platform_device *pdev) static int __devinit ep93xx_ac97_probe(struct platform_device *pdev)
{ {
struct ep93xx_ac97_info *info; struct ep93xx_ac97_info *info;
struct resource *res;
unsigned int irq;
int ret; int ret;
info = kzalloc(sizeof(struct ep93xx_ac97_info), GFP_KERNEL); info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
if (!info) if (!info)
return -ENOMEM; return -ENOMEM;
dev_set_drvdata(&pdev->dev, info); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
mutex_init(&info->lock); return -ENODEV;
init_completion(&info->done);
info->dev = &pdev->dev;
info->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); info->regs = devm_request_and_ioremap(&pdev->dev, res);
if (!info->mem) { if (!info->regs)
ret = -ENXIO; return -ENXIO;
goto fail_free_info;
}
info->irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (!info->irq) { if (!irq)
ret = -ENXIO; return -ENODEV;
goto fail_free_info;
}
if (!request_mem_region(info->mem->start, resource_size(info->mem), ret = devm_request_irq(&pdev->dev, irq, ep93xx_ac97_interrupt,
pdev->name)) { IRQF_TRIGGER_HIGH, pdev->name, info);
ret = -EBUSY; if (ret)
goto fail_free_info; goto fail;
}
info->regs = ioremap(info->mem->start, resource_size(info->mem)); dev_set_drvdata(&pdev->dev, info);
if (!info->regs) {
ret = -ENOMEM;
goto fail_release_mem;
}
ret = request_irq(info->irq, ep93xx_ac97_interrupt, IRQF_TRIGGER_HIGH, mutex_init(&info->lock);
pdev->name, info); init_completion(&info->done);
if (ret) info->dev = &pdev->dev;
goto fail_unmap_mem;
ep93xx_ac97_info = info; ep93xx_ac97_info = info;
platform_set_drvdata(pdev, info); platform_set_drvdata(pdev, info);
ret = snd_soc_register_dai(&pdev->dev, &ep93xx_ac97_dai); ret = snd_soc_register_dai(&pdev->dev, &ep93xx_ac97_dai);
if (ret) if (ret)
goto fail_free_irq; goto fail;
return 0; return 0;
fail_free_irq: fail:
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
free_irq(info->irq, info); ep93xx_ac97_info = NULL;
fail_unmap_mem: dev_set_drvdata(&pdev->dev, NULL);
iounmap(info->regs);
fail_release_mem:
release_mem_region(info->mem->start, resource_size(info->mem));
fail_free_info:
kfree(info);
return ret; return ret;
} }
...@@ -431,11 +411,9 @@ static int __devexit ep93xx_ac97_remove(struct platform_device *pdev) ...@@ -431,11 +411,9 @@ static int __devexit ep93xx_ac97_remove(struct platform_device *pdev)
/* disable the AC97 controller */ /* disable the AC97 controller */
ep93xx_ac97_write_reg(info, AC97GCR, 0); ep93xx_ac97_write_reg(info, AC97GCR, 0);
free_irq(info->irq, info);
iounmap(info->regs);
release_mem_region(info->mem->start, resource_size(info->mem));
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(info); ep93xx_ac97_info = NULL;
dev_set_drvdata(&pdev->dev, NULL);
return 0; return 0;
} }
......
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