Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1416953

[PATCH V2 3/3] x86/ioapic: Simplify ioapic_setup_resources()

From Rui Wang <rui.y.wang@intel.com>
Newsgroups linux.kernel
Subject [PATCH V2 3/3] x86/ioapic: Simplify ioapic_setup_resources()
Date 2016-06-08 09:20 +0200
Message-ID <rHFWp-5tG-15@gated-at.bofh.it> (permalink)
References <rHFWp-5tG-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Optimize the function by removing the variable 'num'.

Signed-off-by: Rui Wang <rui.y.wang@intel.com>
---
 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;
-- 
1.8.3.1

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH V2 3/3] x86/ioapic: Simplify ioapic_setup_resources() Rui Wang <rui.y.wang@intel.com> - 2016-06-08 09:20 +0200
  [tip:x86/apic] x86/ioapic: Simplify ioapic_setup_resources() tip-bot for Rui Wang <tipbot@zytor.com> - 2016-06-10 11:50 +0200
  [tip:x86/apic] x86/ioapic: Simplify ioapic_setup_resources() tip-bot for Rui Wang <tipbot@zytor.com> - 2016-06-10 15:00 +0200

csiph-web