[tools] autoconf: another relocatability fix for autom4te, substitute hardcoded prefi...
[openwrt.git] / target / linux / ar71xx / patches-3.2 / 401-mtd-physmap-add-lock-unlock.patch
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];
5 };
6
7 +static struct platform_device *physmap_map2pdev(struct map_info *map)
8 +{
9 + return (struct platform_device *) map->map_priv_1;
10 +}
11 +
12 +static void physmap_lock(struct map_info *map)
13 +{
14 + struct platform_device *pdev;
15 + struct physmap_flash_data *physmap_data;
16 +
17 + pdev = physmap_map2pdev(map);
18 + physmap_data = pdev->dev.platform_data;
19 + physmap_data->lock(pdev);
20 +}
21 +
22 +static void physmap_unlock(struct map_info *map)
23 +{
24 + struct platform_device *pdev;
25 + struct physmap_flash_data *physmap_data;
26 +
27 + pdev = physmap_map2pdev(map);
28 + physmap_data = pdev->dev.platform_data;
29 + physmap_data->unlock(pdev);
30 +}
31 +
32 +static map_word physmap_flash_read_lock(struct map_info *map, unsigned long ofs)
33 +{
34 + map_word ret;
35 +
36 + physmap_lock(map);
37 + ret = inline_map_read(map, ofs);
38 + physmap_unlock(map);
39 +
40 + return ret;
41 +}
42 +
43 +static void physmap_flash_write_lock(struct map_info *map, map_word d,
44 + unsigned long ofs)
45 +{
46 + physmap_lock(map);
47 + inline_map_write(map, d, ofs);
48 + physmap_unlock(map);
49 +}
50 +
51 +static void physmap_flash_copy_from_lock(struct map_info *map, void *to,
52 + unsigned long from, ssize_t len)
53 +{
54 + physmap_lock(map);
55 + inline_map_copy_from(map, to, from, len);
56 + physmap_unlock(map);
57 +}
58 +
59 +static void physmap_flash_copy_to_lock(struct map_info *map, unsigned long to,
60 + const void *from, ssize_t len)
61 +{
62 + physmap_lock(map);
63 + inline_map_copy_to(map, to, from, len);
64 + physmap_unlock(map);
65 +}
66 +
67 static int physmap_flash_remove(struct platform_device *dev)
68 {
69 struct physmap_flash_info *info;
70 @@ -140,6 +200,13 @@ static int physmap_flash_probe(struct pl
71
72 simple_map_init(&info->map[i]);
73
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;
79 + }
80 +
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 {
87 unsigned int width;
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;
This page took 0.043456 seconds and 5 git commands to generate.