hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/soc/rockchip/mtd_vendor_storage.c
....@@ -16,38 +16,12 @@
1616 #include <linux/soc/rockchip/rk_vendor_storage.h>
1717 #include <linux/uaccess.h>
1818 #include <linux/vmalloc.h>
19
+#include <misc/rkflash_vendor_storage.h>
1920
2021 #define MTD_VENDOR_PART_START 0
21
-#define MTD_VENDOR_PART_SIZE 8
22
+#define MTD_VENDOR_PART_SIZE FLASH_VENDOR_PART_SIZE
2223 #define MTD_VENDOR_PART_NUM 1
23
-#define MTD_VENDOR_TAG 0x524B5644
24
-
25
-struct rk_vendor_req {
26
- u32 tag;
27
- u16 id;
28
- u16 len;
29
- u8 data[1024];
30
-};
31
-
32
-struct vendor_item {
33
- u16 id;
34
- u16 offset;
35
- u16 size;
36
- u16 flag;
37
-};
38
-
39
-struct vendor_info {
40
- u32 tag;
41
- u32 version;
42
- u16 next_index;
43
- u16 item_num;
44
- u16 free_offset;
45
- u16 free_size;
46
- struct vendor_item item[62];
47
- u8 data[MTD_VENDOR_PART_SIZE * 512 - 512 - 8];
48
- u32 hash;
49
- u32 version2;
50
-};
24
+#define MTD_VENDOR_TAG VENDOR_HEAD_TAG
5125
5226 struct mtd_nand_info {
5327 u32 blk_offset;
....@@ -65,16 +39,13 @@
6539 #define GET_LOCK_FLAG_IO _IOW('r', 0x53, unsigned int)
6640 #endif
6741
68
-#define VENDOR_REQ_TAG 0x56524551
69
-#define VENDOR_READ_IO _IOW('v', 0x01, unsigned int)
70
-#define VENDOR_WRITE_IO _IOW('v', 0x02, unsigned int)
71
-
7242 static u8 *g_idb_buffer;
73
-static struct vendor_info *g_vendor;
43
+static struct flash_vendor_info *g_vendor;
7444 static DEFINE_MUTEX(vendor_ops_mutex);
7545 static struct mtd_info *mtd;
7646 static const char *vendor_mtd_name = "vnvm";
7747 static struct mtd_nand_info nand_info;
48
+static struct platform_device *g_pdev;
7849
7950 static int mtd_vendor_nand_write(void)
8051 {
....@@ -305,7 +276,7 @@
305276 {
306277 long ret = -1;
307278 int size;
308
- struct rk_vendor_req *v_req;
279
+ struct RK_VENDOR_REQ *v_req;
309280 u32 *page_buf;
310281
311282 page_buf = kmalloc(4096, GFP_KERNEL);
....@@ -314,7 +285,7 @@
314285
315286 mutex_lock(&vendor_ops_mutex);
316287
317
- v_req = (struct rk_vendor_req *)page_buf;
288
+ v_req = (struct RK_VENDOR_REQ *)page_buf;
318289
319290 switch (cmd) {
320291 case VENDOR_READ_IO:
....@@ -436,6 +407,8 @@
436407
437408 g_idb_buffer = NULL;
438409 ret = platform_driver_register(&vendor_storage_driver);
410
+ if (ret)
411
+ return ret;
439412
440413 pdev = platform_device_register_simple("mtd_vendor_storage",
441414 -1, NULL, 0);
....@@ -443,8 +416,17 @@
443416 platform_driver_unregister(&vendor_storage_driver);
444417 return PTR_ERR(pdev);
445418 }
419
+ g_pdev = pdev;
446420
447421 return ret;
448422 }
449423
424
+static __exit void vendor_storage_deinit(void)
425
+{
426
+ platform_device_unregister(g_pdev);
427
+ platform_driver_unregister(&vendor_storage_driver);
428
+}
429
+
450430 device_initcall_sync(vendor_storage_init);
431
+module_exit(vendor_storage_deinit);
432
+MODULE_LICENSE("GPL");