summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorManeesh Soni <maneesh@in.ibm.com>2005-06-25 14:58:28 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-25 16:24:55 -0700
commit72414d3f1d22fc3e311b162fca95c430048d38ce (patch)
tree46850947c1602357dd3c51d8d6ebaa5805507f9f /arch
parent4f339ecb30c759f94a29992d4635d9194132b6cf (diff)
downloadop-kernel-dev-72414d3f1d22fc3e311b162fca95c430048d38ce.zip
op-kernel-dev-72414d3f1d22fc3e311b162fca95c430048d38ce.tar.gz
[PATCH] kexec code cleanup
o Following patch provides purely cosmetic changes and corrects CodingStyle guide lines related certain issues like below in kexec related files o braces for one line "if" statements, "for" loops, o more than 80 column wide lines, o No space after "while", "for" and "switch" key words o Changes: o take-2: Removed the extra tab before "case" key words. o take-3: Put operator at the end of line and space before "*/" Signed-off-by: Maneesh Soni <maneesh@in.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/i386/kernel/crash.c23
-rw-r--r--arch/i386/kernel/machine_kexec.c16
-rw-r--r--arch/ppc/kernel/machine_kexec.c30
-rw-r--r--arch/ppc64/kernel/machine_kexec.c9
-rw-r--r--arch/s390/kernel/machine_kexec.c4
-rw-r--r--arch/x86_64/kernel/machine_kexec.c49
6 files changed, 71 insertions, 60 deletions
diff --git a/arch/i386/kernel/crash.c b/arch/i386/kernel/crash.c
index 8bdb4b6..e5fab12 100644
--- a/arch/i386/kernel/crash.c
+++ b/arch/i386/kernel/crash.c
@@ -31,10 +31,11 @@ note_buf_t crash_notes[NR_CPUS];
/* This keeps a track of which one is crashing cpu. */
static int crashing_cpu;
-static u32 *append_elf_note(u32 *buf,
- char *name, unsigned type, void *data, size_t data_len)
+static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
+ size_t data_len)
{
struct elf_note note;
+
note.n_namesz = strlen(name) + 1;
note.n_descsz = data_len;
note.n_type = type;
@@ -44,26 +45,28 @@ static u32 *append_elf_note(u32 *buf,
buf += (note.n_namesz + 3)/4;
memcpy(buf, data, note.n_descsz);
buf += (note.n_descsz + 3)/4;
+
return buf;
}
static void final_note(u32 *buf)
{
struct elf_note note;
+
note.n_namesz = 0;
note.n_descsz = 0;
note.n_type = 0;
memcpy(buf, &note, sizeof(note));
}
-
static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
{
struct elf_prstatus prstatus;
u32 *buf;
- if ((cpu < 0) || (cpu >= NR_CPUS)) {
+
+ if ((cpu < 0) || (cpu >= NR_CPUS))
return;
- }
+
/* Using ELF notes here is opportunistic.
* I need a well defined structure format
* for the data I pass, and I need tags
@@ -75,9 +78,8 @@ static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
memset(&prstatus, 0, sizeof(prstatus));
prstatus.pr_pid = current->pid;
elf_core_copy_regs(&prstatus.pr_reg, regs);
- buf = append_elf_note(buf, "CORE", NT_PRSTATUS,
- &prstatus, sizeof(prstatus));
-
+ buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
+ sizeof(prstatus));
final_note(buf);
}
@@ -119,8 +121,8 @@ static void crash_save_self(struct pt_regs *saved_regs)
{
struct pt_regs regs;
int cpu;
- cpu = smp_processor_id();
+ cpu = smp_processor_id();
if (saved_regs)
crash_setup_regs(&regs, saved_regs);
else
@@ -153,6 +155,7 @@ static int crash_nmi_callback(struct pt_regs *regs, int cpu)
/* Assume hlt works */
__asm__("hlt");
for(;;);
+
return 1;
}
@@ -169,8 +172,8 @@ static void smp_send_nmi_allbutself(void)
static void nmi_shootdown_cpus(void)
{
unsigned long msecs;
- atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
+ atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
/* Would it be better to replace the trap vector here? */
set_nmi_callback(crash_nmi_callback);
/* Ensure the new callback function is set before sending
diff --git a/arch/i386/kernel/machine_kexec.c b/arch/i386/kernel/machine_kexec.c
index 67188041..52ed18d 100644
--- a/arch/i386/kernel/machine_kexec.c
+++ b/arch/i386/kernel/machine_kexec.c
@@ -80,7 +80,8 @@ static void identity_map_page(unsigned long address)
/* Identity map the page table entry */
pgtable_level1[level1_index] = address | L0_ATTR;
pgtable_level2[level2_index] = __pa(pgtable_level1) | L1_ATTR;
- set_64bit(&pgtable_level3[level3_index], __pa(pgtable_level2) | L2_ATTR);
+ set_64bit(&pgtable_level3[level3_index],
+ __pa(pgtable_level2) | L2_ATTR);
/* Flush the tlb so the new mapping takes effect.
* Global tlb entries are not flushed but that is not an issue.
@@ -139,8 +140,10 @@ static void load_segments(void)
}
typedef asmlinkage NORET_TYPE void (*relocate_new_kernel_t)(
- unsigned long indirection_page, unsigned long reboot_code_buffer,
- unsigned long start_address, unsigned int has_pae) ATTRIB_NORET;
+ unsigned long indirection_page,
+ unsigned long reboot_code_buffer,
+ unsigned long start_address,
+ unsigned int has_pae) ATTRIB_NORET;
const extern unsigned char relocate_new_kernel[];
extern void relocate_new_kernel_end(void);
@@ -180,20 +183,23 @@ NORET_TYPE void machine_kexec(struct kimage *image)
{
unsigned long page_list;
unsigned long reboot_code_buffer;
+
relocate_new_kernel_t rnk;
/* Interrupts aren't acceptable while we reboot */
local_irq_disable();
/* Compute some offsets */
- reboot_code_buffer = page_to_pfn(image->control_code_page) << PAGE_SHIFT;
+ reboot_code_buffer = page_to_pfn(image->control_code_page)
+ << PAGE_SHIFT;
page_list = image->head;
/* Set up an identity mapping for the reboot_code_buffer */
identity_map_page(reboot_code_buffer);
/* copy it out */
- memcpy((void *)reboot_code_buffer, relocate_new_kernel, relocate_new_kernel_size);
+ memcpy((void *)reboot_code_buffer, relocate_new_kernel,
+ relocate_new_kernel_size);
/* The segment registers are funny things, they are
* automatically loaded from a table, in memory wherever you
diff --git a/arch/ppc/kernel/machine_kexec.c b/arch/ppc/kernel/machine_kexec.c
index b825353..84d65a8 100644
--- a/arch/ppc/kernel/machine_kexec.c
+++ b/arch/ppc/kernel/machine_kexec.c
@@ -21,24 +21,23 @@
#include <asm/machdep.h>
typedef NORET_TYPE void (*relocate_new_kernel_t)(
- unsigned long indirection_page, unsigned long reboot_code_buffer,
- unsigned long start_address) ATTRIB_NORET;
+ unsigned long indirection_page,
+ unsigned long reboot_code_buffer,
+ unsigned long start_address) ATTRIB_NORET;
const extern unsigned char relocate_new_kernel[];
const extern unsigned int relocate_new_kernel_size;
void machine_shutdown(void)
{
- if (ppc_md.machine_shutdown) {
+ if (ppc_md.machine_shutdown)
ppc_md.machine_shutdown();
- }
}
void machine_crash_shutdown(struct pt_regs *regs)
{
- if (ppc_md.machine_crash_shutdown) {
+ if (ppc_md.machine_crash_shutdown)
ppc_md.machine_crash_shutdown();
- }
}
/*
@@ -48,9 +47,8 @@ void machine_crash_shutdown(struct pt_regs *regs)
*/
int machine_kexec_prepare(struct kimage *image)
{
- if (ppc_md.machine_kexec_prepare) {
+ if (ppc_md.machine_kexec_prepare)
return ppc_md.machine_kexec_prepare(image);
- }
/*
* Fail if platform doesn't provide its own machine_kexec_prepare
* implementation.
@@ -60,9 +58,8 @@ int machine_kexec_prepare(struct kimage *image)
void machine_kexec_cleanup(struct kimage *image)
{
- if (ppc_md.machine_kexec_cleanup) {
+ if (ppc_md.machine_kexec_cleanup)
ppc_md.machine_kexec_cleanup(image);
- }
}
/*
@@ -71,9 +68,9 @@ void machine_kexec_cleanup(struct kimage *image)
*/
NORET_TYPE void machine_kexec(struct kimage *image)
{
- if (ppc_md.machine_kexec) {
+ if (ppc_md.machine_kexec)
ppc_md.machine_kexec(image);
- } else {
+ else {
/*
* Fall back to normal restart if platform doesn't provide
* its own kexec function, and user insist to kexec...
@@ -83,7 +80,6 @@ NORET_TYPE void machine_kexec(struct kimage *image)
for(;;);
}
-
/*
* This is a generic machine_kexec function suitable at least for
* non-OpenFirmware embedded platforms.
@@ -104,15 +100,15 @@ void machine_kexec_simple(struct kimage *image)
/* we need both effective and real address here */
reboot_code_buffer =
- (unsigned long)page_address(image->control_code_page);
+ (unsigned long)page_address(image->control_code_page);
reboot_code_buffer_phys = virt_to_phys((void *)reboot_code_buffer);
/* copy our kernel relocation code to the control code page */
- memcpy((void *)reboot_code_buffer,
- relocate_new_kernel, relocate_new_kernel_size);
+ memcpy((void *)reboot_code_buffer, relocate_new_kernel,
+ relocate_new_kernel_size);
flush_icache_range(reboot_code_buffer,
- reboot_code_buffer + KEXEC_CONTROL_CODE_SIZE);
+ reboot_code_buffer + KEXEC_CONTROL_CODE_SIZE);
printk(KERN_INFO "Bye!\n");
/* now call it */
diff --git a/arch/ppc64/kernel/machine_kexec.c b/arch/ppc64/kernel/machine_kexec.c
index 06b25b5..fdb2fc6 100644
--- a/arch/ppc64/kernel/machine_kexec.c
+++ b/arch/ppc64/kernel/machine_kexec.c
@@ -58,7 +58,7 @@ int machine_kexec_prepare(struct kimage *image)
* handle the virtual mode, we must make sure no destination
* overlaps kernel static data or bss.
*/
- for(i = 0; i < image->nr_segments; i++)
+ for (i = 0; i < image->nr_segments; i++)
if (image->segment[i].mem < __pa(_end))
return -ETXTBSY;
@@ -76,7 +76,7 @@ int machine_kexec_prepare(struct kimage *image)
low = __pa(htab_address);
high = low + (htab_hash_mask + 1) * HASH_GROUP_SIZE;
- for(i = 0; i < image->nr_segments; i++) {
+ for (i = 0; i < image->nr_segments; i++) {
begin = image->segment[i].mem;
end = begin + image->segment[i].memsz;
@@ -98,7 +98,7 @@ int machine_kexec_prepare(struct kimage *image)
low = *basep;
high = low + (*sizep);
- for(i = 0; i < image->nr_segments; i++) {
+ for (i = 0; i < image->nr_segments; i++) {
begin = image->segment[i].mem;
end = begin + image->segment[i].memsz;
@@ -274,7 +274,8 @@ union thread_union kexec_stack
/* Our assembly helper, in kexec_stub.S */
extern NORET_TYPE void kexec_sequence(void *newstack, unsigned long start,
- void *image, void *control, void (*clear_all)(void)) ATTRIB_NORET;
+ void *image, void *control,
+ void (*clear_all)(void)) ATTRIB_NORET;
/* too late to fail here */
void machine_kexec(struct kimage *image)
diff --git a/arch/s390/kernel/machine_kexec.c b/arch/s390/kernel/machine_kexec.c
index 7a94db7..2721c3a 100644
--- a/arch/s390/kernel/machine_kexec.c
+++ b/arch/s390/kernel/machine_kexec.c
@@ -67,7 +67,7 @@ machine_kexec(struct kimage *image)
ctl_clear_bit(0,28);
on_each_cpu(kexec_halt_all_cpus, image, 0, 0);
- for(;;);
+ for (;;);
}
static void
@@ -85,7 +85,7 @@ kexec_halt_all_cpus(void *kernel_image)
for_each_online_cpu(cpu) {
if (cpu == smp_processor_id())
continue;
- while(!smp_cpu_not_running(cpu))
+ while (!smp_cpu_not_running(cpu))
cpu_relax();
}
diff --git a/arch/x86_64/kernel/machine_kexec.c b/arch/x86_64/kernel/machine_kexec.c
index 200b599..60d1eff 100644
--- a/arch/x86_64/kernel/machine_kexec.c
+++ b/arch/x86_64/kernel/machine_kexec.c
@@ -32,29 +32,31 @@
#define L2_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
#define L3_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
-static void init_level2_page(
- u64 *level2p, unsigned long addr)
+static void init_level2_page(u64 *level2p, unsigned long addr)
{
unsigned long end_addr;
+
addr &= PAGE_MASK;
end_addr = addr + LEVEL2_SIZE;
- while(addr < end_addr) {
+ while (addr < end_addr) {
*(level2p++) = addr | L1_ATTR;
addr += LEVEL1_SIZE;
}
}
-static int init_level3_page(struct kimage *image,
- u64 *level3p, unsigned long addr, unsigned long last_addr)
+static int init_level3_page(struct kimage *image, u64 *level3p,
+ unsigned long addr, unsigned long last_addr)
{
unsigned long end_addr;
int result;
+
result = 0;
addr &= PAGE_MASK;
end_addr = addr + LEVEL3_SIZE;
- while((addr < last_addr) && (addr < end_addr)) {
+ while ((addr < last_addr) && (addr < end_addr)) {
struct page *page;
u64 *level2p;
+
page = kimage_alloc_control_pages(image, 0);
if (!page) {
result = -ENOMEM;
@@ -66,7 +68,7 @@ static int init_level3_page(struct kimage *image,
addr += LEVEL2_SIZE;
}
/* clear the unused entries */
- while(addr < end_addr) {
+ while (addr < end_addr) {
*(level3p++) = 0;
addr += LEVEL2_SIZE;
}
@@ -75,17 +77,19 @@ out:
}
-static int init_level4_page(struct kimage *image,
- u64 *level4p, unsigned long addr, unsigned long last_addr)
+static int init_level4_page(struct kimage *image, u64 *level4p,
+ unsigned long addr, unsigned long last_addr)
{
unsigned long end_addr;
int result;
+
result = 0;
addr &= PAGE_MASK;
end_addr = addr + LEVEL4_SIZE;
- while((addr < last_addr) && (addr < end_addr)) {
+ while ((addr < last_addr) && (addr < end_addr)) {
struct page *page;
u64 *level3p;
+
page = kimage_alloc_control_pages(image, 0);
if (!page) {
result = -ENOMEM;
@@ -100,11 +104,11 @@ static int init_level4_page(struct kimage *image,
addr += LEVEL3_SIZE;
}
/* clear the unused entries */
- while(addr < end_addr) {
+ while (addr < end_addr) {
*(level4p++) = 0;
addr += LEVEL3_SIZE;
}
- out:
+out:
return result;
}
@@ -113,7 +117,7 @@ static int init_pgtable(struct kimage *image, unsigned long start_pgtable)
{
u64 *level4p;
level4p = (u64 *)__va(start_pgtable);
- return init_level4_page(image, level4p, 0, end_pfn << PAGE_SHIFT);
+ return init_level4_page(image, level4p, 0, end_pfn << PAGE_SHIFT);
}
static void set_idt(void *newidt, u16 limit)
@@ -159,9 +163,10 @@ static void load_segments(void)
#undef __STR
}
-typedef NORET_TYPE void (*relocate_new_kernel_t)(
- unsigned long indirection_page, unsigned long control_code_buffer,
- unsigned long start_address, unsigned long pgtable) ATTRIB_NORET;
+typedef NORET_TYPE void (*relocate_new_kernel_t)(unsigned long indirection_page,
+ unsigned long control_code_buffer,
+ unsigned long start_address,
+ unsigned long pgtable) ATTRIB_NORET;
const extern unsigned char relocate_new_kernel[];
const extern unsigned long relocate_new_kernel_size;
@@ -172,17 +177,17 @@ int machine_kexec_prepare(struct kimage *image)
int result;
/* Calculate the offsets */
- start_pgtable = page_to_pfn(image->control_code_page) << PAGE_SHIFT;
+ start_pgtable = page_to_pfn(image->control_code_page) << PAGE_SHIFT;
control_code_buffer = start_pgtable + 4096UL;
/* Setup the identity mapped 64bit page table */
result = init_pgtable(image, start_pgtable);
- if (result) {
+ if (result)
return result;
- }
/* Place the code in the reboot code buffer */
- memcpy(__va(control_code_buffer), relocate_new_kernel, relocate_new_kernel_size);
+ memcpy(__va(control_code_buffer), relocate_new_kernel,
+ relocate_new_kernel_size);
return 0;
}
@@ -207,8 +212,8 @@ NORET_TYPE void machine_kexec(struct kimage *image)
local_irq_disable();
/* Calculate the offsets */
- page_list = image->head;
- start_pgtable = page_to_pfn(image->control_code_page) << PAGE_SHIFT;
+ page_list = image->head;
+ start_pgtable = page_to_pfn(image->control_code_page) << PAGE_SHIFT;
control_code_buffer = start_pgtable + 4096UL;
/* Set the low half of the page table to my identity mapped
OpenPOWER on IntegriCloud