hw: Define new device_class_set_legacy_reset()

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
This commit is contained in:
Peter Maydell 2024-09-13 15:31:44 +01:00
parent 349ecf61e8
commit 134e0944f4
3 changed files with 48 additions and 0 deletions

View file

@ -953,6 +953,19 @@ void device_class_set_parent_realize(DeviceClass *dc,
DeviceRealize dev_realize,
DeviceRealize *parent_realize);
/**
* device_class_set_legacy_reset(): set the DeviceClass::reset method
* @dc: The device class
* @dev_reset: the reset function
*
* This function sets the DeviceClass::reset method. This is widely
* used in existing code, but new code should prefer to use the
* Resettable API as documented in docs/devel/reset.rst.
* In addition, devices which need to chain to their parent class's
* reset methods or which need to be subclassed must use Resettable.
*/
void device_class_set_legacy_reset(DeviceClass *dc,
DeviceReset dev_reset);
/**
* device_class_set_parent_unrealize() - set up for chaining unrealize fns