summaryrefslogtreecommitdiffstats
path: root/include/linux/efi.h
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-02-03 19:53:46 +0000
committerMatt Fleming <matt.fleming@intel.com>2013-04-17 08:28:21 +0100
commitd5abc7c1050ab2b9556a4bf21626cd74e83cd086 (patch)
treec38123d5676d331d9562a7f2620b470743b80f09 /include/linux/efi.h
parent07961ac7c0ee8b546658717034fe692fd12eefa9 (diff)
downloadlinux-d5abc7c1050ab2b9556a4bf21626cd74e83cd086.tar.gz
linux-d5abc7c1050ab2b9556a4bf21626cd74e83cd086.tar.bz2
linux-d5abc7c1050ab2b9556a4bf21626cd74e83cd086.zip
efi: move utf16 string functions to efi.h
There are currently two implementations of the utf16 string functions. Somewhat confusingly, they've got different names. Centralise the functions in efi.h. Reviewed-by: Tom Gundersen <teg@jklm.no> Tested-by: Tom Gundersen <teg@jklm.no> Reviewed-by: Mike Waychison <mikew@google.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'include/linux/efi.h')
-rw-r--r--include/linux/efi.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 9bf2f1fcae27..d1d782a6d34c 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -719,6 +719,23 @@ static inline void memrange_efi_to_native(u64 *addr, u64 *npages)
*addr &= PAGE_MASK;
}
+/* Return the number of unicode characters in data */
+static inline unsigned long
+utf16_strnlen(efi_char16_t *s, size_t maxlength)
+{
+ unsigned long length = 0;
+
+ while (*s++ != 0 && length < maxlength)
+ length++;
+ return length;
+}
+
+static inline unsigned long
+utf16_strlen(efi_char16_t *s)
+{
+ return utf16_strnlen(s, ~0UL);
+}
+
#if defined(CONFIG_EFI_VARS) || defined(CONFIG_EFI_VARS_MODULE)
/*
* EFI Variable support.