drivers: rkflash: Fix the error of repeatedly calling memory allocation

Reinit the spiflash in resume ops and result in memory leak.

Change-Id: Id0a12f115f267df91e27a9cfc9d01ecce71be256
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
This commit is contained in:
Jon Lin
2022-08-15 17:21:27 +08:00
committed by Tao Huang
parent fba09b4ecb
commit b8eea96692
2 changed files with 6 additions and 3 deletions

View File

@@ -1058,7 +1058,8 @@ u32 sfc_nand_init(void)
return (u32)FTL_UNSUPPORTED_FLASH;
}
gp_page_buf = (u32 *)__get_free_pages(GFP_KERNEL | GFP_DMA32, get_order(SFC_NAND_PAGE_MAX_SIZE));
if (!gp_page_buf)
gp_page_buf = (u32 *)__get_free_pages(GFP_KERNEL | GFP_DMA32, get_order(SFC_NAND_PAGE_MAX_SIZE));
if (!gp_page_buf)
return -ENOMEM;
@@ -1074,7 +1075,8 @@ u32 sfc_nand_init(void)
sfc_nand_dev.prog_lines = DATA_LINES_X1;
sfc_nand_dev.page_read_cmd = 0x03;
sfc_nand_dev.page_prog_cmd = 0x02;
sfc_nand_dev.recheck_buffer = (u8 *)__get_free_pages(GFP_KERNEL | GFP_DMA32, get_order(SFC_NAND_PAGE_MAX_SIZE));
if (!sfc_nand_dev.recheck_buffer)
sfc_nand_dev.recheck_buffer = (u8 *)__get_free_pages(GFP_KERNEL | GFP_DMA32, get_order(SFC_NAND_PAGE_MAX_SIZE));
if (!sfc_nand_dev.recheck_buffer) {
pr_err("%s recheck_buffer alloc failed\n", __func__);
return -ENOMEM;

View File

@@ -32,7 +32,8 @@ static int spi_nor_init(void __iomem *reg_addr)
struct id_block_tag *idb_tag;
struct snor_info_packet *packet;
sfnor_dev = kzalloc(sizeof(*sfnor_dev), GFP_KERNEL);
if (!sfnor_dev)
sfnor_dev = kzalloc(sizeof(*sfnor_dev), GFP_KERNEL);
if (!sfnor_dev)
return -ENOMEM;