rtc: rtc-pxa: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
c417299ce7
commit
618c300305
|
@ -324,37 +324,35 @@ static int __init pxa_rtc_probe(struct platform_device *pdev)
|
||||||
int ret;
|
int ret;
|
||||||
u32 rttr;
|
u32 rttr;
|
||||||
|
|
||||||
pxa_rtc = kzalloc(sizeof(struct pxa_rtc), GFP_KERNEL);
|
pxa_rtc = devm_kzalloc(dev, sizeof(*pxa_rtc), GFP_KERNEL);
|
||||||
if (!pxa_rtc)
|
if (!pxa_rtc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
spin_lock_init(&pxa_rtc->lock);
|
spin_lock_init(&pxa_rtc->lock);
|
||||||
platform_set_drvdata(pdev, pxa_rtc);
|
platform_set_drvdata(pdev, pxa_rtc);
|
||||||
|
|
||||||
ret = -ENXIO;
|
|
||||||
pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
if (!pxa_rtc->ress) {
|
if (!pxa_rtc->ress) {
|
||||||
dev_err(dev, "No I/O memory resource defined\n");
|
dev_err(dev, "No I/O memory resource defined\n");
|
||||||
goto err_ress;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
pxa_rtc->irq_1Hz = platform_get_irq(pdev, 0);
|
pxa_rtc->irq_1Hz = platform_get_irq(pdev, 0);
|
||||||
if (pxa_rtc->irq_1Hz < 0) {
|
if (pxa_rtc->irq_1Hz < 0) {
|
||||||
dev_err(dev, "No 1Hz IRQ resource defined\n");
|
dev_err(dev, "No 1Hz IRQ resource defined\n");
|
||||||
goto err_ress;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
pxa_rtc->irq_Alrm = platform_get_irq(pdev, 1);
|
pxa_rtc->irq_Alrm = platform_get_irq(pdev, 1);
|
||||||
if (pxa_rtc->irq_Alrm < 0) {
|
if (pxa_rtc->irq_Alrm < 0) {
|
||||||
dev_err(dev, "No alarm IRQ resource defined\n");
|
dev_err(dev, "No alarm IRQ resource defined\n");
|
||||||
goto err_ress;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
pxa_rtc_open(dev);
|
pxa_rtc_open(dev);
|
||||||
ret = -ENOMEM;
|
pxa_rtc->base = devm_ioremap(dev, pxa_rtc->ress->start,
|
||||||
pxa_rtc->base = ioremap(pxa_rtc->ress->start,
|
|
||||||
resource_size(pxa_rtc->ress));
|
resource_size(pxa_rtc->ress));
|
||||||
if (!pxa_rtc->base) {
|
if (!pxa_rtc->base) {
|
||||||
dev_err(&pdev->dev, "Unable to map pxa RTC I/O memory\n");
|
dev_err(dev, "Unable to map pxa RTC I/O memory\n");
|
||||||
goto err_map;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -370,41 +368,24 @@ static int __init pxa_rtc_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE);
|
rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE);
|
||||||
|
|
||||||
pxa_rtc->rtc = rtc_device_register("pxa-rtc", &pdev->dev, &pxa_rtc_ops,
|
pxa_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pxa-rtc",
|
||||||
THIS_MODULE);
|
&pxa_rtc_ops, THIS_MODULE);
|
||||||
ret = PTR_ERR(pxa_rtc->rtc);
|
|
||||||
if (IS_ERR(pxa_rtc->rtc)) {
|
if (IS_ERR(pxa_rtc->rtc)) {
|
||||||
|
ret = PTR_ERR(pxa_rtc->rtc);
|
||||||
dev_err(dev, "Failed to register RTC device -> %d\n", ret);
|
dev_err(dev, "Failed to register RTC device -> %d\n", ret);
|
||||||
goto err_rtc_reg;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
device_init_wakeup(dev, 1);
|
device_init_wakeup(dev, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_rtc_reg:
|
|
||||||
iounmap(pxa_rtc->base);
|
|
||||||
err_ress:
|
|
||||||
err_map:
|
|
||||||
kfree(pxa_rtc);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __exit pxa_rtc_remove(struct platform_device *pdev)
|
static int __exit pxa_rtc_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev);
|
|
||||||
|
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
|
|
||||||
pxa_rtc_release(dev);
|
pxa_rtc_release(dev);
|
||||||
|
|
||||||
rtc_device_unregister(pxa_rtc->rtc);
|
|
||||||
|
|
||||||
spin_lock_irq(&pxa_rtc->lock);
|
|
||||||
iounmap(pxa_rtc->base);
|
|
||||||
spin_unlock_irq(&pxa_rtc->lock);
|
|
||||||
|
|
||||||
kfree(pxa_rtc);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue