Since we're going to move the drm_private_obj state allocation to a
callback, we need to be able to deal with its possible failure.

Make drm_private_obj_init return an error code on failure.

Suggested-by: Ville Syrjälä <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
---
 drivers/gpu/drm/drm_atomic.c | 14 +++++++++-----
 include/drm/drm_atomic.h     |  8 ++++----
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 
52738b80ddbeb124896f6124df5628e2ac27faa4..4191a8333fc4ebdfc10f664c837a3f1693eff022
 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -925,16 +925,18 @@ static void drm_atomic_plane_print_state(struct 
drm_printer *p,
  * @funcs: pointer to the struct of function pointers that identify the object
  * type
  *
  * Initialize the private object, which can be embedded into any
  * driver private object that needs its own atomic state.
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
  */
-void
-drm_atomic_private_obj_init(struct drm_device *dev,
-                           struct drm_private_obj *obj,
-                           struct drm_private_state *state,
-                           const struct drm_private_state_funcs *funcs)
+int drm_atomic_private_obj_init(struct drm_device *dev,
+                               struct drm_private_obj *obj,
+                               struct drm_private_state *state,
+                               const struct drm_private_state_funcs *funcs)
 {
        memset(obj, 0, sizeof(*obj));
 
        drm_modeset_lock_init(&obj->lock);
 
@@ -942,10 +944,12 @@ drm_atomic_private_obj_init(struct drm_device *dev,
        obj->state = state;
        obj->funcs = funcs;
        list_add_tail(&obj->head, &dev->mode_config.privobj_list);
 
        state->obj = obj;
+
+       return 0;
 }
 EXPORT_SYMBOL(drm_atomic_private_obj_init);
 
 /**
  * drm_atomic_private_obj_fini - finalize private object
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 
178f8f62c80fc58fe42e8564a716da1a99ddb7da..712f5fb977bff8a15592a3949444d9ac306e6c54
 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -721,14 +721,14 @@ drm_atomic_get_new_colorop_state(struct drm_atomic_state 
*state,
 
 struct drm_connector_state * __must_check
 drm_atomic_get_connector_state(struct drm_atomic_state *state,
                               struct drm_connector *connector);
 
-void drm_atomic_private_obj_init(struct drm_device *dev,
-                                struct drm_private_obj *obj,
-                                struct drm_private_state *state,
-                                const struct drm_private_state_funcs *funcs);
+int drm_atomic_private_obj_init(struct drm_device *dev,
+                               struct drm_private_obj *obj,
+                               struct drm_private_state *state,
+                               const struct drm_private_state_funcs *funcs);
 void drm_atomic_private_obj_fini(struct drm_private_obj *obj);
 
 struct drm_private_state * __must_check
 drm_atomic_get_private_obj_state(struct drm_atomic_state *state,
                                 struct drm_private_obj *obj);

-- 
2.52.0

Reply via email to