The omapdrm driver relies on a drm_private_obj, that is initialized by
allocating and initializing a state, and then passing it to
drm_private_obj_init.

Since we're gradually moving away from that pattern to the more
established one relying on a reset implementation, let's migrate this
instance to the new pattern.

Signed-off-by: Maxime Ripard <[email protected]>

---

Cc: Tomi Valkeinen <[email protected]>
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 
794267f0f007850e43949f93be5c98d0e32a84ea..4c556da5a5cae3685d929679f43260c51459e8a9
 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -272,25 +272,37 @@ static void omap_global_destroy_state(struct 
drm_private_obj *obj,
        struct omap_global_state *omap_state = to_omap_global_state(state);
 
        kfree(omap_state);
 }
 
+static void omap_global_reset(struct drm_private_obj *obj)
+{
+       struct omap_global_state *state;
+
+       if (obj->state) {
+               omap_global_destroy_state(obj, obj->state);
+               obj->state = NULL;
+       }
+
+       state = kzalloc(sizeof(*state), GFP_KERNEL);
+       if (!state)
+               return;
+
+       __drm_atomic_helper_private_obj_reset(obj, &state->base);
+}
+
 static const struct drm_private_state_funcs omap_global_state_funcs = {
        .atomic_duplicate_state = omap_global_duplicate_state,
        .atomic_destroy_state = omap_global_destroy_state,
+       .reset = omap_global_reset,
 };
 
 static int omap_global_obj_init(struct drm_device *dev)
 {
        struct omap_drm_private *priv = dev->dev_private;
-       struct omap_global_state *state;
 
-       state = kzalloc(sizeof(*state), GFP_KERNEL);
-       if (!state)
-               return -ENOMEM;
-
-       drm_atomic_private_obj_init(dev, &priv->glob_obj, &state->base,
+       drm_atomic_private_obj_init(dev, &priv->glob_obj, NULL,
                                    &omap_global_state_funcs);
        return 0;
 }
 
 static void omap_global_obj_fini(struct omap_drm_private *priv)

-- 
2.51.0

Reply via email to