xref: /openbmc/qemu/scripts/coccinelle/memory-region-housekeeping.cocci (revision 044e2af9f5f55d81be754a0e2ba1d206ad2b3bc6)
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 by-hand memory_region_init_ram_nomigrate/vmstate_register_ram
15// code sequences with use of the new memory_region_init_ram function.
16// Similarly for the _rom and _rom_device functions.
17// We don't try to replace sequences with a non-NULL owner, because
18// there are none in the tree that can be automatically converted
19// (and only a handful that can be manually converted).
20@@
21expression MR;
22expression NAME;
23expression SIZE;
24expression ERRP;
25@@
26-memory_region_init_ram_nomigrate(MR, NULL, NAME, SIZE, ERRP);
27+memory_region_init_ram(MR, NULL, NAME, SIZE, ERRP);
28 ...
29-vmstate_register_ram_global(MR);
30@@
31expression MR;
32expression NAME;
33expression SIZE;
34expression ERRP;
35@@
36-memory_region_init_rom_nomigrate(MR, NULL, NAME, SIZE, ERRP);
37+memory_region_init_rom(MR, NULL, NAME, SIZE, ERRP);
38 ...
39-vmstate_register_ram_global(MR);
40@@
41expression MR;
42expression OPS;
43expression OPAQUE;
44expression NAME;
45expression SIZE;
46expression ERRP;
47@@
48-memory_region_init_rom_device_nomigrate(MR, NULL, OPS, OPAQUE, NAME, SIZE, ERRP);
49+memory_region_init_rom_device(MR, NULL, OPS, OPAQUE, NAME, SIZE, ERRP);
50 ...
51-vmstate_register_ram_global(MR);
52