From 356b355ceec09a5b96426ecda7f4ffd02f8eb04f Mon Sep 17 00:00:00 2001 From: Yifeng Zhao Date: Thu, 20 Apr 2023 10:22:59 +0800 Subject: [PATCH] soc: rockchip: vendor_storage: move some defines to common header file Signed-off-by: Yifeng Zhao Change-Id: Ic11edc5bf111689024dcc45f5d94d0cda231830a --- drivers/soc/rockchip/flash_vendor_storage.c | 25 +---------- drivers/soc/rockchip/mtd_vendor_storage.c | 42 +++---------------- drivers/soc/rockchip/sdmmc_vendor_storage.c | 42 +++---------------- .../linux/soc/rockchip/rk_vendor_storage.h | 37 ++++++++++++++++ 4 files changed, 51 insertions(+), 95 deletions(-) diff --git a/drivers/soc/rockchip/flash_vendor_storage.c b/drivers/soc/rockchip/flash_vendor_storage.c index 72961108ee5a..7c8cd338d286 100644 --- a/drivers/soc/rockchip/flash_vendor_storage.c +++ b/drivers/soc/rockchip/flash_vendor_storage.c @@ -23,34 +23,13 @@ #define DLOG(x...) #endif -struct vendor_item { - u16 id; - u16 offset; - u16 size; - u16 flag; -}; - #define FLASH_VENDOR_PART_START 8 -#define FLASH_VENDOR_PART_SIZE 8 #define FLASH_VENDOR_PART_NUM 4 -#define FLASH_VENDOR_TAG 0x524B5644 - -struct tag_vendor_info { - u32 tag; - u32 version; - u16 next_index; - u16 item_num; - u16 free_offset; - u16 free_size; - struct vendor_item item[62]; /* 62 * 8 */ - u8 data[FLASH_VENDOR_PART_SIZE * 512 - 512 - 8]; - u32 hash; - u32 version2; -}; +#define FLASH_VENDOR_TAG VENDOR_HEAD_TAG static int (*_flash_read)(u32 sec, u32 n_sec, void *p_data); static int (*_flash_write)(u32 sec, u32 n_sec, void *p_data); -static struct tag_vendor_info *g_vendor; +static struct flash_vendor_info *g_vendor; int flash_vendor_dev_ops_register(int (*read)(u32 sec, u32 n_sec, diff --git a/drivers/soc/rockchip/mtd_vendor_storage.c b/drivers/soc/rockchip/mtd_vendor_storage.c index 4c6d955f104a..2f4e4f8038f9 100644 --- a/drivers/soc/rockchip/mtd_vendor_storage.c +++ b/drivers/soc/rockchip/mtd_vendor_storage.c @@ -16,38 +16,12 @@ #include #include #include +#include #define MTD_VENDOR_PART_START 0 -#define MTD_VENDOR_PART_SIZE 8 +#define MTD_VENDOR_PART_SIZE FLASH_VENDOR_PART_SIZE #define MTD_VENDOR_PART_NUM 1 -#define MTD_VENDOR_TAG 0x524B5644 - -struct rk_vendor_req { - u32 tag; - u16 id; - u16 len; - u8 data[1024]; -}; - -struct vendor_item { - u16 id; - u16 offset; - u16 size; - u16 flag; -}; - -struct vendor_info { - u32 tag; - u32 version; - u16 next_index; - u16 item_num; - u16 free_offset; - u16 free_size; - struct vendor_item item[62]; - u8 data[MTD_VENDOR_PART_SIZE * 512 - 512 - 8]; - u32 hash; - u32 version2; -}; +#define MTD_VENDOR_TAG VENDOR_HEAD_TAG struct mtd_nand_info { u32 blk_offset; @@ -65,12 +39,8 @@ struct mtd_nand_info { #define GET_LOCK_FLAG_IO _IOW('r', 0x53, unsigned int) #endif -#define VENDOR_REQ_TAG 0x56524551 -#define VENDOR_READ_IO _IOW('v', 0x01, unsigned int) -#define VENDOR_WRITE_IO _IOW('v', 0x02, unsigned int) - static u8 *g_idb_buffer; -static struct vendor_info *g_vendor; +static struct flash_vendor_info *g_vendor; static DEFINE_MUTEX(vendor_ops_mutex); static struct mtd_info *mtd; static const char *vendor_mtd_name = "vnvm"; @@ -306,7 +276,7 @@ static long vendor_storage_ioctl(struct file *file, unsigned int cmd, { long ret = -1; int size; - struct rk_vendor_req *v_req; + struct RK_VENDOR_REQ *v_req; u32 *page_buf; page_buf = kmalloc(4096, GFP_KERNEL); @@ -315,7 +285,7 @@ static long vendor_storage_ioctl(struct file *file, unsigned int cmd, mutex_lock(&vendor_ops_mutex); - v_req = (struct rk_vendor_req *)page_buf; + v_req = (struct RK_VENDOR_REQ *)page_buf; switch (cmd) { case VENDOR_READ_IO: diff --git a/drivers/soc/rockchip/sdmmc_vendor_storage.c b/drivers/soc/rockchip/sdmmc_vendor_storage.c index 469eda37e7e4..d8681b920742 100644 --- a/drivers/soc/rockchip/sdmmc_vendor_storage.c +++ b/drivers/soc/rockchip/sdmmc_vendor_storage.c @@ -23,42 +23,16 @@ #include #include #include +#include #include "../../mmc/host/rk_sdmmc_ops.h" #define EMMC_IDB_PART_OFFSET 64 #define EMMC_SYS_PART_OFFSET 8064 #define EMMC_BOOT_PART_SIZE 1024 #define EMMC_VENDOR_PART_START (1024 * 7) -#define EMMC_VENDOR_PART_SIZE 128 +#define EMMC_VENDOR_PART_SIZE VENDOR_PART_SIZE #define EMMC_VENDOR_PART_NUM 4 -#define EMMC_VENDOR_TAG 0x524B5644 - -struct rk_vendor_req { - u32 tag; - u16 id; - u16 len; - u8 data[1024]; -}; - -struct vendor_item { - u16 id; - u16 offset; - u16 size; - u16 flag; -}; - -struct vendor_info { - u32 tag; - u32 version; - u16 next_index; - u16 item_num; - u16 free_offset; - u16 free_size; - struct vendor_item item[126]; /* 126 * 8*/ - u8 data[EMMC_VENDOR_PART_SIZE * 512 - 1024 - 8]; - u32 hash; - u32 version2; -}; +#define EMMC_VENDOR_TAG VENDOR_HEAD_TAG #ifdef CONFIG_ROCKCHIP_VENDOR_STORAGE_UPDATE_LOADER #define READ_SECTOR_IO _IOW('r', 0x04, unsigned int) @@ -69,10 +43,6 @@ struct vendor_info { #define GET_LOCK_FLAG_IO _IOW('r', 0x53, unsigned int) #endif -#define VENDOR_REQ_TAG 0x56524551 -#define VENDOR_READ_IO _IOW('v', 0x01, unsigned int) -#define VENDOR_WRITE_IO _IOW('v', 0x02, unsigned int) - static u8 *g_idb_buffer; static struct vendor_info *g_vendor; static DEFINE_MUTEX(vendor_ops_mutex); @@ -405,7 +375,7 @@ static long vendor_storage_ioctl(struct file *file, unsigned int cmd, { long ret = -1; int size; - struct rk_vendor_req *v_req; + struct RK_VENDOR_REQ *v_req; u32 *page_buf; page_buf = kmalloc(4096, GFP_KERNEL); @@ -414,7 +384,7 @@ static long vendor_storage_ioctl(struct file *file, unsigned int cmd, mutex_lock(&vendor_ops_mutex); - v_req = (struct rk_vendor_req *)page_buf; + v_req = (struct RK_VENDOR_REQ *)page_buf; switch (cmd) { case VENDOR_READ_IO: @@ -573,7 +543,7 @@ exit: return ret; } -const struct file_operations vendor_storage_fops = { +static const struct file_operations vendor_storage_fops = { .open = vendor_storage_open, .compat_ioctl = vendor_storage_ioctl, .unlocked_ioctl = vendor_storage_ioctl, diff --git a/include/linux/soc/rockchip/rk_vendor_storage.h b/include/linux/soc/rockchip/rk_vendor_storage.h index 29cee9bf6aba..d30b775e6a5f 100644 --- a/include/linux/soc/rockchip/rk_vendor_storage.h +++ b/include/linux/soc/rockchip/rk_vendor_storage.h @@ -29,6 +29,43 @@ #define LAN_RGMII_DL_ID 16 #define EINK_VCOM_ID 17 +#define VENDOR_HEAD_TAG 0x524B5644 +#define FLASH_VENDOR_PART_SIZE 8 +#define VENDOR_PART_SIZE 128 + +struct vendor_item { + u16 id; + u16 offset; + u16 size; + u16 flag; +}; + +struct vendor_info { + u32 tag; + u32 version; + u16 next_index; + u16 item_num; + u16 free_offset; + u16 free_size; + struct vendor_item item[126]; /* 126 * 8 */ + u8 data[VENDOR_PART_SIZE * 512 - 1024 - 8]; + u32 hash; + u32 version2; +}; + +struct flash_vendor_info { + u32 tag; + u32 version; + u16 next_index; + u16 item_num; + u16 free_offset; + u16 free_size; + struct vendor_item item[62]; /* 62 * 8 */ + u8 data[FLASH_VENDOR_PART_SIZE * 512 - 512 - 8]; + u32 hash; + u32 version2; +}; + #if IS_REACHABLE(CONFIG_ROCKCHIP_VENDOR_STORAGE) int rk_vendor_read(u32 id, void *pbuf, u32 size); int rk_vendor_write(u32 id, void *pbuf, u32 size);