All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Rui Wang <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hpa@zytor.com, rui.y.wang@intel.com, tglx@linutronix.de,
	linux-kernel@vger.kernel.org, mingo@kernel.org
Subject: [tip:x86/apic] x86/ioapic: Simplify ioapic_setup_resources()
Date: Fri, 10 Jun 2016 02:48:51 -0700	[thread overview]
Message-ID: <tip-0286d538082b854b4e1f05b29c23556fa344e145@git.kernel.org> (raw)
In-Reply-To: <1465369193-4816-4-git-send-email-rui.y.wang@intel.com>

Commit-ID:  0286d538082b854b4e1f05b29c23556fa344e145
Gitweb:     http://git.kernel.org/tip/0286d538082b854b4e1f05b29c23556fa344e145
Author:     Rui Wang <rui.y.wang@intel.com>
AuthorDate: Wed, 8 Jun 2016 14:59:53 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 10 Jun 2016 11:43:52 +0200

x86/ioapic: Simplify ioapic_setup_resources()

Optimize the function by removing the variable 'num'.

Signed-off-by: Rui Wang <rui.y.wang@intel.com>
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: Thomas Gleixner <tglx@linutronix.de>

---
 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;

  reply	other threads:[~2016-06-10  9:49 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-08  6:59 [PATCH V2 0/3] ioapic hot-removal bugs Rui Wang
2016-06-08  6:59 ` [PATCH V2 1/3] x86/ioapic: Support hot-removal of IOAPICs present during boot Rui Wang
2016-06-08  8:05   ` kbuild test robot
2016-06-08  8:05     ` kbuild test robot
2016-06-08  9:32   ` [PATCH V3 " Rui Wang
2016-06-10 12:57     ` Thomas Gleixner
2016-06-10 13:56       ` Rafael J. Wysocki
2016-06-10 16:43     ` Bjorn Helgaas
2016-06-12  6:06       ` Rui Wang
2016-06-16 17:09         ` Bjorn Helgaas
2016-06-22  7:13           ` Rui Wang
2016-06-22 14:53             ` Bjorn Helgaas
2016-06-24 15:18               ` Rui Wang
2016-06-22  7:40           ` [PATCH V4 " Rui Wang
2016-06-22 15:14             ` Bjorn Helgaas
2016-06-23  5:11               ` Unknown, 
2016-06-23  5:11                 ` 
2016-06-23  5:11                 ` 
2016-06-23 17:34                 ` Bjorn Helgaas
2016-06-24 15:30                   ` Rui Wang
2016-06-26  3:44                   ` [PATCH V5 " Rui Wang
2016-08-08 20:22                     ` Bjorn Helgaas
2016-08-09  3:23                       ` Rui Wang
2016-08-09 12:09                         ` Rafael J. Wysocki
2016-06-08  6:59 ` [PATCH V2 2/3] x86/ioapic: Fix wrong pointers in ioapic_setup_resources() Rui Wang
2016-06-10  9:45   ` [tip:x86/urgent] " tip-bot for Rui Wang
2016-06-10 12:01   ` [tip:x86/apic] x86/ioapic: Fix incorrect " tip-bot for Rui Wang
2016-06-10 12:48   ` [tip:x86/urgent] " tip-bot for Rui Wang
2016-06-08  6:59 ` [PATCH V2 3/3] x86/ioapic: Simplify ioapic_setup_resources() Rui Wang
2016-06-10  9:48   ` tip-bot for Rui Wang [this message]
2016-06-10 12:54   ` [tip:x86/apic] " tip-bot for Rui Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-0286d538082b854b4e1f05b29c23556fa344e145@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=rui.y.wang@intel.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.