summaryrefslogtreecommitdiff
path: root/kexec/kexec.h
diff options
context:
space:
mode:
authorTiezhu Yang <yangtiezhu@loongson.cn>2022-07-15 18:05:14 +0800
committerSimon Horman <horms@kernel.org>2022-07-19 14:24:30 +0200
commitc3950959f42857d3de5bca01fe3f4a85f31545c5 (patch)
tree229e4426333376ee69d230a6b48ae7006a5ae874 /kexec/kexec.h
parent6cd3e94813f71bc45756fd4e3ca3beec19039c40 (diff)
kexec-tools: Remove duplicate ultoa() definitions and redefine it
There exist duplicate ultoa() definitions in many archs, remove them, and also redefine ultoa() in kexec/kexec.h to make it more readable. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Simon Horman <horms@kernel.org>
Diffstat (limited to 'kexec/kexec.h')
-rw-r--r--kexec/kexec.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 0f97a97..8a05644 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -329,4 +329,20 @@ int xen_kexec_status(uint64_t kexec_flags);
extern unsigned long long get_kernel_sym(const char *text);
+/* Converts unsigned long to ascii string. */
+static inline void ultoa(unsigned long val, char *str)
+{
+ char buf[36];
+ int len = 0, pos = 0;
+
+ do {
+ buf[len++] = val % 10;
+ val /= 10;
+ } while (val);
+
+ while (len)
+ str[pos++] = buf[--len] + '0';
+ str[pos] = 0;
+}
+
#endif /* KEXEC_H */