aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-pcf2123.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-pcf2123.c')
-rw-r--r--drivers/rtc/rtc-pcf2123.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c
index 02b742afa761..796a6c5067dd 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;
@@ -265,6 +266,7 @@ static int pcf2123_probe(struct spi_device *spi)
265 266
266 if (!(rxbuf[0] & 0x20)) { 267 if (!(rxbuf[0] & 0x20)) {
267 dev_err(&spi->dev, "chip not found\n"); 268 dev_err(&spi->dev, "chip not found\n");
269 ret = -ENODEV;
268 goto kfree_exit; 270 goto kfree_exit;
269 } 271 }
270 272
@@ -281,7 +283,7 @@ static int pcf2123_probe(struct spi_device *spi)
281 pcf2123_delay_trec(); 283 pcf2123_delay_trec();
282 284
283 /* Finalize the initialization */ 285 /* Finalize the initialization */
284 rtc = rtc_device_register(pcf2123_driver.driver.name, &spi->dev, 286 rtc = devm_rtc_device_register(&spi->dev, pcf2123_driver.driver.name,
285 &pcf2123_rtc_ops, THIS_MODULE); 287 &pcf2123_rtc_ops, THIS_MODULE);
286 288
287 if (IS_ERR(rtc)) { 289 if (IS_ERR(rtc)) {
@@ -314,7 +316,6 @@ sysfs_exit:
314 device_remove_file(&spi->dev, &pdata->regs[i].attr); 316 device_remove_file(&spi->dev, &pdata->regs[i].attr);
315 317
316kfree_exit: 318kfree_exit:
317 kfree(pdata);
318 spi->dev.platform_data = NULL; 319 spi->dev.platform_data = NULL;
319 return ret; 320 return ret;
320} 321}
@@ -325,15 +326,10 @@ static int pcf2123_remove(struct spi_device *spi)
325 int i; 326 int i;
326 327
327 if (pdata) { 328 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++) 329 for (i = 0; i < 16; i++)
333 if (pdata->regs[i].name[0]) 330 if (pdata->regs[i].name[0])
334 device_remove_file(&spi->dev, 331 device_remove_file(&spi->dev,
335 &pdata->regs[i].attr); 332 &pdata->regs[i].attr);
336 kfree(pdata);
337 } 333 }
338 334
339 return 0; 335 return 0;