Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756855AbcDHBRi (ORCPT ); Thu, 7 Apr 2016 21:17:38 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:51784 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752502AbcDHBRg (ORCPT ); Thu, 7 Apr 2016 21:17:36 -0400 From: Yinghai Lu To: Bjorn Helgaas , David Miller , Benjamin Herrenschmidt , Linus Torvalds Cc: Wei Yang , TJ , Yijing Wang , Khalid Aziz , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH v11 50/60] PCI: Unify calculate_size() for io port and MMIO Date: Thu, 7 Apr 2016 17:16:03 -0700 Message-Id: <1460074573-7481-51-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1460074573-7481-1-git-send-email-yinghai@kernel.org> References: <1460074573-7481-1-git-send-email-yinghai@kernel.org> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2489 Lines: 74 Now calculate_memsize() and calculate_iosize() is the same. Change them to calculate_size(). Signed-off-by: Yinghai Lu --- drivers/pci/setup-bus.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 930dcbd..b071035 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1103,22 +1103,7 @@ static struct resource *find_free_bus_resource(struct pci_bus *bus, return NULL; } -static resource_size_t calculate_iosize(resource_size_t size, - resource_size_t min_size, - resource_size_t old_size, - resource_size_t align) -{ - if (size < min_size) - size = min_size; - if (old_size == 1) - old_size = 0; - size = ALIGN(size, align); - if (size < old_size) - size = old_size; - return size; -} - -static resource_size_t calculate_memsize(resource_size_t size, +static resource_size_t calculate_size(resource_size_t size, resource_size_t min_size, resource_size_t old_size, resource_size_t align) @@ -1244,14 +1229,14 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, size = size_aligned_for_isa(size); size += size1; - size0 = calculate_iosize(size, min_size, + size0 = calculate_size(size, min_size, resource_size(b_res), min_align); sum_add_size = size_aligned_for_isa(sum_add_size); sum_add_size += sum_add_size1; if (sum_add_size < min_sum_size) sum_add_size = min_sum_size; size1 = !realloc_head ? size0 : - calculate_iosize(sum_add_size, min_size, + calculate_size(sum_add_size, min_size, resource_size(b_res), min_align); if (!size0 && !size1) { if (b_res->start || b_res->end) @@ -1580,7 +1565,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, if (size || min_size) { min_align = calculate_mem_align(&align_test_list, max_align, size, window_align); - size0 = calculate_memsize(size, min_size, + size0 = calculate_size(size, min_size, resource_size(b_res), min_align); } free_align_test_list(&align_test_list); @@ -1605,7 +1590,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, min_add_align = calculate_mem_align(&align_test_add_list, max_add_align, sum_add_size, window_align); - size1 = calculate_memsize(sum_add_size, min_size, + size1 = calculate_size(sum_add_size, min_size, resource_size(b_res), min_add_align); } free_align_test_list(&align_test_add_list); -- 1.8.4.5