Commit dd48ccc4 authored by Jingoo Han's avatar Jingoo Han Committed by Linus Torvalds

rtc: rtc-pcf2123: use devm_*() functions

Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6b5f4862
...@@ -226,7 +226,8 @@ static int pcf2123_probe(struct spi_device *spi) ...@@ -226,7 +226,8 @@ static int pcf2123_probe(struct spi_device *spi)
u8 txbuf[2], rxbuf[2]; u8 txbuf[2], rxbuf[2];
int ret, i; int ret, i;
pdata = kzalloc(sizeof(struct pcf2123_plat_data), GFP_KERNEL); pdata = devm_kzalloc(&spi->dev, sizeof(struct pcf2123_plat_data),
GFP_KERNEL);
if (!pdata) if (!pdata)
return -ENOMEM; return -ENOMEM;
spi->dev.platform_data = pdata; spi->dev.platform_data = pdata;
...@@ -281,7 +282,7 @@ static int pcf2123_probe(struct spi_device *spi) ...@@ -281,7 +282,7 @@ static int pcf2123_probe(struct spi_device *spi)
pcf2123_delay_trec(); pcf2123_delay_trec();
/* Finalize the initialization */ /* Finalize the initialization */
rtc = rtc_device_register(pcf2123_driver.driver.name, &spi->dev, rtc = devm_rtc_device_register(&spi->dev, pcf2123_driver.driver.name,
&pcf2123_rtc_ops, THIS_MODULE); &pcf2123_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) { if (IS_ERR(rtc)) {
...@@ -314,7 +315,6 @@ static int pcf2123_probe(struct spi_device *spi) ...@@ -314,7 +315,6 @@ static int pcf2123_probe(struct spi_device *spi)
device_remove_file(&spi->dev, &pdata->regs[i].attr); device_remove_file(&spi->dev, &pdata->regs[i].attr);
kfree_exit: kfree_exit:
kfree(pdata);
spi->dev.platform_data = NULL; spi->dev.platform_data = NULL;
return ret; return ret;
} }
...@@ -325,15 +325,10 @@ static int pcf2123_remove(struct spi_device *spi) ...@@ -325,15 +325,10 @@ static int pcf2123_remove(struct spi_device *spi)
int i; int i;
if (pdata) { if (pdata) {
struct rtc_device *rtc = pdata->rtc;
if (rtc)
rtc_device_unregister(rtc);
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
if (pdata->regs[i].name[0]) if (pdata->regs[i].name[0])
device_remove_file(&spi->dev, device_remove_file(&spi->dev,
&pdata->regs[i].attr); &pdata->regs[i].attr);
kfree(pdata);
} }
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