1 // Convert targets using the old CPUState reset to DeviceState reset
3 // Copyright Linaro Ltd 2020
4 // This work is licensed under the terms of the GNU GPLv2 or later.
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
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
22 - void (*parent_reset)(CPUState *cpu);
23 + DeviceReset parent_reset;
28 expression resetfield;
31 - cpu_class_set_parent_reset(cc, resetfn, resetfield)
32 + device_class_set_parent_reset(dc, resetfn, resetfield)
34 identifier rule1.resetfn;
36 typedef CPUState, DeviceState;
38 -resetfn(CPUState *cpu)
40 +resetfn(DeviceState *dev)
42 + CPUState *cpu = CPU(dev);
44 - cc->parent_reset(cpu);
45 + cc->parent_reset(dev);