Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4855531e authored by Rui Wang's avatar Rui Wang Committed by Ingo Molnar
Browse files

x86/ioapic: Simplify ioapic_setup_resources()



Optimize the function by removing the variable 'num'.

Signed-off-by: default avatarRui Wang <rui.y.wang@intel.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
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: default avatarIngo Molnar <mingo@kernel.org>
parent 9d98bcec
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -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;