diff mbox series

[v2,11/11] hw/core/resettable: Remove transitional_function machinery

Message ID 20240830145812.1967042-12-peter.maydell@linaro.org (mailing list archive)
State New, archived
Headers show
Series s390: Convert virtio-ccw, cpu to three-phase reset, and followup cleanup | expand

Commit Message

Peter Maydell Aug. 30, 2024, 2:58 p.m. UTC
We used to need the transitional_function machinery to handle bus
classes and device classes which still used their legacy reset
handling.  We have now converted all bus classes to three phase
reset, and simplified the device class legacy reset so it is just an
adapting wrapper function around registration of a hold phase method.
There are therefore no more users of the transitional_function
machinery and we can remove it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/hw/resettable.h | 13 -------------
 hw/core/resettable.c    | 24 +++---------------------
 2 files changed, 3 insertions(+), 34 deletions(-)

Comments

Philippe Mathieu-Daudé Sept. 3, 2024, 2:52 p.m. UTC | #1
On 30/8/24 16:58, Peter Maydell wrote:
> We used to need the transitional_function machinery to handle bus
> classes and device classes which still used their legacy reset
> handling.  We have now converted all bus classes to three phase
> reset, and simplified the device class legacy reset so it is just an
> adapting wrapper function around registration of a hold phase method.
> There are therefore no more users of the transitional_function
> machinery and we can remove it.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   include/hw/resettable.h | 13 -------------
>   hw/core/resettable.c    | 24 +++---------------------
>   2 files changed, 3 insertions(+), 34 deletions(-)


> @@ -171,12 +157,8 @@ static void resettable_phase_hold(Object *obj, void *opaque, ResetType type)
>       /* exec hold phase */
>       if (s->hold_phase_pending) {
>           s->hold_phase_pending = false;
> -        ResettableTrFunction tr_func = resettable_get_tr_func(rc, obj);
>           trace_resettable_phase_hold_exec(obj, obj_typename, !!rc->phases.hold);
> -        if (tr_func) {
> -            trace_resettable_transitional_function(obj, obj_typename);

Squashing:

-- >8 --
diff --git a/hw/core/trace-events b/hw/core/trace-events
index 2cf085ac66..5cf89da51d 100644
--- a/hw/core/trace-events
+++ b/hw/core/trace-events
@@ -22,3 +22,2 @@ resettable_phase_exit_exec(void *obj, const char 
*objtype, int has_method) "obj=
  resettable_phase_exit_end(void *obj, const char *objtype, unsigned 
count) "obj=%p(%s) count=%d"
-resettable_transitional_function(void *obj, const char *objtype) 
"obj=%p(%s)"
---

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Nice cleanup.
diff mbox series

Patch

diff --git a/include/hw/resettable.h b/include/hw/resettable.h
index 83b561fc830..94f6f22e3cf 100644
--- a/include/hw/resettable.h
+++ b/include/hw/resettable.h
@@ -90,14 +90,6 @@  typedef enum ResetType {
  * @get_state: Mandatory method which must return a pointer to a
  * ResettableState.
  *
- * @get_transitional_function: transitional method to handle Resettable objects
- * not yet fully moved to this interface. It will be removed as soon as it is
- * not needed anymore. This method is optional and may return a pointer to a
- * function to be used instead of the phases. If the method exists and returns
- * a non-NULL function pointer then that function is executed as a replacement
- * of the 'hold' phase method taking the object as argument. The two other phase
- * methods are not executed.
- *
  * @child_foreach: Executes a given callback on every Resettable child. Child
  * in this context means a child in the qbus tree, so the children of a qbus
  * are the devices on it, and the children of a device are all the buses it
@@ -109,8 +101,6 @@  typedef void (*ResettableEnterPhase)(Object *obj, ResetType type);
 typedef void (*ResettableHoldPhase)(Object *obj, ResetType type);
 typedef void (*ResettableExitPhase)(Object *obj, ResetType type);
 typedef ResettableState * (*ResettableGetState)(Object *obj);
-typedef void (*ResettableTrFunction)(Object *obj);
-typedef ResettableTrFunction (*ResettableGetTrFunction)(Object *obj);
 typedef void (*ResettableChildCallback)(Object *, void *opaque,
                                         ResetType type);
 typedef void (*ResettableChildForeach)(Object *obj,
@@ -130,9 +120,6 @@  struct ResettableClass {
     /* State access method */
     ResettableGetState get_state;
 
-    /* Transitional method for legacy reset compatibility */
-    ResettableGetTrFunction get_transitional_function;
-
     /* Hierarchy handling method */
     ResettableChildForeach child_foreach;
 };
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
index 6dd3e3dc487..5cdb4a4f8d3 100644
--- a/hw/core/resettable.c
+++ b/hw/core/resettable.c
@@ -93,20 +93,6 @@  static void resettable_child_foreach(ResettableClass *rc, Object *obj,
     }
 }
 
-/**
- * resettable_get_tr_func:
- * helper to fetch transitional reset callback if any.
- */
-static ResettableTrFunction resettable_get_tr_func(ResettableClass *rc,
-                                                   Object *obj)
-{
-    ResettableTrFunction tr_func = NULL;
-    if (rc->get_transitional_function) {
-        tr_func = rc->get_transitional_function(obj);
-    }
-    return tr_func;
-}
-
 static void resettable_phase_enter(Object *obj, void *opaque, ResetType type)
 {
     ResettableClass *rc = RESETTABLE_GET_CLASS(obj);
@@ -146,7 +132,7 @@  static void resettable_phase_enter(Object *obj, void *opaque, ResetType type)
     if (action_needed) {
         trace_resettable_phase_enter_exec(obj, obj_typename, type,
                                           !!rc->phases.enter);
-        if (rc->phases.enter && !resettable_get_tr_func(rc, obj)) {
+        if (rc->phases.enter) {
             rc->phases.enter(obj, type);
         }
         s->hold_phase_pending = true;
@@ -171,12 +157,8 @@  static void resettable_phase_hold(Object *obj, void *opaque, ResetType type)
     /* exec hold phase */
     if (s->hold_phase_pending) {
         s->hold_phase_pending = false;
-        ResettableTrFunction tr_func = resettable_get_tr_func(rc, obj);
         trace_resettable_phase_hold_exec(obj, obj_typename, !!rc->phases.hold);
-        if (tr_func) {
-            trace_resettable_transitional_function(obj, obj_typename);
-            tr_func(obj);
-        } else if (rc->phases.hold) {
+        if (rc->phases.hold) {
             rc->phases.hold(obj, type);
         }
     }
@@ -199,7 +181,7 @@  static void resettable_phase_exit(Object *obj, void *opaque, ResetType type)
     assert(s->count > 0);
     if (--s->count == 0) {
         trace_resettable_phase_exit_exec(obj, obj_typename, !!rc->phases.exit);
-        if (rc->phases.exit && !resettable_get_tr_func(rc, obj)) {
+        if (rc->phases.exit) {
             rc->phases.exit(obj, type);
         }
     }