]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/mtd/devices/sst25l.c
Merge remote-tracking branch 'l2-mtd/master'
[karo-tx-linux.git] / drivers / mtd / devices / sst25l.c
index a42f1f0e7281417398f4de453845ff8edf79b60c..687bf27ec85076c2d735418714c12c537c2dc498 100644 (file)
@@ -364,7 +364,7 @@ static int sst25l_probe(struct spi_device *spi)
        if (!flash_info)
                return -ENODEV;
 
-       flash = kzalloc(sizeof(struct sst25l_flash), GFP_KERNEL);
+       flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL);
        if (!flash)
                return -ENOMEM;
 
@@ -402,11 +402,8 @@ static int sst25l_probe(struct spi_device *spi)
        ret = mtd_device_parse_register(&flash->mtd, NULL, NULL,
                                        data ? data->parts : NULL,
                                        data ? data->nr_parts : 0);
-       if (ret) {
-               kfree(flash);
-               spi_set_drvdata(spi, NULL);
+       if (ret)
                return -ENODEV;
-       }
 
        return 0;
 }
@@ -414,12 +411,8 @@ static int sst25l_probe(struct spi_device *spi)
 static int sst25l_remove(struct spi_device *spi)
 {
        struct sst25l_flash *flash = spi_get_drvdata(spi);
-       int ret;
 
-       ret = mtd_device_unregister(&flash->mtd);
-       if (ret == 0)
-               kfree(flash);
-       return ret;
+       return mtd_device_unregister(&flash->mtd);
 }
 
 static struct spi_driver sst25l_driver = {