include/ui/console.h: Delete is_surface_bgr()
[qemu/ar7.git] / scripts / coccinelle / cpu-reset.cocci
blob396a724e514a85a7f692c2ef651e28ed8c2aad8e
1 // Convert targets using the old CPUState reset to DeviceState reset
2 //
3 // Copyright Linaro Ltd 2020
4 // This work is licensed under the terms of the GNU GPLv2 or later.
5 //
6 // spatch --macro-file scripts/cocci-macro-file.h \
7 //        --sp-file scripts/coccinelle/cpu-reset.cocci \
8 //        --keep-comments --smpl-spacing --in-place --include-headers --dir target
9 //
10 // For simplicity we assume some things about the code we're modifying
11 // that happen to be true for all our targets:
12 //  * all cpu_class_set_parent_reset() callsites have a 'DeviceClass *dc' local
13 //  * the parent reset field in the target CPU class is 'parent_reset'
14 //  * no reset function already has a 'dev' local
17 identifier cpu, x;
18 typedef CPUState;
20 struct x {
21 ...
22 - void (*parent_reset)(CPUState *cpu);
23 + DeviceReset parent_reset;
24 ...
26 @ rule1 @
27 identifier resetfn;
28 expression resetfield;
29 identifier cc;
31 - cpu_class_set_parent_reset(cc, resetfn, resetfield)
32 + device_class_set_parent_reset(dc, resetfn, resetfield)
34 identifier rule1.resetfn;
35 identifier cpu, cc;
36 typedef CPUState, DeviceState;
38 -resetfn(CPUState *cpu)
40 +resetfn(DeviceState *dev)
42 +    CPUState *cpu = CPU(dev);
43 <...
44 -    cc->parent_reset(cpu);
45 +    cc->parent_reset(dev);
46 ...>