1 --- a/drivers/mtd/maps/physmap.c
2 +++ b/drivers/mtd/maps/physmap.c
3 @@ -29,6 +29,66 @@ struct physmap_flash_info {
4 struct map_info map[MAX_RESOURCES];
7 +static struct platform_device *physmap_map2pdev(struct map_info *map)
9 + return (struct platform_device *) map->map_priv_1;
12 +static void physmap_lock(struct map_info *map)
14 + struct platform_device *pdev;
15 + struct physmap_flash_data *physmap_data;
17 + pdev = physmap_map2pdev(map);
18 + physmap_data = pdev->dev.platform_data;
19 + physmap_data->lock(pdev);
22 +static void physmap_unlock(struct map_info *map)
24 + struct platform_device *pdev;
25 + struct physmap_flash_data *physmap_data;
27 + pdev = physmap_map2pdev(map);
28 + physmap_data = pdev->dev.platform_data;
29 + physmap_data->unlock(pdev);
32 +static map_word physmap_flash_read_lock(struct map_info *map, unsigned long ofs)
37 + ret = inline_map_read(map, ofs);
38 + physmap_unlock(map);
43 +static void physmap_flash_write_lock(struct map_info *map, map_word d,
47 + inline_map_write(map, d, ofs);
48 + physmap_unlock(map);
51 +static void physmap_flash_copy_from_lock(struct map_info *map, void *to,
52 + unsigned long from, ssize_t len)
55 + inline_map_copy_from(map, to, from, len);
56 + physmap_unlock(map);
59 +static void physmap_flash_copy_to_lock(struct map_info *map, unsigned long to,
60 + const void *from, ssize_t len)
63 + inline_map_copy_to(map, to, from, len);
64 + physmap_unlock(map);
67 static int physmap_flash_remove(struct platform_device *dev)
69 struct physmap_flash_info *info;
70 @@ -141,6 +201,13 @@ static int physmap_flash_probe(struct pl
72 simple_map_init(&info->map[i]);
74 + if (physmap_data->lock && physmap_data->unlock) {
75 + info->map[i].read = physmap_flash_read_lock;
76 + info->map[i].write = physmap_flash_write_lock;
77 + info->map[i].copy_from = physmap_flash_copy_from_lock;
78 + info->map[i].copy_to = physmap_flash_copy_to_lock;
81 probe_type = rom_probe_types;
82 if (physmap_data->probe_type == NULL) {
83 for (; info->mtd[i] == NULL && *probe_type != NULL; probe_type++)
84 --- a/include/linux/mtd/physmap.h
85 +++ b/include/linux/mtd/physmap.h
86 @@ -26,6 +26,8 @@ struct physmap_flash_data {
88 int (*init)(struct platform_device *);
89 void (*exit)(struct platform_device *);
90 + void (*lock)(struct platform_device *);
91 + void (*unlock)(struct platform_device *);
92 void (*set_vpp)(struct platform_device *, int);
93 unsigned int nr_parts;
94 unsigned int pfow_base;