On Fri, 13 Feb 2015, Bob Paauwe <bob.j.paauwe@xxxxxxxxx> wrote: > We'll reduce some duplicate code if we move the list node allocation > to its own function when we start processing future config items like > workaround or vbt information. Should probably just be part of patch 1. BR, Jani. > > Signed-off-by: Bob Paauwe <bob.j.paauwe@xxxxxxxxx> > --- > drivers/gpu/drm/i915/intel_config.c | 49 ++++++++++++++++++++++--------------- > 1 file changed, 29 insertions(+), 20 deletions(-) > > diff --git a/drivers/gpu/drm/i915/intel_config.c b/drivers/gpu/drm/i915/intel_config.c > index cf7da93..fb495ed 100644 > --- a/drivers/gpu/drm/i915/intel_config.c > +++ b/drivers/gpu/drm/i915/intel_config.c > @@ -161,6 +161,21 @@ static bool node_property(struct intel_config_node *n, > } > > > +static bool alloc_new_node(struct acpi_device *cl, struct list_head *list) > +{ > + struct intel_config_node *new_node; > + > + new_node = kzalloc(sizeof(*new_node), GFP_KERNEL); > + if (!new_node) > + return false; > + > + new_node->adev = cl; > + INIT_LIST_HEAD(&new_node->node); > + list_add_tail(&new_node->node, list); > + > + return true; > +} > + > /** > * intel_config_init - > * > @@ -232,26 +247,20 @@ void intel_config_init(struct drm_device *dev) > > cname = acpi_device_bid(component); > > - list_for_each_entry(cl, &component->children, node) { > - new_node = kzalloc(sizeof(*new_node), GFP_KERNEL); > - if (!new_node) > - goto bail; > - new_node->adev = cl; > - INIT_LIST_HEAD(&new_node->node); > - > - /* Add to the appropriate list */ > - if (strcmp(cname, i915_COMPONENT_CRTC) == 0) { > - list_add_tail(&new_node->node, > - &info->crtc_list); > - } else if (strcmp(cname, i915_COMPONENT_CONNECTOR) == 0) { > - list_add_tail(&new_node->node, > - &info->connector_list); > - } else if (strcmp(cname, i915_COMPONENT_PLANE) == 0) { > - list_add_tail(&new_node->node, > - &info->plane_list); > - } else { > - /* unknown component, ignore it */ > - kfree(new_node); > + if (strcmp(cname, i915_COMPONENT_CRTC) == 0) { > + list_for_each_entry(cl, &component->children, node) { > + if (!alloc_new_node(cl, &info->crtc_list)) > + goto bail; > + } > + } else if (strcmp(cname, i915_COMPONENT_CONNECTOR) == 0) { > + list_for_each_entry(cl, &component->children, node) { > + if (!alloc_new_node(cl, &info->crtc_list)) > + goto bail; > + } > + } else if (strcmp(cname, i915_COMPONENT_PLANE) == 0) { > + list_for_each_entry(cl, &component->children, node) { > + if (!alloc_new_node(cl, &info->crtc_list)) > + goto bail; > } > } > } > -- > 2.1.0 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@xxxxxxxxxxxxxxxxxxxxx > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx