mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@openvz.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org,
	Cyrill Gorcunov <gorcunov@openvz.org>,
	Yinghai Lu <yinghai@kernel.org>
Subject: [rfc -tip 4/4] x86,ioapic: ioapic_setup_resources - get rid of needless check and simplify
Date: Mon, 24 Aug 2009 21:53:39 +0400	[thread overview]
Message-ID: <20090824175551.493629148@openvz.org> (raw)
In-Reply-To: <20090824175335.186713800@openvz.org>

[-- Attachment #1: x86-io-apic-bootmem --]
[-- Type: text/plain, Size: 2385 bytes --]

alloc_bootmem do panic on allication failure.
There is no need to check the result.

Also there is a way to unbind global variable from its
body and use it as a parameter which allow us to simplify
ioapic_init_mappings as well -- "for" cycle already uses
nr_ioapics as a conditional variable and there is no need
to check if ioapic_setup_resources was returning NULL again.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Yinghai Lu <yinghai@kernel.org>
---
 arch/x86/kernel/apic/io_apic.c |   26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

Index: linux-2.6.git/arch/x86/kernel/apic/io_apic.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/apic/io_apic.c
+++ linux-2.6.git/arch/x86/kernel/apic/io_apic.c
@@ -4056,7 +4056,7 @@ void __init setup_ioapic_dest(void)
 
 static struct resource *ioapic_resources;
 
-static struct resource * __init ioapic_setup_resources(void)
+static struct resource * __init ioapic_setup_resources(int nr_ioapics)
 {
 	unsigned long n;
 	struct resource *res;
@@ -4072,15 +4072,13 @@ static struct resource * __init ioapic_s
 	mem = alloc_bootmem(n);
 	res = (void *)mem;
 
-	if (mem != NULL) {
-		mem += sizeof(struct resource) * nr_ioapics;
+	mem += sizeof(struct resource) * nr_ioapics;
 
-		for (i = 0; i < nr_ioapics; i++) {
-			res[i].name = mem;
-			res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-			sprintf(mem,  "IOAPIC %u", i);
-			mem += IOAPIC_RESOURCE_NAME_SIZE;
-		}
+	for (i = 0; i < nr_ioapics; i++) {
+		res[i].name = mem;
+		res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+		sprintf(mem,  "IOAPIC %u", i);
+		mem += IOAPIC_RESOURCE_NAME_SIZE;
 	}
 
 	ioapic_resources = res;
@@ -4094,7 +4092,7 @@ void __init ioapic_init_mappings(void)
 	struct resource *ioapic_res;
 	int i;
 
-	ioapic_res = ioapic_setup_resources();
+	ioapic_res = ioapic_setup_resources(nr_ioapics);
 	for (i = 0; i < nr_ioapics; i++) {
 		if (smp_found_config) {
 			ioapic_phys = mp_ioapics[i].apicaddr;
@@ -4123,11 +4121,9 @@ fake_ioapic_page:
 			    __fix_to_virt(idx), ioapic_phys);
 		idx++;
 
-		if (ioapic_res != NULL) {
-			ioapic_res->start = ioapic_phys;
-			ioapic_res->end = ioapic_phys + (4 * 1024) - 1;
-			ioapic_res++;
-		}
+		ioapic_res->start = ioapic_phys;
+		ioapic_res->end = ioapic_phys + (4 * 1024) - 1;
+		ioapic_res++;
 	}
 }
 


  parent reply	other threads:[~2009-08-24 17:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-24 17:53 [rfc -tip 0/4] x86 apic,ioapic fixes Cyrill Gorcunov
2009-08-24 17:53 ` [rfc -tip 1/4] x86,ioapic: define IO_APIC_DEFAULT_PHYS_BASE constant Cyrill Gorcunov
2009-08-26  6:22   ` [tip:x86/apic] x86, ioapic: Define " tip-bot for Cyrill Gorcunov
2009-08-24 17:53 ` [rfc -tip 2/4] x86,e820: __e820_add_region -- guard against array overflowed Cyrill Gorcunov
2009-08-26  6:22   ` [tip:x86/setup] x86, e820: Guard against array overflowed in __e820_add_region() tip-bot for Cyrill Gorcunov
2009-08-24 17:53 ` [rfc -tip 3/4] x86,apic: fix missed handling of discrete apics Cyrill Gorcunov
2009-08-26  6:12   ` Ingo Molnar
2009-08-26  6:22     ` Cyrill Gorcunov
2009-08-26 16:49     ` Cyrill Gorcunov
2009-08-24 17:53 ` Cyrill Gorcunov [this message]
2009-08-26  6:22   ` [tip:x86/apic] x86, ioapic: Get rid of needless check and simplify ioapic_setup_resources() tip-bot for Cyrill Gorcunov

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=20090824175551.493629148@openvz.org \
    --to=gorcunov@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    --cc=yinghai@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®