diff --git a/drivers/rkflash/nand_boot.c b/drivers/rkflash/nand_boot.c index 0685128ca128..1a9abc99f79f 100644 --- a/drivers/rkflash/nand_boot.c +++ b/drivers/rkflash/nand_boot.c @@ -35,14 +35,12 @@ unsigned int sftl_flash_get_capacity(void) int sftl_flash_write(u32 sec, u32 n_sec, void *p_data) { - sftl_write(sec, n_sec, p_data); - return 0; + return sftl_write(sec, n_sec, p_data); } int sftl_flash_read(u32 sec, u32 n_sec, void *p_data) { - sftl_read(sec, n_sec, p_data); - return 0; + return sftl_read(sec, n_sec, p_data); } void sftl_flash_deinit(void) diff --git a/drivers/rkflash/rkflash_blk.c b/drivers/rkflash/rkflash_blk.c index e3131309ddfd..ce107c6a3185 100644 --- a/drivers/rkflash/rkflash_blk.c +++ b/drivers/rkflash/rkflash_blk.c @@ -106,6 +106,38 @@ static char *mtd_read_temp_buffer; #define MTD_RW_SECTORS (512) static DEFINE_MUTEX(g_flash_ops_mutex); +static int vendor_read(u32 sec, u32 n_sec, void *p_data) +{ + int ret; + + if (g_boot_ops[g_flash_type]->vendor_read) { + mutex_lock(&g_flash_ops_mutex); + ret = g_boot_ops[g_flash_type]->vendor_read(sec, n_sec, p_data); + mutex_unlock(&g_flash_ops_mutex); + } else { + ret = -EPERM; + } + + return ret; +} + +static int vendor_write(u32 sec, u32 n_sec, void *p_data) +{ + int ret; + + if (g_boot_ops[g_flash_type]->vendor_write) { + mutex_lock(&g_flash_ops_mutex); + ret = g_boot_ops[g_flash_type]->vendor_write(sec, + n_sec, + p_data); + mutex_unlock(&g_flash_ops_mutex); + } else { + ret = -EPERM; + } + + return ret; +} + static unsigned int rk_partition_init(struct flash_part *part) { int i, part_num = 0; @@ -647,8 +679,8 @@ int rkflash_dev_init(void __iomem *reg_addr, enum flash_con_type con_type) pr_info("rkflash[%d] init success\n", tmp_id); g_flash_type = tmp_id; mytr.quit = 1; - flash_vendor_dev_ops_register(g_boot_ops[g_flash_type]->vendor_read, - g_boot_ops[g_flash_type]->vendor_write); + flash_vendor_dev_ops_register(&vendor_read, + &vendor_write); #ifdef CONFIG_RK_SFC_NOR_MTD if (g_flash_type == FLASH_TYPE_SFC_NOR) { pr_info("sfc_nor flash registered as a mtd device\n");