--- a/drivers/mtd/maps/physmap.c +++ b/drivers/mtd/maps/physmap.c @@ -31,6 +31,66 @@ struct physmap_flash_info { int vpp_refcnt; }; +static struct platform_device *physmap_map2pdev(struct map_info *map) +{ + return (struct platform_device *) map->map_priv_1; +} + +static void physmap_lock(struct map_info *map) +{ + struct platform_device *pdev; + struct physmap_flash_data *physmap_data; + + pdev = physmap_map2pdev(map); + physmap_data = pdev->dev.platform_data; + physmap_data->lock(pdev); +} + +static void physmap_unlock(struct map_info *map) +{ + struct platform_device *pdev; + struct physmap_flash_data *physmap_data; + + pdev = physmap_map2pdev(map); + physmap_data = pdev->dev.platform_data; + physmap_data->unlock(pdev); +} + +static map_word physmap_flash_read_lock(struct map_info *map, unsigned long ofs) +{ + map_word ret; + + physmap_lock(map); + ret = inline_map_read(map, ofs); + physmap_unlock(map); + + return ret; +} + +static void physmap_flash_write_lock(struct map_info *map, map_word d, + unsigned long ofs) +{ + physmap_lock(map); + inline_map_write(map, d, ofs); + physmap_unlock(map); +} + +static void physmap_flash_copy_from_lock(struct map_info *map, void *to, + unsigned long from, ssize_t len) +{ + physmap_lock(map); + inline_map_copy_from(map, to, from, len); + physmap_unlock(map); +} + +static void physmap_flash_copy_to_lock(struct map_info *map, unsigned long to, + const void *from, ssize_t len) +{ + physmap_lock(map); + inline_map_copy_to(map, to, from, len); + physmap_unlock(map); +} + static int physmap_flash_remove(struct platform_device *dev) { struct physmap_flash_info *info; @@ -153,6 +213,13 @@ static int physmap_flash_probe(struct pl simple_map_init(&info->map[i]); + if (physmap_data->lock && physmap_data->unlock) { + info->map[i].read = physmap_flash_read_lock; + info->map[i].write = physmap_flash_write_lock; + info->map[i].copy_from = physmap_flash_copy_from_lock; + info->map[i].copy_to = physmap_flash_copy_to_lock; + } + probe_type = rom_probe_types; if (physmap_data->probe_type == NULL) { for (; info->mtd[i] == NULL && *probe_type != NULL; probe_type++) --- a/include/linux/mtd/physmap.h +++ b/include/linux/mtd/physmap.h @@ -25,6 +25,8 @@ struct physmap_flash_data { unsigned int width; int (*init)(struct platform_device *); void (*exit)(struct platform_device *); + void (*lock)(struct platform_device *); + void (*unlock)(struct platform_device *); void (*set_vpp)(struct platform_device *, int); unsigned int nr_parts; unsigned int pfow_base; vr/qmk/firmware/tree/?id=716c29881c0f91e3998e1fc5c49740bd6e65876f'>root/docs/newbs_building_firmware_configurator.md
blob: becceb6693ecd70dbee71ffebe91f811477de186 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105