From patchwork Thu Feb 12 23:41:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paauwe, Bob J" X-Patchwork-Id: 5822601 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7BAD89FB2A for ; Thu, 12 Feb 2015 23:41:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE1E82021B for ; Thu, 12 Feb 2015 23:41:15 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id ABAF82026C for ; Thu, 12 Feb 2015 23:41:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 48AC86E78D; Thu, 12 Feb 2015 15:41:12 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id DFD986E781 for ; Thu, 12 Feb 2015 15:41:05 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 12 Feb 2015 15:41:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,567,1418112000"; d="scan'208";a="665697133" Received: from bpaauwe-desk.fm.intel.com ([10.1.134.218]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2015 15:41:03 -0800 From: Bob Paauwe To: intel-gfx Date: Thu, 12 Feb 2015 15:41:32 -0800 Message-Id: <1423784498-11272-7-git-send-email-bob.j.paauwe@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1423784498-11272-1-git-send-email-bob.j.paauwe@intel.com> References: <1423784498-11272-1-git-send-email-bob.j.paauwe@intel.com> Subject: [Intel-gfx] [RFC 06/12] drm/i915/config: Split out allocation of list nodes. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Bob Paauwe --- 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; } } }