The tegra 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 atomic_create_state implementation, let's
migrate this instance to the new pattern.

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

---

Cc: Thierry Reding <[email protected]>
Cc: Mikko Perttunen <[email protected]>
Cc: Jonathan Hunter <[email protected]>
Cc: [email protected]
---
 drivers/gpu/drm/tegra/hub.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/tegra/hub.c b/drivers/gpu/drm/tegra/hub.c
index 
8f779f23dc0904d38b14d3f3a928a07fc9e601ad..52058f7dd92fadd45551447106ebe265975e6d8f
 100644
--- a/drivers/gpu/drm/tegra/hub.c
+++ b/drivers/gpu/drm/tegra/hub.c
@@ -822,11 +822,26 @@ static void tegra_display_hub_destroy_state(struct 
drm_private_obj *obj,
                to_tegra_display_hub_state(state);
 
        kfree(hub_state);
 }
 
+static struct drm_private_state *
+tegra_display_hub_create_state(struct drm_private_obj *obj)
+{
+       struct tegra_display_hub_state *hub_state;
+
+       hub_state = kzalloc(sizeof(*hub_state), GFP_KERNEL);
+       if (!hub_state)
+               return ERR_PTR(-ENOMEM);
+
+       __drm_atomic_helper_private_obj_create_state(obj, &hub_state->base);
+
+       return &hub_state->base;
+}
+
 static const struct drm_private_state_funcs tegra_display_hub_state_funcs = {
+       .atomic_create_state = tegra_display_hub_create_state,
        .atomic_duplicate_state = tegra_display_hub_duplicate_state,
        .atomic_destroy_state = tegra_display_hub_destroy_state,
 };
 
 static struct tegra_display_hub_state *
@@ -938,17 +953,12 @@ void tegra_display_hub_atomic_commit(struct drm_device 
*drm,
 static int tegra_display_hub_init(struct host1x_client *client)
 {
        struct tegra_display_hub *hub = to_tegra_display_hub(client);
        struct drm_device *drm = dev_get_drvdata(client->host);
        struct tegra_drm *tegra = drm->dev_private;
-       struct tegra_display_hub_state *state;
 
-       state = kzalloc(sizeof(*state), GFP_KERNEL);
-       if (!state)
-               return -ENOMEM;
-
-       drm_atomic_private_obj_init(drm, &hub->base, &state->base,
+       drm_atomic_private_obj_init(drm, &hub->base, NULL,
                                    &tegra_display_hub_state_funcs);
 
        tegra->hub = hub;
 
        return 0;

-- 
2.51.0

Reply via email to