summaryrefslogtreecommitdiff
path: root/kexec/arch/sh
diff options
context:
space:
mode:
authorJamey Sharp <jamey@thetovacompany.com>2008-05-15 22:42:10 -0700
committerSimon Horman <horms@verge.net.au>2008-05-21 16:29:56 +1000
commit7c3109cb6c5e1834bb3b6f788c9dcaa0ddbdf090 (patch)
treeafe65be035cbb3bc3377b5b9113d3d91e6e49b41 /kexec/arch/sh
parent01cc79edacf626472e3d505b60ac86f7150efa84 (diff)
Factor uname-based native architecture detection into a common function.
This code was copy-pasted into every architecture and was basically identical. Besides producing a nice net reduction in code, this factors a portability challenge into a single function that can be easily replaced at build-time. Signed-off-by: Jamey Sharp <jamey@thetovacompany.com> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/arch/sh')
-rw-r--r--kexec/arch/sh/kexec-sh.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/kexec/arch/sh/kexec-sh.c b/kexec/arch/sh/kexec-sh.c
index 7050ccd..f0b5a76 100644
--- a/kexec/arch/sh/kexec-sh.c
+++ b/kexec/arch/sh/kexec-sh.c
@@ -14,7 +14,6 @@
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
-#include <sys/utsname.h>
#include "../../kexec.h"
#include "../../kexec-syscall.h"
#include "kexec-sh.h"
@@ -99,31 +98,18 @@ int arch_process_options(int argc, char **argv)
return 0;
}
+const struct arch_map_entry arches[] = {
+ /* For compatibility with older patches
+ * use KEXEC_ARCH_DEFAULT instead of KEXEC_ARCH_SH here.
+ */
+ { "sh3", KEXEC_ARCH_DEFAULT },
+ { "sh4", KEXEC_ARCH_DEFAULT },
+ { "sh4a", KEXEC_ARCH_DEFAULT },
+ { 0 },
+};
+
int arch_compat_trampoline(struct kexec_info *info)
{
- int result;
- struct utsname utsname;
- result = uname(&utsname);
- if (result < 0) {
- fprintf(stderr, "uname failed: %s\n",
- strerror(errno));
- return -1;
- }
- if ( (strcmp(utsname.machine, "sh3") == 0) ||
- (strcmp(utsname.machine, "sh4") == 0) ||
- (strcmp(utsname.machine, "sh4a") == 0))
- {
- /*
- * For compatibility with older patches
- * use KEXEC_ARCH_DEFAULT instead of KEXEC_ARCH_SH here.
- */
- info->kexec_flags |= KEXEC_ARCH_DEFAULT;
- }
- else {
- fprintf(stderr, "Unsupported machine type: %s\n",
- utsname.machine);
- return -1;
- }
return 0;
}