diff --git a/drivers/mtd/spiflash/spi020_nand.c b/drivers/mtd/spiflash/spi020_nand.c index 36da5276cd..bd43609230 100644 --- a/drivers/mtd/spiflash/spi020_nand.c +++ b/drivers/mtd/spiflash/spi020_nand.c @@ -1066,7 +1066,8 @@ static int spinand_probe(struct platform_device *pdev) info->pdev = pdev; - info->flash_info = kmalloc(sizeof(struct nvt_nand_flash), GFP_KERNEL); + info->flash_info = devm_kzalloc(&pdev->dev, sizeof(struct nvt_nand_flash), + GFP_KERNEL); if (!info->flash_info) { dev_err(&pdev->dev, "failed to allocate nvt_nand_flash\n"); return -ENOMEM; @@ -1205,8 +1206,8 @@ static int spinand_probe(struct platform_device *pdev) static int spinand_remove(struct platform_device *pdev) { - struct mtd_info *mtd = platform_get_drvdata(pdev); - struct drv_nand_dev_info *info = mtd->priv; + struct drv_nand_dev_info *info = platform_get_drvdata(pdev); + struct mtd_info *mtd = nand_to_mtd(&info->nand_chip); platform_set_drvdata(pdev, NULL); @@ -1216,7 +1217,6 @@ static int spinand_remove(struct platform_device *pdev) kfree(info->data_buff); - kfree(mtd); return E_OK; } @@ -1224,8 +1224,7 @@ static int spinand_remove(struct platform_device *pdev) static int spinand_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); - struct mtd_info *mtd = platform_get_drvdata(pdev); - struct drv_nand_dev_info *info = mtd->priv; + struct drv_nand_dev_info *info = platform_get_drvdata(pdev); if (!IS_ERR(info->clk)) clk_disable(info->clk); @@ -1235,8 +1234,7 @@ static int spinand_suspend(struct device *dev) static int spinand_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); - struct mtd_info *mtd = platform_get_drvdata(pdev); - struct drv_nand_dev_info *info = mtd->priv; + struct drv_nand_dev_info *info = platform_get_drvdata(pdev); clk_enable(info->clk); diff --git a/drivers/mtd/spiflash/spinand.c b/drivers/mtd/spiflash/spinand.c index 84775b382e..1a9693f2b4 100644 --- a/drivers/mtd/spiflash/spinand.c +++ b/drivers/mtd/spiflash/spinand.c @@ -1289,7 +1289,8 @@ static int spinand_probe(struct platform_device *pdev) info->pdev = pdev; - info->flash_info = kmalloc(sizeof(struct nvt_nand_flash), GFP_KERNEL); + info->flash_info = devm_kzalloc(&pdev->dev, sizeof(struct nvt_nand_flash), + GFP_KERNEL); if (!info->flash_info) { dev_err(&pdev->dev, "failed to allocate nvt_nand_flash\n"); return -ENOMEM; @@ -1457,8 +1458,8 @@ static int spinand_probe(struct platform_device *pdev) static int spinand_remove(struct platform_device *pdev) { - struct mtd_info *mtd = platform_get_drvdata(pdev); - struct drv_nand_dev_info *info = mtd->priv; + struct drv_nand_dev_info *info = platform_get_drvdata(pdev); + struct mtd_info *mtd = nand_to_mtd(&info->nand_chip); platform_set_drvdata(pdev, NULL); @@ -1468,7 +1469,6 @@ static int spinand_remove(struct platform_device *pdev) kfree(info->data_buff); - kfree(mtd); return E_OK; } @@ -1476,8 +1476,7 @@ static int spinand_remove(struct platform_device *pdev) static int spinand_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); - struct mtd_info *mtd = platform_get_drvdata(pdev); - struct drv_nand_dev_info *info = mtd->priv; + struct drv_nand_dev_info *info = platform_get_drvdata(pdev); if (!IS_ERR(info->clk)) clk_disable(info->clk); @@ -1487,8 +1486,7 @@ static int spinand_suspend(struct device *dev) static int spinand_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); - struct mtd_info *mtd = platform_get_drvdata(pdev); - struct drv_nand_dev_info *info = mtd->priv; + struct drv_nand_dev_info *info = platform_get_drvdata(pdev); clk_enable(info->clk);