summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-04-29 16:20:47 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 18:28:38 -0700
commitdd48ccc491c3c327bef12e4d07bfa4d4266be3b9 (patch)
tree29089d0c2678b3dd4387681c0a1c95711013fcbc /drivers
parent6b5f486225f6a4ec052209a466d580a1d1d92ce5 (diff)
rtc: rtc-pcf2123: 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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rtc/rtc-pcf2123.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c
index 02b742afa76..6a3f329c3df 100644
--- a/drivers/rtc/rtc-pcf2123.c
+++ b/drivers/rtc/rtc-pcf2123.c
@@ -226,7 +226,8 @@ static int pcf2123_probe(struct spi_device *spi)
u8 txbuf[2], rxbuf[2];
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)
return -ENOMEM;
spi->dev.platform_data = pdata;
@@ -281,7 +282,7 @@ static int pcf2123_probe(struct spi_device *spi)
pcf2123_delay_trec();
/* 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);
if (IS_ERR(rtc)) {
@@ -314,7 +315,6 @@ sysfs_exit:
device_remove_file(&spi->dev, &pdata->regs[i].attr);
kfree_exit:
- kfree(pdata);
spi->dev.platform_data = NULL;
return ret;
}
@@ -325,15 +325,10 @@ static int pcf2123_remove(struct spi_device *spi)
int i;
if (pdata) {
- struct rtc_device *rtc = pdata->rtc;
-
- if (rtc)
- rtc_device_unregister(rtc);
for (i = 0; i < 16; i++)
if (pdata->regs[i].name[0])
device_remove_file(&spi->dev,
&pdata->regs[i].attr);
- kfree(pdata);
}
return 0;