The drm_atomic_get_private_obj_state() function tries to find if a
private_obj had already been allocated and was part of the given
drm_atomic_state. If one is found, it returns the existing state
pointer.

At the point in time where drm_atomic_get_private_obj_state() can be
called (ie, during atomic_check), the existing state is the new state
and we can thus replace the hand-crafted logic by a call to
drm_atomic_get_new_private_obj_state().

Signed-off-by: Maxime Ripard <mrip...@kernel.org>
---
 drivers/gpu/drm/drm_atomic.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 
6d92f13d489f299aea5cd14f900ae766588462da..b7bef44e2d42eb56446a5a05f851c7503daeaa1f
 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -829,18 +829,18 @@ EXPORT_SYMBOL(drm_atomic_private_obj_fini);
  */
 struct drm_private_state *
 drm_atomic_get_private_obj_state(struct drm_atomic_state *state,
                                 struct drm_private_obj *obj)
 {
-       int index, num_objs, i, ret;
+       int index, num_objs, ret;
        size_t size;
        struct __drm_private_objs_state *arr;
        struct drm_private_state *obj_state;
 
-       for (i = 0; i < state->num_private_objs; i++)
-               if (obj == state->private_objs[i].ptr)
-                       return state->private_objs[i].state;
+       obj_state = drm_atomic_get_new_private_obj_state(state, obj);
+       if (obj_state)
+               return obj_state;
 
        ret = drm_modeset_lock(&obj->lock, state->acquire_ctx);
        if (ret)
                return ERR_PTR(ret);
 

-- 
2.50.1

Reply via email to