[Intel-gfx] [PATCH 1/5] drm/atomic: Refactor drm_atomic_state_realloc_connectors()
ville.syrjala at linux.intel.com
ville.syrjala at linux.intel.com
Thu Jun 29 13:49:44 UTC 2017
From: Ville Syrjälä <ville.syrjala at linux.intel.com>
Pull the code to reallocate the state->connectors[] array into a
helper function. We'll have another use for this later.
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
drivers/gpu/drm/drm_atomic.c | 43 +++++++++++++++++++++++++++++--------------
include/drm/drm_atomic.h | 5 +++++
2 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 095e87278a88..a9f02b214fc6 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1043,6 +1043,32 @@ drm_atomic_get_private_obj_state(struct drm_atomic_state *state, void *obj,
}
EXPORT_SYMBOL(drm_atomic_get_private_obj_state);
+int drm_atomic_state_realloc_connectors(struct drm_device *dev,
+ struct drm_atomic_state *state,
+ int index)
+{
+ struct drm_mode_config *config = &dev->mode_config;
+ struct __drm_connnectors_state *c;
+ int alloc = max(index + 1, config->num_connector);
+
+ if (index < state->num_connector)
+ return 0;
+
+ c = krealloc(state->connectors,
+ alloc * sizeof(*state->connectors), GFP_KERNEL);
+ if (!c)
+ return -ENOMEM;
+
+ state->connectors = c;
+ memset(&state->connectors[state->num_connector], 0,
+ sizeof(*state->connectors) * (alloc - state->num_connector));
+
+ state->num_connector = alloc;
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_atomic_state_realloc_connectors);
+
/**
* drm_atomic_get_connector_state - get connector state
* @state: global atomic state object
@@ -1074,20 +1100,9 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
index = drm_connector_index(connector);
- if (index >= state->num_connector) {
- struct __drm_connnectors_state *c;
- int alloc = max(index + 1, config->num_connector);
-
- c = krealloc(state->connectors, alloc * sizeof(*state->connectors), GFP_KERNEL);
- if (!c)
- return ERR_PTR(-ENOMEM);
-
- state->connectors = c;
- memset(&state->connectors[state->num_connector], 0,
- sizeof(*state->connectors) * (alloc - state->num_connector));
-
- state->num_connector = alloc;
- }
+ ret = drm_atomic_state_realloc_connectors(connector->dev, state, index);
+ if (ret)
+ return ERR_PTR(ret);
if (state->connectors[index].state)
return state->connectors[index].state;
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 0196f264a418..5596ad58bcdc 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -324,6 +324,11 @@ drm_atomic_get_private_obj_state(struct drm_atomic_state *state,
void *obj,
const struct drm_private_state_funcs *funcs);
+int __must_check
+drm_atomic_state_realloc_connectors(struct drm_device *dev,
+ struct drm_atomic_state *state,
+ int index);
+
/**
* drm_atomic_get_existing_crtc_state - get crtc state, if it exists
* @state: global atomic state object
--
2.13.0
More information about the Intel-gfx
mailing list