Commit b38be288 authored by Sachin Kamat's avatar Sachin Kamat Committed by Brian Norris

mtd: sst25l: Use devm_kzalloc

devm_kzalloc is device managed and makes code simpler.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent fcfd9f2d
...@@ -364,7 +364,7 @@ static int sst25l_probe(struct spi_device *spi) ...@@ -364,7 +364,7 @@ static int sst25l_probe(struct spi_device *spi)
if (!flash_info) if (!flash_info)
return -ENODEV; return -ENODEV;
flash = kzalloc(sizeof(struct sst25l_flash), GFP_KERNEL); flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL);
if (!flash) if (!flash)
return -ENOMEM; return -ENOMEM;
...@@ -402,10 +402,8 @@ static int sst25l_probe(struct spi_device *spi) ...@@ -402,10 +402,8 @@ static int sst25l_probe(struct spi_device *spi)
ret = mtd_device_parse_register(&flash->mtd, NULL, NULL, ret = mtd_device_parse_register(&flash->mtd, NULL, NULL,
data ? data->parts : NULL, data ? data->parts : NULL,
data ? data->nr_parts : 0); data ? data->nr_parts : 0);
if (ret) { if (ret)
kfree(flash);
return -ENODEV; return -ENODEV;
}
return 0; return 0;
} }
...@@ -413,12 +411,8 @@ static int sst25l_probe(struct spi_device *spi) ...@@ -413,12 +411,8 @@ static int sst25l_probe(struct spi_device *spi)
static int sst25l_remove(struct spi_device *spi) static int sst25l_remove(struct spi_device *spi)
{ {
struct sst25l_flash *flash = spi_get_drvdata(spi); struct sst25l_flash *flash = spi_get_drvdata(spi);
int ret;
ret = mtd_device_unregister(&flash->mtd); return mtd_device_unregister(&flash->mtd);
if (ret == 0)
kfree(flash);
return ret;
} }
static struct spi_driver sst25l_driver = { static struct spi_driver sst25l_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment