On Thu, Jun 29, 2017 at 04:49:44PM +0300, ville.syrjala@xxxxxxxxxxxxxxx wrote: > From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> > > 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@xxxxxxxxxxxxxxx> > --- > 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) Needs some pretty kerneldoc, best with some explanation why/when drivers might want to use this (i.e. when they're constructing their own state for special reasons like hw state read-out or recovery after a hw reset or whatever). Commit message should explain that too, but better to stuff it into the kerneldoc. With that addressed: Reviewed-by: Daniel Vetter <daniel.vetter@xxxxxxxx> > +{ > + 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 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx