>From existing code, create function get_nr_cpus(). This function,
will be referenced from multiple locations.

No functional changes.

Signed-off-by: Eric DeVolder <[email protected]>
---
 kexec/crashdump-elf.c |  6 +-----
 kexec/crashdump.h     |  1 -
 kexec/kexec-xen.h     |  1 +
 kexec/kexec.c         | 11 +++++++++++
 kexec/kexec.h         |  2 ++
 5 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c
index b8bb686..5e29f7a 100644
--- a/kexec/crashdump-elf.c
+++ b/kexec/crashdump-elf.c
@@ -43,11 +43,7 @@ int FUNC(struct kexec_info *info,
        int (*get_note_info)(int cpu, uint64_t *addr, uint64_t *len);
        long int count_cpu;
 
-       if (xen_present())
-               nr_cpus = xen_get_nr_phys_cpus();
-       else
-               nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
-
+       nr_cpus = get_nr_cpus();
        if (nr_cpus < 0) {
                return -1;
        }
diff --git a/kexec/crashdump.h b/kexec/crashdump.h
index 18bd691..28d3278 100644
--- a/kexec/crashdump.h
+++ b/kexec/crashdump.h
@@ -57,7 +57,6 @@ unsigned long phys_to_virt(struct crash_elf_info *elf_info,
                           unsigned long long paddr);
 
 unsigned long xen_architecture(struct crash_elf_info *elf_info);
-int xen_get_nr_phys_cpus(void);
 int xen_get_note(int cpu, uint64_t *addr, uint64_t *len);
 int xen_get_crashkernel_region(uint64_t *start, uint64_t *end);
 
diff --git a/kexec/kexec-xen.h b/kexec/kexec-xen.h
index 70fb576..f54a2dd 100644
--- a/kexec/kexec-xen.h
+++ b/kexec/kexec-xen.h
@@ -83,5 +83,6 @@ extern int __xc_interface_close(xc_interface *xch);
 #endif
 
 int xen_get_kexec_range(int range, uint64_t *start, uint64_t *end);
+int xen_get_nr_phys_cpus(void);
 
 #endif /* KEXEC_XEN_H */
diff --git a/kexec/kexec.c b/kexec/kexec.c
index 90f2e71..d2379cb 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -490,6 +490,17 @@ static int add_backup_segments(struct kexec_info *info,
        return 0;
 }
 
+long int get_nr_cpus(void)
+{
+       long int nr_cpus;
+
+       if (xen_present())
+               nr_cpus = xen_get_nr_phys_cpus();
+       else
+               nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
+       return nr_cpus;
+}
+
 static char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread)
 {
        char *buf;
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 9a26065..9675e79 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -294,6 +294,8 @@ extern unsigned long add_buffer_phys_virt(struct kexec_info 
*info,
        int buf_end, int phys);
 extern void arch_reuse_initrd(void);
 
+extern long int get_nr_cpus(void);
+
 extern int ifdown(void);
 
 extern int do_hotplug;
-- 
2.31.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Reply via email to