1// Convert opencoded DeviceClass::reset assignments to calls to
2// device_class_set_legacy_reset()
3//
4// Copyright Linaro Ltd 2024
5// This work is licensed under the terms of the GNU GPLv2 or later.
6//
7// spatch --macro-file scripts/cocci-macro-file.h \
8//        --sp-file scripts/coccinelle/device-reset.cocci \
9//        --keep-comments --smpl-spacing --in-place --include-headers --dir hw
10//
11// For simplicity we assume some things about the code we're modifying
12// that happen to be true for all our targets:
13//  * all cpu_class_set_parent_reset() callsites have a 'DeviceClass *dc' local
14//  * the parent reset field in the target CPU class is 'parent_reset'
15//  * no reset function already has a 'dev' local
16
17@@
18identifier dc, resetfn;
19@@
20  DeviceClass *dc;
21  ...
22- dc->reset = resetfn;
23+ device_class_set_legacy_reset(dc, resetfn);
24@@
25identifier dc, resetfn;
26@@
27  DeviceClass *dc;
28  ...
29- dc->reset = &resetfn;
30+ device_class_set_legacy_reset(dc, resetfn);
31