diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-04-29 19:20:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:38 -0400 |
commit | dd48ccc491c3c327bef12e4d07bfa4d4266be3b9 (patch) | |
tree | 29089d0c2678b3dd4387681c0a1c95711013fcbc /drivers/rtc | |
parent | 6b5f486225f6a4ec052209a466d580a1d1d92ce5 (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/rtc')
-rw-r--r-- | drivers/rtc/rtc-pcf2123.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c index 02b742afa761..6a3f329c3df4 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) | |||
226 | u8 txbuf[2], rxbuf[2]; | 226 | u8 txbuf[2], rxbuf[2]; |
227 | int ret, i; | 227 | int ret, i; |
228 | 228 | ||
229 | pdata = kzalloc(sizeof(struct pcf2123_plat_data), GFP_KERNEL); | 229 | pdata = devm_kzalloc(&spi->dev, sizeof(struct pcf2123_plat_data), |
230 | GFP_KERNEL); | ||
230 | if (!pdata) | 231 | if (!pdata) |
231 | return -ENOMEM; | 232 | return -ENOMEM; |
232 | spi->dev.platform_data = pdata; | 233 | spi->dev.platform_data = pdata; |
@@ -281,7 +282,7 @@ static int pcf2123_probe(struct spi_device *spi) | |||
281 | pcf2123_delay_trec(); | 282 | pcf2123_delay_trec(); |
282 | 283 | ||
283 | /* Finalize the initialization */ | 284 | /* Finalize the initialization */ |
284 | rtc = rtc_device_register(pcf2123_driver.driver.name, &spi->dev, | 285 | rtc = devm_rtc_device_register(&spi->dev, pcf2123_driver.driver.name, |
285 | &pcf2123_rtc_ops, THIS_MODULE); | 286 | &pcf2123_rtc_ops, THIS_MODULE); |
286 | 287 | ||
287 | if (IS_ERR(rtc)) { | 288 | if (IS_ERR(rtc)) { |
@@ -314,7 +315,6 @@ sysfs_exit: | |||
314 | device_remove_file(&spi->dev, &pdata->regs[i].attr); | 315 | device_remove_file(&spi->dev, &pdata->regs[i].attr); |
315 | 316 | ||
316 | kfree_exit: | 317 | kfree_exit: |
317 | kfree(pdata); | ||
318 | spi->dev.platform_data = NULL; | 318 | spi->dev.platform_data = NULL; |
319 | return ret; | 319 | return ret; |
320 | } | 320 | } |
@@ -325,15 +325,10 @@ static int pcf2123_remove(struct spi_device *spi) | |||
325 | int i; | 325 | int i; |
326 | 326 | ||
327 | if (pdata) { | 327 | if (pdata) { |
328 | struct rtc_device *rtc = pdata->rtc; | ||
329 | |||
330 | if (rtc) | ||
331 | rtc_device_unregister(rtc); | ||
332 | for (i = 0; i < 16; i++) | 328 | for (i = 0; i < 16; i++) |
333 | if (pdata->regs[i].name[0]) | 329 | if (pdata->regs[i].name[0]) |
334 | device_remove_file(&spi->dev, | 330 | device_remove_file(&spi->dev, |
335 | &pdata->regs[i].attr); | 331 | &pdata->regs[i].attr); |
336 | kfree(pdata); | ||
337 | } | 332 | } |
338 | 333 | ||
339 | return 0; | 334 | return 0; |