]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/rtc/rtc-pcf2123.c
Merge tag 'fixes-for-3.10-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git...
[karo-tx-linux.git] / drivers / rtc / rtc-pcf2123.c
index 02b742afa761649b0737ab00da9cf69b8526feb8..796a6c5067dd58bc106f746f39e3b9f221838d97 100644 (file)
@@ -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;
@@ -265,6 +266,7 @@ static int pcf2123_probe(struct spi_device *spi)
 
        if (!(rxbuf[0] & 0x20)) {
                dev_err(&spi->dev, "chip not found\n");
+               ret = -ENODEV;
                goto kfree_exit;
        }
 
@@ -281,7 +283,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 +316,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 +326,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;