134e0944f4
Define a device_class_set_legacy_reset() function which sets the DeviceClass::reset field. This serves two purposes: * it makes it clearer to the person writing code that DeviceClass::reset is now legacy and they should look for the new alternative (which is Resettable) * it makes it easier to rename the reset field (which in turn makes it easier to find places that call it) The Coccinelle script can be used to automatically convert code that was doing an open-coded assignment to DeviceClass::reset to call device_class_set_legacy_reset() instead. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20240830145812.1967042-7-peter.maydell@linaro.org
31 lines
965 B
Plaintext
31 lines
965 B
Plaintext
// Convert opencoded DeviceClass::reset assignments to calls to
|
|
// device_class_set_legacy_reset()
|
|
//
|
|
// Copyright Linaro Ltd 2024
|
|
// This work is licensed under the terms of the GNU GPLv2 or later.
|
|
//
|
|
// spatch --macro-file scripts/cocci-macro-file.h \
|
|
// --sp-file scripts/coccinelle/device-reset.cocci \
|
|
// --keep-comments --smpl-spacing --in-place --include-headers --dir hw
|
|
//
|
|
// For simplicity we assume some things about the code we're modifying
|
|
// that happen to be true for all our targets:
|
|
// * all cpu_class_set_parent_reset() callsites have a 'DeviceClass *dc' local
|
|
// * the parent reset field in the target CPU class is 'parent_reset'
|
|
// * no reset function already has a 'dev' local
|
|
|
|
@@
|
|
identifier dc, resetfn;
|
|
@@
|
|
DeviceClass *dc;
|
|
...
|
|
- dc->reset = resetfn;
|
|
+ device_class_set_legacy_reset(dc, resetfn);
|
|
@@
|
|
identifier dc, resetfn;
|
|
@@
|
|
DeviceClass *dc;
|
|
...
|
|
- dc->reset = &resetfn;
|
|
+ device_class_set_legacy_reset(dc, resetfn);
|