Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754547AbbGNW7t (ORCPT ); Tue, 14 Jul 2015 18:59:49 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:44866 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753052AbbGNWrw (ORCPT ); Tue, 14 Jul 2015 18:47:52 -0400 From: Yinghai Lu To: Bjorn Helgaas , David Miller , Benjamin Herrenschmidt , Wei Yang , TJ , Yijing Wang Cc: Andrew Morton , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH v2 08/49] PCI: Remove duplicated code for resource sorting Date: Tue, 14 Jul 2015 15:46:39 -0700 Message-Id: <1436914040-13206-9-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1436914040-13206-1-git-send-email-yinghai@kernel.org> References: <1436914040-13206-1-git-send-email-yinghai@kernel.org> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1915 Lines: 71 Now __sort_resources, and pdev_sort_resources all have sorting code. As we are going to call __sort_resources several places later, so choose to keep __sort_resources, and remove related code in pdev_sort_resources. Signed-off-by: Yinghai Lu --- drivers/pci/setup-bus.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 6f2d508..6642a60 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -215,9 +215,8 @@ static void pdev_sort_resources(struct pci_dev *dev, for (i = 0; i < PCI_NUM_RESOURCES; i++) { struct resource *r; - struct pci_dev_resource *dev_res, *tmp; + struct pci_dev_resource *tmp; resource_size_t r_align; - struct list_head *n; r = &dev->resource[i]; @@ -240,22 +239,7 @@ static void pdev_sort_resources(struct pci_dev *dev, tmp->res = r; tmp->dev = dev; - /* fallback is smallest one or list is empty*/ - n = head; - list_for_each_entry(dev_res, head, list) { - resource_size_t align; - - align = __pci_resource_alignment(dev_res->dev, - dev_res->res, - realloc_head); - - if (r_align > align) { - n = &dev_res->list; - break; - } - } - /* Insert it just before n*/ - list_add_tail(&tmp->list, n); + list_add_tail(&tmp->list, head); } } @@ -558,9 +542,9 @@ static void __assign_resources_sorted(struct list_head *head, } free_list(&save_head); +requested_and_reassign: __sort_resources(head); -requested_and_reassign: /* Satisfy the must-have resource requests */ assign_requested_resources_sorted(head, fail_head); -- 1.8.4.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/