]> git.proxmox.com Git - mirror_qemu.git/blame - 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
CommitLineData
044e2af9
PMD
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
d3ec684d
PMD
14// Replace memory_region_init_ram(readonly) by memory_region_init_rom()
15@@
16expression E1, E2, E3, E4, E5;
17symbol 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
96d851a6
PM
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@@
39expression MR;
40expression NAME;
41expression SIZE;
42expression 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@@
49expression MR;
50expression NAME;
51expression SIZE;
52expression 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@@
59expression MR;
60expression OPS;
61expression OPAQUE;
62expression NAME;
63expression SIZE;
64expression 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);