summaryrefslogtreecommitdiffstats
path: root/drivers/staging/csr
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-20 17:04:08 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-20 17:04:08 -0700
commit9e16d457689d1b866e8c1b7de331cb069e341f4c (patch)
treed494bf6412ec69bce2d903a799bfa482e117229e /drivers/staging/csr
parenteaae2e9223e859cd968b58bd3173a3f17b50538d (diff)
downloadblackbird-op-linux-9e16d457689d1b866e8c1b7de331cb069e341f4c.tar.gz
blackbird-op-linux-9e16d457689d1b866e8c1b7de331cb069e341f4c.zip
staging: csr: remove csr_utf16.c
Only one function was being used in the file, so move it to where it was being called and delete the rest of the file, and csr_unicode.h as it's no longer needed as well. Cc: Mikko Virkkilä <mikko.virkkila@bluegiga.com> Cc: Lauri Hintsala <Lauri.Hintsala@bluegiga.com> Cc: Riku Mettälä <riku.mettala@bluegiga.com> Cc: Veli-Pekka Peltola <veli-pekka.peltola@bluegiga.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/csr')
-rw-r--r--drivers/staging/csr/Makefile1
-rw-r--r--drivers/staging/csr/csr_msgconv.h1
-rw-r--r--drivers/staging/csr/csr_serialize_primitive_types.c28
-rw-r--r--drivers/staging/csr/csr_unicode.h87
-rw-r--r--drivers/staging/csr/csr_utf16.c1055
-rw-r--r--drivers/staging/csr/csr_wifi_msgconv.h1
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_serialize.c1
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_serialize.c3
-rw-r--r--drivers/staging/csr/csr_wifi_router_serialize.c3
-rw-r--r--drivers/staging/csr/csr_wifi_sme_serialize.c3
10 files changed, 28 insertions, 1155 deletions
diff --git a/drivers/staging/csr/Makefile b/drivers/staging/csr/Makefile
index 814f57a539db..afda44b0a925 100644
--- a/drivers/staging/csr/Makefile
+++ b/drivers/staging/csr/Makefile
@@ -71,6 +71,5 @@ csr_helper-y := csr_time.o \
csr_framework_ext.o \
csr_wifi_serialize_primitive_types.o \
csr_serialize_primitive_types.o \
- csr_utf16.o \
csr_msgconv.o \
csr_panic.o
diff --git a/drivers/staging/csr/csr_msgconv.h b/drivers/staging/csr/csr_msgconv.h
index 2e1aad8a3895..08497096fdfe 100644
--- a/drivers/staging/csr/csr_msgconv.h
+++ b/drivers/staging/csr/csr_msgconv.h
@@ -14,7 +14,6 @@
#include <linux/types.h>
#include "csr_prim_defs.h"
#include "csr_sched.h"
-#include "csr_unicode.h"
#ifdef __cplusplus
extern "C" {
diff --git a/drivers/staging/csr/csr_serialize_primitive_types.c b/drivers/staging/csr/csr_serialize_primitive_types.c
index 39406fd1f1a1..a6f29ea36d20 100644
--- a/drivers/staging/csr/csr_serialize_primitive_types.c
+++ b/drivers/staging/csr/csr_serialize_primitive_types.c
@@ -15,6 +15,34 @@
#include "csr_macro.h"
#include "csr_lib.h"
+/********************************************************************************
+*
+* Name: CsrUtf16StrLen
+*
+* Description: The function returns the number of 16 bit elements present
+* in the 0-terminated string.
+*
+* Input: 0-terminated string of 16 bit unicoded characters.
+*
+* Output: The number of 16 bit elements in the string.
+*
+*********************************************************************************/
+static u32 CsrUtf16StrLen(const u16 *unicodeString)
+{
+ u32 length;
+
+ length = 0;
+ if (unicodeString != NULL)
+ {
+ while (*unicodeString)
+ {
+ length++;
+ unicodeString++;
+ }
+ }
+ return length;
+}
+
void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset)
{
*value = buffer[*offset];
diff --git a/drivers/staging/csr/csr_unicode.h b/drivers/staging/csr/csr_unicode.h
deleted file mode 100644
index 2105e7110c65..000000000000
--- a/drivers/staging/csr/csr_unicode.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#ifndef CSR_UNICODE_H__
-#define CSR_UNICODE_H__
-/*****************************************************************************
-
- (c) Cambridge Silicon Radio Limited 2010
- All rights reserved and confidential information of CSR
-
- Refer to LICENSE.txt included with this source for details
- on the license terms.
-
-*****************************************************************************/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-u16 *CsrUint32ToUtf16String(u32 number);
-
-u32 CsrUtf16StringToUint32(const u16 *unicodeString);
-u32 CsrUtf16StrLen(const u16 *unicodeString);
-
-u8 *CsrUtf16String2Utf8(const u16 *source);
-
-u16 *CsrUtf82Utf16String(const u8 *utf8String);
-
-u16 *CsrUtf16StrCpy(u16 *target, const u16 *source);
-u16 *CsrUtf16StringDuplicate(const u16 *source);
-
-u16 CsrUtf16StrICmp(const u16 *string1, const u16 *string2);
-u16 CsrUtf16StrNICmp(const u16 *string1, const u16 *string2, u32 count);
-
-u16 *CsrUtf16MemCpy(u16 *dest, const u16 *src, u32 count);
-u16 *CsrUtf16ConcatenateTexts(const u16 *inputText1, const u16 *inputText2,
- const u16 *inputText3, const u16 *inputText4);
-
-u16 *CsrUtf16String2XML(u16 *str);
-u16 *CsrXML2Utf16String(u16 *str);
-
-u32 CsrUtf8StringLengthInBytes(const u8 *string);
-
-/*******************************************************************************
-
- NAME
- CsrUtf8StrTruncate
-
- DESCRIPTION
- In-place truncate a string on a UTF-8 character boundary by writing a
- null character somewhere in the range target[count - 3]:target[count].
-
- Please note that memory passed must be at least of length count + 1, to
- ensure space for a full length string that is terminated at
- target[count], in the event that target[count - 1] is the final byte of
- a UTF-8 character.
-
- PARAMETERS
- target - Target string to truncate.
- count - The desired length, in bytes, of the resulting string. Depending
- on the contents, the resulting string length will be between
- count - 3 and count.
-
- RETURNS
- Returns target
-
-*******************************************************************************/
-u8 *CsrUtf8StrTruncate(u8 *target, size_t count);
-
-/*
- * UCS2
- *
- * D-13157
- */
-typedef u8 CsrUcs2String;
-
-size_t CsrUcs2ByteStrLen(const CsrUcs2String *ucs2String);
-size_t CsrConverterUcs2ByteStrLen(const CsrUcs2String *str);
-
-u8 *CsrUcs2ByteString2Utf8(const CsrUcs2String *ucs2String);
-CsrUcs2String *CsrUtf82Ucs2ByteString(const u8 *utf8String);
-
-u8 *CsrUtf16String2Ucs2ByteString(const u16 *source);
-u16 *CsrUcs2ByteString2Utf16String(const u8 *source);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/drivers/staging/csr/csr_utf16.c b/drivers/staging/csr/csr_utf16.c
deleted file mode 100644
index 4854f85aa92a..000000000000
--- a/drivers/staging/csr/csr_utf16.c
+++ /dev/null
@@ -1,1055 +0,0 @@
-/*****************************************************************************
-
- (c) Cambridge Silicon Radio Limited 2010
- All rights reserved and confidential information of CSR
-
- Refer to LICENSE.txt included with this source for details
- on the license terms.
-
-*****************************************************************************/
-#include <linux/module.h>
-#include <linux/slab.h>
-#include "csr_unicode.h"
-#include "csr_macro.h"
-
-#define UNI_SUR_HIGH_START ((u32) 0xD800)
-#define UNI_SUR_HIGH_END ((u32) 0xDBFF)
-#define UNI_SUR_LOW_START ((u32) 0xDC00)
-#define UNI_SUR_LOW_END ((u32) 0xDFFF)
-#define UNI_REPLACEMENT_CHAR ((u32) 0xFFFD)
-#define UNI_HALF_SHIFT ((u8) 10) /* used for shifting by 10 bits */
-#define UNI_HALF_BASE ((u32) 0x00010000)
-#define UNI_BYTEMASK ((u32) 0xBF)
-#define UNI_BYTEMARK ((u32) 0x80)
-
-#define CAPITAL(x) ((x >= 'a') && (x <= 'z') ? ((x) & 0x00DF) : (x))
-
-/*
-* Index into the table with the first byte to get the number of trailing bytes in a utf-8 character.
-* -1 if the byte has an invalid value.
-*
-* Legal sequences are:
-*
-* byte 1st 2nd 3rd 4th
-*
-* 00-7F
-* C2-DF 80-BF
-* E0 A0-BF 80-BF
-* E1-EC 80-BF 80-BF
-* ED 80-9F 80-BF
-* EE-EF 80-BF 80-BF
-* F0 90-BF 80-BF 80-BF
-* F1-F3 80-BF 80-BF 80-BF
-* F4 80-8F 80-BF 80-BF
-*/
-static const s8 trailingBytesForUtf8[256] =
-{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 - 0x1F */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 - 0x3F */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 - 0x5F */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x7F */
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x80 - 0x9F */
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xA0 - 0xBF */
- -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xC0 - 0xDF */
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0xE0 - 0xFF */
-};
-
-/* Values to be substracted from a u32 when converting from UTF8 to UTF16 */
-static const u32 offsetsFromUtf8[4] =
-{
- 0x00000000, 0x00003080, 0x000E2080, 0x03C82080
-};
-
-/********************************************************************************
-*
-* Name: CsrUint32ToUtf16String
-*
-* Description: The function converts an 32 bit number to an UTF-16 string
-* that is allocated and 0-terminated.
-*
-* Input: 32 bit number.
-*
-* Output: A string of UTF-16 characters.
-*
-*********************************************************************************/
-u16 *CsrUint32ToUtf16String(u32 number)
-{
- u16 count, noOfDigits;
- u16 *output;
- u32 tempNumber;
-
- /* calculate the number of digits in the output */
- tempNumber = number;
- noOfDigits = 1;
- while (tempNumber >= 10)
- {
- tempNumber = tempNumber / 10;
- noOfDigits++;
- }
-
- output = kmalloc(sizeof(u16) * (noOfDigits + 1), GFP_KERNEL); /*add space for 0-termination*/
-
- tempNumber = number;
- for (count = noOfDigits; count > 0; count--)
- {
- output[count - 1] = (u16) ((tempNumber % 10) + '0');
- tempNumber = tempNumber / 10;
- }
- output[noOfDigits] = '\0';
-
- return output;
-}
-
-/********************************************************************************
-*
-* Name: CsrUtf16StringToUint32
-*
-* Description: The function converts an UTF-16 string that is
-* 0-terminated into a 32 bit number.
-*
-* Input: A string of UTF-16 characters containig a number.
-*
-* Output: 32 bit number.
-*
-*********************************************************************************/
-u32 CsrUtf16StringToUint32(const u16 *unicodeString)
-{
- u16 numLen, count;
- u32 newNumber = 0;
-
- numLen = (u16) CsrUtf16StrLen(unicodeString);
-
- if ((numLen > 10) || (numLen == 0) || (unicodeString == NULL)) /*CSRMAX number is 4.294.967.295 */
- {
- return 0;
- }
-
- for (count = 0; count < numLen; count++)
- {
- u16 input = unicodeString[count];
- if ((input < 0x30) || (input > 0x39) || ((newNumber == 0x19999999) && (input > 0x35)) || (newNumber > 0x19999999)) /* chars are present or number is too large now causing number to get to large when *10 */
- {
- return 0;
- }
-
- newNumber = (newNumber * 10) + (input - 0x30);
- }
- return newNumber;
-}
-
-/********************************************************************************
-*
-* Name: CsrUtf16MemCpy
-*
-* Description: The function copies count number of 16 bit data elements
-* from srv to dest.
-*
-* Input: A pointer to an unicoded string.
-*
-* Output: A pointer to an unicoded string.
-*
-*********************************************************************************/
-u16 *CsrUtf16MemCpy(u16 *dest, const u16 *src, u32 count)
-{
- return memcpy((u8 *) dest, (u8 *) src, count * sizeof(u16));
-}
-
-/********************************************************************************
-*
-* Name: CsrUtf16ConcatenateTexts
-*
-* Description: The function merge the contents of 4 unicoded input pointers
-* into a new string.
-*
-* Input: 4 unicoded input strings (UTF-16).
-*
-* Output: A new unicoded string (UTF-16) containing the combined strings.
-*
-*********************************************************************************/
-u16 *CsrUtf16ConcatenateTexts(const u16 *inputText1, const u16 *inputText2,
- const u16 *inputText3, const u16 *inputText4)
-{
- u16 *outputText;
- u32 textLen, textLen1, textLen2, textLen3, textLen4;
-
- textLen1 = CsrUtf16StrLen(inputText1);
- textLen2 = CsrUtf16StrLen(inputText2);
- textLen3 = CsrUtf16StrLen(inputText3);
- textLen4 = CsrUtf16StrLen(inputText4);
-
- textLen = textLen1 + textLen2 + textLen3 + textLen4;
-
- if (textLen == 0) /*stop here is all lengths are 0*/
- {
- return NULL;
- }
-
- outputText = kmalloc((textLen + 1) * sizeof(u16), GFP_KERNEL); /* add space for 0-termination*/
-
-
- if (inputText1 != NULL)
- {
- CsrUtf16MemCpy(outputText, inputText1, textLen1);
- }
-
- if (inputText2 != NULL)
- {
- CsrUtf16MemCpy(&(outputText[textLen1]), inputText2, textLen2);
- }
-
- if (inputText3 != NULL)
- {
- CsrUtf16MemCpy(&(outputText[textLen1 + textLen2]), inputText3, textLen3);
- }
-
- if (inputText4 != NULL)
- {
- CsrUtf16MemCpy(&(outputText[textLen1 + textLen2 + textLen3]), inputText4, textLen4);
- }
-
- outputText[textLen] = '\0';
-
- return outputText;
-}
-
-/********************************************************************************
-*
-* Name: CsrUtf16StrLen
-*
-* Description: The function returns the number of 16 bit elements present
-* in the 0-terminated string.
-*
-* Input: 0-terminated string of 16 bit unicoded characters.
-*
-* Output: The number of 16 bit elements in the string.
-*
-*********************************************************************************/
-u32 CsrUtf16StrLen(const u16 *unicodeString)
-{
- u32 length;
-
- length = 0;
- if (unicodeString != NULL)
- {
- while (*unicodeString)
- {
- length++;
- unicodeString++;
- }
- }
- return length;
-}
-
-/********************************************************************************
-*
-* Name: CsrUtf16String2Utf8
-*
-* Description: The function decodes an UTF-16 string into an UTF8 byte
-* oriented string.
-*
-* Input: 0-terminated UTF-16 string characters.
-*
-* Output: 0-terminated string of byte oriented UTF8 coded characters.
-*
-*********************************************************************************/
-u8 *CsrUtf16String2Utf8(const u16 *source)
-{
- u8 *dest, *destStart = NULL;
- u32 i;
- u32 ch;
- u32 length;
- u32 sourceLength;
- u8 bytes;
- u8 appendNull = FALSE;
-
- u8 firstByteMark[5] = {0x00, 0x00, 0xC0, 0xE0, 0xF0};
-
- if (!source)
- {
- return NULL;
- }
-
- length = 0;
- sourceLength = CsrUtf16StrLen(source) + 1;
-
- for (i = 0; i < sourceLength; i++)
- {
- ch = source[i];
- if ((ch >= UNI_SUR_HIGH_START) && (ch <= UNI_SUR_HIGH_END)) /* This is a high surrogate */
- {
- if (i + 1 < sourceLength) /* The low surrogate is in the source */
- {
- u32 ch2 = source[++i];
- if ((ch2 >= UNI_SUR_LOW_START) && (ch2 <= UNI_SUR_LOW_END)) /* And it is a legal low surrogate */
- {
- length += 4;
- }
- else /* It is not a low surrogate, instead put a Unicode
- 'REPLACEMENT CHARACTER' (U+FFFD) */
- {
- length += 3;
- i--; /* Substract 1 again as the conversion must continue after the ill-formed code unit */
- }
- }
- else /* The low surrogate does not exist, instead put a Unicode
- 'REPLACEMENT CHARACTER' (U+FFFD), and the null terminated character */
- {
- length += 4;
- }
- }
- else if ((ch >= UNI_SUR_LOW_START) && (ch <= UNI_SUR_LOW_END)) /* The value of UTF-16 is not allowed to be in this range, instead put
- a Unicode 'REPLACEMENT CHARACTER' (U+FFFD) */
- {
- length += 3;
- }
- else /* Figure out how many bytes that are required */
- {
- if (ch < 0x0080)
- {
- length++;
- }
- else if (ch < 0x0800)
- {
- length += 2;
- }
- else
- {
- length += 3;
- }
- }
- }
-
- dest = kmalloc(length, GFP_KERNEL);
- destStart = dest;
-
- for (i = 0; i < sourceLength; i++)
- {
- ch = source[i];
- if ((ch >= UNI_SUR_HIGH_START) && (ch <= UNI_SUR_HIGH_END)) /* This is a high surrogate */
- {
- if (i + 1 < sourceLength) /* The low surrogate is in the source */
- {
- u32 ch2 = source[++i];
- if ((ch2 >= UNI_SUR_LOW_START) && (ch2 <= UNI_SUR_LOW_END)) /* And it is a legal low surrogate, convert to UTF-32 */
- {
- ch = ((ch - UNI_SUR_HIGH_START) << UNI_HALF_SHIFT) + (ch2 - UNI_SUR_LOW_START) + UNI_HALF_BASE;
- }
- else /* It is not a low surrogate, instead put a Unicode
- 'REPLACEMENT CHARACTER' (U+FFFD) */
- {
- ch = UNI_REPLACEMENT_CHAR;
- i--; /* Substract 1 again as the conversion must continue after the ill-formed code unit */
- }
- }
- else /* The low surrogate does not exist, instead put a Unicode
- 'REPLACEMENT CHARACTER' (U+FFFD), and the null terminated character */
- {
- ch = UNI_REPLACEMENT_CHAR;
- appendNull = TRUE;
- }
- }
- else if ((ch >= UNI_SUR_LOW_START) && (ch <= UNI_SUR_LOW_END)) /* The value of UTF-16 is not allowed to be in this range, instead put
- a Unicode 'REPLACEMENT CHARACTER' (U+FFFD) */
- {
- ch = UNI_REPLACEMENT_CHAR;
- }
-
- /* Figure out how many bytes that are required */
- if (ch < (u32) 0x80)
- {
- bytes = 1;
- }
- else if (ch < (u32) 0x800)
- {
- bytes = 2;
- }
- else if (ch < (u32) 0x10000)
- {
- bytes = 3;
- }
- else if (ch < (u32) 0x110000)
- {
- bytes = 4;
- }
- else
- {
- bytes = 3;
- ch = UNI_REPLACEMENT_CHAR;
- }
-
- dest += bytes;
-
- switch (bytes) /* Convert character to UTF-8. Note: everything falls through. */
- {
- case 4:
- {
- *--dest = (u8) ((ch | UNI_BYTEMARK) & UNI_BYTEMASK);
- ch >>= 6;
- }
- /* FALLTHROUGH */
- case 3:
- {
- *--dest = (u8) ((ch | UNI_BYTEMARK) & UNI_BYTEMASK);
- ch >>= 6;
- }
- /* FALLTHROUGH */
- case 2:
- {
- *--dest = (u8) ((ch | UNI_BYTEMARK) & UNI_BYTEMASK);
- ch >>= 6;
- }
- /* FALLTHROUGH */
- case 1:
- {
- *--dest = (u8) (ch | firstByteMark[bytes]);
- }
- /* FALLTHROUGH */
- default:
- {
- break;
- }
- }
-
- dest += bytes;
- }
-
- if (appendNull) /* Append the \0 character */
- {
- *dest = '\0';
- }
-
- return destStart;
-}
-
-/*****************************************************************************
-
- NAME
- isLegalUtf8
-
- DESCRIPTION
- Returns TRUE if the given UFT-8 code unit is legal as defined by the
- Unicode standard (see Chapter 3: Conformance, Section 3.9: Unicode
- Encoding Forms, UTF-8).
-
- This function assumes that the length parameter is unconditionally
- correct and that the first byte is already validated by looking it up
- in the trailingBytesForUtf8 array, which also reveals the number of
- trailing bytes.
-
- Legal code units are composed of one of the following byte sequences:
-
- 1st 2nd 3rd 4th
- --------------------------------
- 00-7F
- C2-DF 80-BF
- E0 A0-BF 80-BF
- E1-EC 80-BF 80-BF
- ED 80-9F 80-BF
- EE-EF 80-BF 80-BF
- F0 90-BF 80-BF 80-BF
- F1-F3 80-BF 80-BF 80-BF
- F4 80-8F 80-BF 80-BF
-
- Please note that this function only checks whether the 2nd, 3rd and
- 4th bytes fall into the valid ranges.
-
- PARAMETERS
- codeUnit - pointer to the first byte of the byte sequence composing
- the code unit to test.
- length - the number of bytes in the code unit. Valid range is 1 to 4.
-
- RETURNS
- TRUE if the given code unit is legal.
-
-*****************************************************************************/
-static u8 isLegalUtf8(const u8 *codeUnit, u32 length)
-{
- const u8 *srcPtr = codeUnit + length;
- u8 byte;
-
- switch (length) /* Everything falls through except case 1 */
- {
- case 4:
- {
- byte = *--srcPtr;
- if ((byte < 0x80) || (byte > 0xBF))
- {
- return FALSE;
- }
- }
- /* Fallthrough */
- case 3:
- {
- byte = *--srcPtr;
- if ((byte < 0x80) || (byte > 0xBF))
- {
- return FALSE;
- }
- }
- /* Fallthrough */
- case 2:
- {
- byte = *--srcPtr;
- if (byte > 0xBF)
- {
- return FALSE;
- }
-
- switch (*codeUnit) /* No fallthrough */
- {
- case 0xE0:
- {
- if (byte < 0xA0)
- {
- return FALSE;
- }
- break;
- }
- case 0xED:
- {
- if ((byte < 0x80) || (byte > 0x9F))
- {
- return FALSE;
- }
- break;
- }
- case 0xF0:
- {
- if (byte < 0x90)
- {
- return FALSE;
- }
- break;
- }
- case 0xF4:
- {
- if ((byte < 0x80) || (byte > 0x8F))
- {
- return FALSE;
- }
- break;
- }
- default:
- {
- if (byte < 0x80)
- {
- return FALSE;
- }
- break;
- }
- }
- }
- /* Fallthrough */
- case 1:
- default:
- /* The 1st byte and length are assumed correct */
- break;
- }
-
- return TRUE;
-}
-
-/********************************************************************************
-*
-* Name: CsrUtf82Utf16String
-*
-* Description: The function decodes an UTF8 byte oriented string into a
-* UTF-16string.
-*
-* Input: 0-terminated string of byte oriented UTF8 coded characters.
-*
-* Output: 0-terminated string of UTF-16 characters.
-*
-*********************************************************************************/
-u16 *CsrUtf82Utf16String(const u8 *utf8String)
-{
- size_t i, length = 0;
- size_t sourceLength;
- u16 *dest = NULL;
- u16 *destStart = NULL;
- s8 extraBytes2Read;
-
- if (!utf8String)
- {
- return NULL;
- }
- sourceLength = strlen((char *)utf8String);
-
- for (i = 0; i < sourceLength; i++)
- {
- extraBytes2Read = trailingBytesForUtf8[utf8String[i]];
-
- if (extraBytes2Read == -1) /* Illegal byte value, instead put a Unicode 'REPLACEMENT CHARACTER' (U+FFFD) */
- {
- length += 1;
- }
- else if (i + extraBytes2Read > sourceLength) /* The extra bytes does not exist, instead put a Unicode 'REPLACEMENT
- CHARACTER' (U+FFFD), and the null terminated character */
- {
- length += 2;
- break;
- }
- else if (isLegalUtf8(&utf8String[i], extraBytes2Read + 1) == FALSE) /* It is not a legal utf-8 character, instead put a Unicode 'REPLACEMENT
- CHARACTER' (U+FFFD) */
- {
- length += 1;
- }
- else
- {
- if (utf8String[i] > 0xEF) /* Needs a high and a low surrogate */
- {
- length += 2;
- }
- else
- {
- length += 1;
- }
- i += extraBytes2Read;
- }
- }
-
- /* Create space for the null terminated character */
- dest = kmalloc((1 + length) * sizeof(u16), GFP_KERNEL);
- destStart = dest;
-
- for (i = 0; i < sourceLength; i++)
- {
- extraBytes2Read = trailingBytesForUtf8[utf8String[i]];
-
- if (extraBytes2Read == -1) /* Illegal byte value, instead put a Unicode 'REPLACEMENT CHARACTER' (U+FFFD) */
- {
- *dest++ = UNI_REPLACEMENT_CHAR;
- }
- else if (i + extraBytes2Read > sourceLength) /* The extra bytes does not exist, instead put a Unicode 'REPLACEMENT
- CHARACTER' (U+FFFD), and the null terminated character */
- {
- *dest++ = UNI_REPLACEMENT_CHAR;
- *dest++ = '\0';
- break;
- }
- else if (isLegalUtf8(&utf8String[i], extraBytes2Read + 1) == FALSE) /* It is not a legal utf-8 character, instead put a Unicode 'REPLACEMENT
- CHARACTER' (U+FFFD) */
- {
- *dest++ = UNI_REPLACEMENT_CHAR;
- }
- else /* It is legal, convert the character to an u32 */
- {
- u32 ch = 0;
-
- switch (extraBytes2Read) /* Everything falls through */
- {
- case 3:
- {
- ch += utf8String[i];
- ch <<= 6;
- i++;
- }
- /* FALLTHROUGH */
- case 2:
- {
- ch += utf8String[i];
- ch <<= 6;
- i++;
- }
- /* FALLTHROUGH */
- case 1:
- {
- ch += utf8String[i];
- ch <<= 6;
- i++;
- }
- /* FALLTHROUGH */
- case 0:
- {
- ch += utf8String[i];
- }
- /* FALLTHROUGH */
- default:
- {
- break;
- }
- }
-
- ch -= offsetsFromUtf8[extraBytes2Read];
-
- if (ch <= 0xFFFF) /* Character can be encoded in one u16 */
- {
- *dest++ = (u16) ch;
- }
- else /* The character needs two u16 */
- {
- ch -= UNI_HALF_BASE;
- *dest++ = (u16) ((ch >> UNI_HALF_SHIFT) | UNI_SUR_HIGH_START);
- *dest++ = (u16) ((ch & 0x03FF) | UNI_SUR_LOW_START);
- }
- }
- }
-
- destStart[length] = 0x00;
-
- return destStart;
-}
-
-/********************************************************************************
-*
-* Name: CsrUtf16StrCpy
-*
-* Description: The function copies the contents from one UTF-16 string
-* to another UTF-16 string.
-*
-* Input: 0-terminated UTF-16 string.
-*
-* Output: 0-terminated UTF-16 string.
-*
-*********************************************************************************/
-u16 *CsrUtf16StrCpy(u16 *target, const u16 *source)
-{
- if (source) /* if source is not NULL*/
- {
- memcpy(target, source, (CsrUtf16StrLen(source) + 1) * sizeof(u16));
- return target;
- }
- else
- {
- return NULL;
- }
-}
-
-/********************************************************************************
-*
-* Name: CsrUtf16StringDuplicate
-*
-* Description: The function allocates a new pointer and copies the input to
-* the new pointer.
-*
-* Input: 0-terminated UTF-16 string.
-*
-* Output: Allocated variable0-terminated UTF-16 string.
-*
-*********************************************************************************/
-u16 *CsrUtf16StringDuplicate(const u16 *source)
-{
- u16 *target = NULL;
- u32 length;
-
- if (source) /* if source is not NULL*/
- {
- length = (CsrUtf16StrLen(source) + 1) * sizeof(u16);
- target = kmalloc(length, GFP_KERNEL);
- memcpy(target, source, length);
- }
- return target;
-}
-
-/********************************************************************************
-*
-* Name: CsrUtf16StrICmp
-*
-* Description: The function compares two UTF-16 strings.
-*
-* Input: Two 0-terminated UTF-16 string.
-*
-* Output: 0: if the strings are identical.
-*
-*********************************************************************************/
-u16 CsrUtf16StrICmp(const u16 *string1, const u16 *string2)
-{
- while (*string1 || *string2)
- {
- if (CAPITAL(*string1) != CAPITAL(*string2))
- {
- return *string1 - *string2;
- }
- string1++;
- string2++;
- }
-
- return 0;
-}
-
-/********************************************************************************
-*
-* Name: CsrUtf16StrNICmp
-*
-* Description: The function compares upto count number of elements in the
-* two UTF-16 string.
-*
-* Input: Two 0-terminated UTF-16 string and a maximum
-* number of elements to check.
-*
-* Output: 0: if the strings are identical.
-*
-*********************************************************************************/
-u16 CsrUtf16StrNICmp(const u16 *string1, const u16 *string2, u32 count)
-{
- while ((*string1 || *string2) && count--)
- {
- if (CAPITAL(*string1) != CAPITAL(*string2))
- {
- return *string1 - *string2;
- }
- string1++;
- string2++;
- }
-
- return 0;
-}
-
-/********************************************************************************
-*
-* Name: CsrUtf16String2XML
-*
-* Description: The function converts an unicoded string (UTF-16) into an unicoded XML
-* string where some special characters are encoded according to
-* the XML spec.
-*
-* Input: A unicoded string (UTF-16) which is freed.
-*
-* Output: A new unicoded string (UTF-16) containing the converted output.
-*
-*********************************************************************************/
-u16 *CsrUtf16String2XML(u16 *str)
-{
- u16 *scanString;
- u16 *outputString = NULL;
- u16 *resultString = str;
- u32 stringLength = 0;
- u8 encodeChars = FALSE;
-
- scanString = str;
- if (scanString)
- {
- while (*scanString)
- {
- if (*scanString == L'&')
- {
- stringLength += 5;
- encodeChars = TRUE;
- }
- else if ((*scanString == L'<') || (*scanString == L'>'))
- {
- stringLength += 4;
- encodeChars = TRUE;
- }
- else
- {
- stringLength++;
- }
-
- scanString++;
- }
-
- stringLength++;
-
- if (encodeChars)
- {
- resultString = outputString = kmalloc(stringLength * sizeof(u16), GFP_KERNEL);
-
- scanString = str;
-
- while (*scanString)
- {
- if (*scanString == L'&')
- {
- *outputString++ = '&';
- *outputString++ = 'a';
- *outputString++ = 'm';
- *outputString++ = 'p';
- *outputString++ = ';';
- }
- else if (*scanString == L'<')
- {
- *outputString++ = '&';
- *outputString++ = 'l';
- *outputString++ = 't';
- *outputString++ = ';';
- }
- else if (*scanString == L'>')
- {
- *outputString++ = '&';
- *outputString++ = 'g';
- *outputString++ = 't';
- *outputString++ = ';';
- }
- else
- {
- *outputString++ = *scanString;
- }
-
- scanString++;
- }
-
- *outputString++ = 0;
-
- kfree(str);
- }
- }
-
- return resultString;
-}
-
-/********************************************************************************
-*
-* Name: CsrXML2Utf16String
-*
-* Description: The function converts an unicoded XML string into an unicoded
-* string (UTF-16) where some special XML characters are decoded according to
-* the XML spec.
-*
-* Input: A unicoded XML string which is freed.
-*
-* Output: A new unicoded pointer containing the decoded output.
-*
-*********************************************************************************/
-u16 *CsrXML2Utf16String(u16 *str)
-{
- u16 *scanString;
- u16 *outputString = NULL;
- u16 *resultString = str;
- u32 stringLength = 0;
- u8 encodeChars = FALSE;
-
- scanString = str;
- if (scanString)
- {
- while (*scanString)
- {
- if (*scanString == (u16) L'&')
- {
- scanString++;
-
- if (!CsrUtf16StrNICmp(scanString, (u16 *) L"AMP;", 4))
- {
- scanString += 3;
- encodeChars = TRUE;
- }
- else if (!CsrUtf16StrNICmp(scanString, (u16 *) L"LT;", 3))
- {
- scanString += 2;
- encodeChars = TRUE;
- }
- else if (!CsrUtf16StrNICmp(scanString, (u16 *) L"GT;", 3))
- {
- scanString += 2;
- encodeChars = TRUE;
- }
- if (!CsrUtf16StrNICmp(scanString, (u16 *) L"APOS;", 5))
- {
- scanString += 4;
- encodeChars = TRUE;
- }
- if (!CsrUtf16StrNICmp(scanString, (u16 *) L"QUOT;", 5))
- {
- scanString += 4;
- encodeChars = TRUE;
- }
- else
- {
- scanString--;
- }
- }
-
- stringLength++;
- scanString++;
- }
-
- stringLength++;
-
- if (encodeChars)
- {
- resultString = outputString = kmalloc(stringLength * sizeof(u16), GFP_KERNEL);
-
- scanString = str;
-
- while (*scanString)
- {
- if (*scanString == L'&')
- {
- scanString++;
-
- if (!CsrUtf16StrNICmp(scanString, (u16 *) L"AMP;", 4))
- {
- *outputString++ = L'&';
- scanString += 3;
- }
- else if (!CsrUtf16StrNICmp(scanString, (u16 *) L"LT;", 3))
- {
- *outputString++ = L'<';
- scanString += 2;
- }
- else if (!CsrUtf16StrNICmp(scanString, (u16 *) L"GT;", 3))
- {
- *outputString++ = L'>';
- scanString += 2;
- }
- else if (!CsrUtf16StrNICmp(scanString, (u16 *) L"APOS;", 5))
- {
- *outputString++ = L'\'';
- scanString += 4;
- }
- else if (!CsrUtf16StrNICmp(scanString, (u16 *) L"QUOT;", 5))
- {
- *outputString++ = L'\"';
- scanString += 4;
- }
- else
- {
- *outputString++ = L'&';
- scanString--;
- }
- }
- else
- {
- *outputString++ = *scanString;
- }
-
- scanString++;
- }
-
- *outputString++ = 0;
-
- kfree(str);
- }
- }
-
- return resultString;
-}
-
-u32 CsrUtf8StringLengthInBytes(const u8 *string)
-{
- size_t length = 0;
- if (string)
- {
- length = strlen((const char *)string);
- }
- return (u32) length;
-}
-
-u8 *CsrUtf8StrTruncate(u8 *target, size_t count)
-{
- size_t lastByte = count - 1;
-
- target[count] = '\0';
-
- if (count && (target[lastByte] & 0x80))
- {
- /* the last byte contains non-ascii char */
- if (target[lastByte] & 0x40)
- {
- /* multi-byte char starting just before truncation */
- target[lastByte] = '\0';
- }
- else if ((target[lastByte - 1] & 0xE0) == 0xE0)
- {
- /* 3-byte char starting 2 bytes before truncation */
- target[lastByte - 1] = '\0';
- }
- else if ((target[lastByte - 2] & 0xF0) == 0xF0)
- {
- /* 4-byte char starting 3 bytes before truncation */
- target[lastByte - 2] = '\0';
- }
- }
-
- return target;
-}
diff --git a/drivers/staging/csr/csr_wifi_msgconv.h b/drivers/staging/csr/csr_wifi_msgconv.h
index 06314109098a..7ec35d70e14a 100644
--- a/drivers/staging/csr/csr_wifi_msgconv.h
+++ b/drivers/staging/csr/csr_wifi_msgconv.h
@@ -13,7 +13,6 @@
#include "csr_prim_defs.h"
#include "csr_sched.h"
-#include "csr_unicode.h"
#ifdef __cplusplus
extern "C" {
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_serialize.c b/drivers/staging/csr/csr_wifi_nme_ap_serialize.c
index 493e33e95e24..1a901a70d195 100644
--- a/drivers/staging/csr/csr_wifi_nme_ap_serialize.c
+++ b/drivers/staging/csr/csr_wifi_nme_ap_serialize.c
@@ -12,7 +12,6 @@
#include <linux/string.h>
#include <linux/slab.h>
#include "csr_msgconv.h"
-#include "csr_unicode.h"
#ifdef CSR_WIFI_NME_ENABLE
#ifdef CSR_WIFI_AP_ENABLE
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_serialize.c b/drivers/staging/csr/csr_wifi_router_ctrl_serialize.c
index b9f9adb5ad5d..3eda1b66b336 100644
--- a/drivers/staging/csr/csr_wifi_router_ctrl_serialize.c
+++ b/drivers/staging/csr/csr_wifi_router_ctrl_serialize.c
@@ -12,9 +12,6 @@
#include <linux/string.h>
#include <linux/slab.h>
#include "csr_msgconv.h"
-#include "csr_unicode.h"
-
-
#include "csr_wifi_router_ctrl_prim.h"
#include "csr_wifi_router_ctrl_serialize.h"
diff --git a/drivers/staging/csr/csr_wifi_router_serialize.c b/drivers/staging/csr/csr_wifi_router_serialize.c
index 5717ebc05b0b..4eccf5d6c289 100644
--- a/drivers/staging/csr/csr_wifi_router_serialize.c
+++ b/drivers/staging/csr/csr_wifi_router_serialize.c
@@ -11,9 +11,6 @@
/* Note: this is an auto-generated file. */
#include <linux/slab.h>
#include "csr_msgconv.h"
-#include "csr_unicode.h"
-
-
#include "csr_wifi_router_prim.h"
#include "csr_wifi_router_serialize.h"
diff --git a/drivers/staging/csr/csr_wifi_sme_serialize.c b/drivers/staging/csr/csr_wifi_sme_serialize.c
index d55e3ee6921a..7d7e1d8b5ed3 100644
--- a/drivers/staging/csr/csr_wifi_sme_serialize.c
+++ b/drivers/staging/csr/csr_wifi_sme_serialize.c
@@ -12,9 +12,6 @@
#include <linux/string.h>
#include <linux/slab.h>
#include "csr_msgconv.h"
-#include "csr_unicode.h"
-
-
#include "csr_wifi_sme_prim.h"
#include "csr_wifi_sme_serialize.h"
OpenPOWER on IntegriCloud