From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753453AbcFJMzG (ORCPT ); Fri, 10 Jun 2016 08:55:06 -0400 Received: from terminus.zytor.com ([198.137.202.10]:52318 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753086AbcFJMzE (ORCPT ); Fri, 10 Jun 2016 08:55:04 -0400 Date: Fri, 10 Jun 2016 05:54:52 -0700 From: tip-bot for Rui Wang Message-ID: Cc: tglx@linutronix.de, hpa@zytor.com, linux-kernel@vger.kernel.org, rui.y.wang@intel.com, mingo@kernel.org Reply-To: mingo@kernel.org, rui.y.wang@intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de In-Reply-To: <1465369193-4816-4-git-send-email-rui.y.wang@intel.com> References: <1465369193-4816-4-git-send-email-rui.y.wang@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/apic] x86/ioapic: Simplify ioapic_setup_resources() Git-Commit-ID: 4855531eb8582a98cb905d2baf86021254d7a675 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 4855531eb8582a98cb905d2baf86021254d7a675 Gitweb: http://git.kernel.org/tip/4855531eb8582a98cb905d2baf86021254d7a675 Author: Rui Wang AuthorDate: Wed, 8 Jun 2016 14:59:53 +0800 Committer: Ingo Molnar CommitDate: Fri, 10 Jun 2016 14:48:18 +0200 x86/ioapic: Simplify ioapic_setup_resources() Optimize the function by removing the variable 'num'. Signed-off-by: Rui Wang Signed-off-by: Thomas Gleixner Cc: tony.luck@intel.com Cc: linux-pci@vger.kernel.org Cc: rjw@rjwysocki.net Cc: linux-acpi@vger.kernel.org Cc: bhelgaas@google.com Link: http://lkml.kernel.org/r/1465369193-4816-4-git-send-email-rui.y.wang@intel.com Signed-off-by: Ingo Molnar --- arch/x86/kernel/apic/io_apic.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 446702e..e587295 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -2567,29 +2567,25 @@ static struct resource * __init ioapic_setup_resources(void) unsigned long n; struct resource *res; char *mem; - int i, num = 0; + int i; - for_each_ioapic(i) - num++; - if (num == 0) + if (nr_ioapics == 0) return NULL; n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource); - n *= num; + n *= nr_ioapics; mem = alloc_bootmem(n); res = (void *)mem; - mem += sizeof(struct resource) * num; + mem += sizeof(struct resource) * nr_ioapics; - num = 0; for_each_ioapic(i) { - res[num].name = mem; - res[num].flags = IORESOURCE_MEM | IORESOURCE_BUSY; + res[i].name = mem; + res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY; snprintf(mem, IOAPIC_RESOURCE_NAME_SIZE, "IOAPIC %u", i); mem += IOAPIC_RESOURCE_NAME_SIZE; - ioapics[i].iomem_res = &res[num]; - num++; + ioapics[i].iomem_res = &res[i]; } ioapic_resources = res;