]> git.proxmox.com Git - mirror_qemu.git/blob - scripts/coccinelle/memory-region-housekeeping.cocci
scripts/cocci: Patch to replace memory_region_init_{ram,readonly -> rom}
[mirror_qemu.git] / scripts / coccinelle / memory-region-housekeeping.cocci
1 /*
2 Usage:
3
4 spatch \
5 --macro-file scripts/cocci-macro-file.h \
6 --sp-file scripts/coccinelle/memory-region-housekeeping.cocci \
7 --keep-comments \
8 --in-place \
9 --dir .
10
11 */
12
13
14 // Replace memory_region_init_ram(readonly) by memory_region_init_rom()
15 @@
16 expression E1, E2, E3, E4, E5;
17 symbol true;
18 @@
19 (
20 - memory_region_init_ram(E1, E2, E3, E4, E5);
21 + memory_region_init_rom(E1, E2, E3, E4, E5);
22 ... WHEN != E1
23 - memory_region_set_readonly(E1, true);
24 |
25 - memory_region_init_ram_nomigrate(E1, E2, E3, E4, E5);
26 + memory_region_init_rom_nomigrate(E1, E2, E3, E4, E5);
27 ... WHEN != E1
28 - memory_region_set_readonly(E1, true);
29 )
30
31
32 // Replace by-hand memory_region_init_ram_nomigrate/vmstate_register_ram
33 // code sequences with use of the new memory_region_init_ram function.
34 // Similarly for the _rom and _rom_device functions.
35 // We don't try to replace sequences with a non-NULL owner, because
36 // there are none in the tree that can be automatically converted
37 // (and only a handful that can be manually converted).
38 @@
39 expression MR;
40 expression NAME;
41 expression SIZE;
42 expression ERRP;
43 @@
44 -memory_region_init_ram_nomigrate(MR, NULL, NAME, SIZE, ERRP);
45 +memory_region_init_ram(MR, NULL, NAME, SIZE, ERRP);
46 ...
47 -vmstate_register_ram_global(MR);
48 @@
49 expression MR;
50 expression NAME;
51 expression SIZE;
52 expression ERRP;
53 @@
54 -memory_region_init_rom_nomigrate(MR, NULL, NAME, SIZE, ERRP);
55 +memory_region_init_rom(MR, NULL, NAME, SIZE, ERRP);
56 ...
57 -vmstate_register_ram_global(MR);
58 @@
59 expression MR;
60 expression OPS;
61 expression OPAQUE;
62 expression NAME;
63 expression SIZE;
64 expression ERRP;
65 @@
66 -memory_region_init_rom_device_nomigrate(MR, NULL, OPS, OPAQUE, NAME, SIZE, ERRP);
67 +memory_region_init_rom_device(MR, NULL, OPS, OPAQUE, NAME, SIZE, ERRP);
68 ...
69 -vmstate_register_ram_global(MR);