|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH for-next] xen/kexec: Style fixes
Adjust kexec and kimage to more closely adhere to Xen style.
Sort the includes, dropping duplicates (kexec.h) and unused (ctype.h and
kernel.h).
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Anthony PERARD <anthony.perard@xxxxxxxxxx>
CC: Michal Orzel <michal.orzel@xxxxxxx>
CC: Jan Beulich <jbeulich@xxxxxxxx>
CC: Julien Grall <julien@xxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Kevin Lampis <kevin.lampis@xxxxxxxxxx>
Fix these before they get copied around in the EFI changes.
---
xen/common/kexec.c | 94 +++++++++++++++++++++++++--------------------
xen/common/kimage.c | 23 ++++++-----
2 files changed, 64 insertions(+), 53 deletions(-)
diff --git a/xen/common/kexec.c b/xen/common/kexec.c
index 65776a95fd70..9ff22e43991c 100644
--- a/xen/common/kexec.c
+++ b/xen/common/kexec.c
@@ -6,31 +6,33 @@
* - Magnus Damm <magnus@xxxxxxxxxxxxx>
*/
-#include <xen/init.h>
-#include <xen/lib.h>
#include <xen/acpi.h>
-#include <xen/ctype.h>
+#include <xen/console.h>
+#include <xen/cpu.h>
+#include <xen/cpumask.h>
#include <xen/elfcore.h>
#include <xen/errno.h>
#include <xen/guest_access.h>
-#include <xen/param.h>
-#include <xen/watchdog.h>
-#include <xen/sched.h>
-#include <xen/types.h>
#include <xen/hypercall.h>
+#include <xen/init.h>
#include <xen/kexec.h>
#include <xen/keyhandler.h>
-#include <public/kexec.h>
-#include <xen/cpumask.h>
-#include <asm/atomic.h>
+#include <xen/kimage.h>
+#include <xen/lib.h>
+#include <xen/param.h>
+#include <xen/sched.h>
#include <xen/spinlock.h>
+#include <xen/types.h>
#include <xen/version.h>
-#include <xen/console.h>
-#include <xen/kexec.h>
-#include <xen/kimage.h>
-#include <public/elfnote.h>
+#include <xen/watchdog.h>
+
+#include <asm/atomic.h>
+
#include <xsm/xsm.h>
-#include <xen/cpu.h>
+
+#include <public/elfnote.h>
+#include <public/kexec.h>
+
#ifdef CONFIG_COMPAT
#include <compat/kexec.h>
#endif
@@ -162,6 +164,7 @@ static int __init cf_check parse_crashkernel(const char
*str)
++idx;
} while ( *str == ',' );
+
if ( idx < ARRAY_SIZE(ranges) )
ranges[idx].size = 0;
}
@@ -317,7 +320,7 @@ void kexec_crash_save_cpu(void)
ELF_Prstatus *prstatus;
crash_xen_core_t *xencore;
- BUG_ON ( ! crash_notes );
+ BUG_ON(!crash_notes);
if ( cpumask_test_and_set_cpu(cpu, &crash_saved_cpus) )
return;
@@ -418,6 +421,7 @@ static void cf_check do_crashdump_trigger(unsigned char key)
static void setup_note(Elf_Note *n, const char *name, int type, int descsz)
{
int l = strlen(name) + 1;
+
strlcpy(ELFNOTE_NAME(n), name, l);
n->namesz = l;
n->descsz = descsz;
@@ -427,7 +431,7 @@ static void setup_note(Elf_Note *n, const char *name, int
type, int descsz)
static size_t sizeof_note(const char *name, int descsz)
{
return (sizeof(Elf_Note) +
- ELFNOTE_ALIGN(strlen(name)+1) +
+ ELFNOTE_ALIGN(strlen(name) + 1) +
ELFNOTE_ALIGN(descsz));
}
@@ -439,7 +443,7 @@ static size_t sizeof_cpu_notes(const unsigned long cpu)
+ sizeof_note("Xen", sizeof(crash_xen_core_t));
/* CPU0 also presents the crash_xen_info note. */
- if ( ! cpu )
+ if ( !cpu )
bytes = bytes +
sizeof_note("Xen", sizeof(crash_xen_info_t));
@@ -450,24 +454,27 @@ static size_t sizeof_cpu_notes(const unsigned long cpu)
* crash heap if the user has requested that crash notes be allocated
* in lower memory. There is currently no case where the crash notes
* should be free()'d. */
-static void * alloc_from_crash_heap(const size_t bytes)
+static void *alloc_from_crash_heap(const size_t bytes)
{
- void * ret;
+ void *ret;
+
if ( crash_heap_current + bytes > crash_heap_end )
return NULL;
- ret = (void*)crash_heap_current;
+
+ ret = crash_heap_current;
crash_heap_current += bytes;
+
return ret;
}
/* Allocate a crash note buffer for a newly onlined cpu. */
static int kexec_init_cpu_notes(const unsigned long cpu)
{
- Elf_Note * note = NULL;
+ Elf_Note *note = NULL;
int ret = 0;
int nr_bytes = 0;
- BUG_ON( cpu >= nr_cpu_ids || ! crash_notes );
+ BUG_ON(cpu >= nr_cpu_ids || !crash_notes);
/* If already allocated, nothing to do. */
if ( crash_notes[cpu].start )
@@ -505,7 +512,7 @@ static int kexec_init_cpu_notes(const unsigned long cpu)
/* If the allocation failed, and another CPU did not beat us, give
* up with ENOMEM. */
- if ( ! note )
+ if ( !note )
ret = -ENOMEM;
/* else all is good so lets set up the notes. */
else
@@ -518,7 +525,7 @@ static int kexec_init_cpu_notes(const unsigned long cpu)
setup_note(note, "Xen", XEN_ELFNOTE_CRASH_REGS,
sizeof(crash_xen_core_t));
- if ( ! cpu )
+ if ( !cpu )
{
/* Set up Xen Crash Info note. */
xen_crash_note = note = ELFNOTE_NEXT(note);
@@ -548,8 +555,6 @@ static int cf_check cpu_callback(
* fail the CPU_UP_PREPARE */
kexec_init_cpu_notes(cpu);
break;
- default:
- break;
}
return NOTIFY_DONE;
}
@@ -592,7 +597,7 @@ static int __init cf_check kexec_init(void)
get_order_from_bytes(crash_heap_size),
MEMF_bits(crashinfo_maxaddr_bits) );
- if ( ! crash_heap_current )
+ if ( !crash_heap_current )
return -ENOMEM;
memset(crash_heap_current, 0, crash_heap_size);
@@ -604,7 +609,7 @@ static int __init cf_check kexec_init(void)
Only the individual CPU crash notes themselves must be allocated
in lower memory if requested. */
crash_notes = xzalloc_array(crash_note_range_t, nr_cpu_ids);
- if ( ! crash_notes )
+ if ( !crash_notes )
return -ENOMEM;
register_keyhandler('C', do_crashdump_trigger, "trigger a crashdump", 0);
@@ -620,7 +625,8 @@ presmp_initcall(kexec_init);
static int kexec_get_reserve(xen_kexec_range_t *range)
{
- if ( kexec_crash_area.size > 0 && kexec_crash_area.start > 0) {
+ if ( kexec_crash_area.size > 0 && kexec_crash_area.start > 0 )
+ {
range->start = kexec_crash_area.start;
range->size = kexec_crash_area.size;
}
@@ -636,7 +642,7 @@ static int kexec_get_cpu(xen_kexec_range_t *range)
if ( nr < 0 || nr >= nr_cpu_ids )
return -ERANGE;
- if ( ! crash_notes )
+ if ( !crash_notes )
return -EINVAL;
/* Try once again to allocate room for the crash notes. It is just
possible
@@ -726,7 +732,7 @@ static int
kexec_get_range_compat(XEN_GUEST_HANDLE_PARAM(void) uarg)
{
XLAT_kexec_range(&compat_range, &range);
if ( unlikely(__copy_to_guest(uarg, &compat_range, 1)) )
- ret = -EFAULT;
+ ret = -EFAULT;
}
return ret;
@@ -760,7 +766,7 @@ void vmcoreinfo_append_str(const char *fmt, ...)
int r;
size_t note_size = sizeof(Elf_Note) +
ELFNOTE_ALIGN(strlen(VMCOREINFO_NOTE_NAME) + 1);
- if (vmcoreinfo_size + note_size + sizeof(buf) > VMCOREINFO_BYTES)
+ if ( vmcoreinfo_size + note_size + sizeof(buf) > VMCOREINFO_BYTES )
return;
va_start(args, fmt);
@@ -776,7 +782,7 @@ static void crash_save_vmcoreinfo(void)
{
size_t data_size;
- if (vmcoreinfo_size > 0) /* already saved */
+ if ( vmcoreinfo_size > 0 ) /* already saved */
return;
data_size = VMCOREINFO_BYTES - (sizeof(Elf_Note) +
ELFNOTE_ALIGN(strlen(VMCOREINFO_NOTE_NAME) + 1));
@@ -835,7 +841,7 @@ static int kexec_exec(XEN_GUEST_HANDLE_PARAM(void) uarg)
if ( !test_bit(base + pos, &kexec_flags) )
return -ENOENT;
- switch (exec.type)
+ switch ( exec.type )
{
case KEXEC_TYPE_DEFAULT:
image = kexec_image[base + pos];
@@ -917,8 +923,8 @@ static int kexec_segments_add_segment(unsigned int
*nr_segments,
unsigned int n = *nr_segments;
/* Need a new segment? */
- if ( n == 0
- || segments[n-1].dest_maddr + segments[n-1].dest_size != maddr )
+ if ( n == 0 ||
+ segments[n-1].dest_maddr + segments[n-1].dest_size != maddr )
{
n++;
if ( n > KEXEC_SEGMENT_MAX )
@@ -1139,7 +1145,7 @@ static int kexec_load(XEN_GUEST_HANDLE_PARAM(void) uarg)
return 0;
error:
- if ( ! kimage )
+ if ( !kimage )
xfree(segments);
kimage_free(kimage);
return ret;
@@ -1229,32 +1235,38 @@ static int do_kexec_op_internal(unsigned long op,
switch ( op )
{
case KEXEC_CMD_kexec_get_range:
- if (compat)
- ret = kexec_get_range_compat(uarg);
+ if ( compat )
+ ret = kexec_get_range_compat(uarg);
else
- ret = kexec_get_range(uarg);
+ ret = kexec_get_range(uarg);
break;
+
case KEXEC_CMD_kexec_load_v1:
if ( compat )
ret = kexec_load_v1_compat(uarg);
else
ret = kexec_load_v1(uarg);
break;
+
case KEXEC_CMD_kexec_unload_v1:
if ( compat )
ret = kexec_unload_v1_compat(uarg);
else
ret = kexec_unload_v1(uarg);
break;
+
case KEXEC_CMD_kexec:
ret = kexec_exec(uarg);
break;
+
case KEXEC_CMD_kexec_load:
ret = kexec_load(uarg);
break;
+
case KEXEC_CMD_kexec_unload:
ret = kexec_unload(uarg);
break;
+
case KEXEC_CMD_kexec_status:
ret = kexec_status(uarg);
break;
diff --git a/xen/common/kimage.c b/xen/common/kimage.c
index 6202491f7e76..a0e4e67df7ee 100644
--- a/xen/common/kimage.c
+++ b/xen/common/kimage.c
@@ -11,15 +11,13 @@
* Version 2. See the file COPYING for more details.
*/
-#include <xen/types.h>
-#include <xen/init.h>
-#include <xen/kernel.h>
#include <xen/errno.h>
-#include <xen/spinlock.h>
#include <xen/guest_access.h>
-#include <xen/mm.h>
+#include <xen/init.h>
#include <xen/kexec.h>
#include <xen/kimage.h>
+#include <xen/mm.h>
+#include <xen/spinlock.h>
#include <asm/page.h>
@@ -166,7 +164,7 @@ static int do_kimage_alloc(struct kexec_image **rimage,
paddr_t entry,
goto out;
}
- /*
+ /*
* Page for the relocation code must still be accessible after the
* processor has switched to 32-bit mode.
*/
@@ -221,8 +219,8 @@ static int kimage_crash_alloc(struct kexec_image **rimage,
paddr_t entry,
unsigned long i;
/* Verify we have a valid entry point */
- if ( (entry < kexec_crash_area.start)
- || (entry > kexec_crash_area.start + kexec_crash_area.size))
+ if ( entry < kexec_crash_area.start ||
+ entry > kexec_crash_area.start + kexec_crash_area.size )
return -EADDRNOTAVAIL;
/*
@@ -244,8 +242,8 @@ static int kimage_crash_alloc(struct kexec_image **rimage,
paddr_t entry,
mstart = segments[i].dest_maddr;
mend = mstart + segments[i].dest_size;
/* Ensure we are within the crash kernel limits. */
- if ( (mstart < kexec_crash_area.start )
- || (mend > kexec_crash_area.start + kexec_crash_area.size))
+ if ( mstart < kexec_crash_area.start ||
+ mend > kexec_crash_area.start + kexec_crash_area.size )
return -EADDRNOTAVAIL;
}
@@ -606,7 +604,7 @@ static struct page_info *kimage_alloc_page(struct
kexec_image *image,
}
}
page = NULL;
- for (;;)
+ for ( ;; )
{
kimage_entry_t *old;
@@ -825,7 +823,8 @@ int kimage_load_segments(struct kexec_image *image)
int s;
int result;
- for ( s = 0; s < image->nr_segments; s++ ) {
+ for ( s = 0; s < image->nr_segments; s++ )
+ {
result = kimage_load_segment(image, &image->segments[s]);
if ( result < 0 )
return result;
--
2.39.5
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |