aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-20 17:11:58 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-20 17:12:47 -0400
commit957417bfeca2893254e660b01e18e71bd4572a38 (patch)
tree836f176ec4465b50c8012f77ea1f638816295a1c
parentc97dbc89bf21d7ef7297b90e0139a27fc10e9cd1 (diff)
staging: csr: remove a bunch of unused functions in csr_util.c
They were wrappers for other functions already in the kernel, and no one was even calling them, so remove them. 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>
-rw-r--r--drivers/staging/csr/csr_util.c321
-rw-r--r--drivers/staging/csr/csr_util.h31
2 files changed, 0 insertions, 352 deletions
diff --git a/drivers/staging/csr/csr_util.c b/drivers/staging/csr/csr_util.c
index 4a9bde09add7..48ed9b79e073 100644
--- a/drivers/staging/csr/csr_util.c
+++ b/drivers/staging/csr/csr_util.c
@@ -16,179 +16,9 @@
16#include "csr_util.h" 16#include "csr_util.h"
17 17
18/*------------------------------------------------------------------*/ 18/*------------------------------------------------------------------*/
19/* Bits */
20/*------------------------------------------------------------------*/
21
22/* Time proportional with the number of 1's */
23u8 CsrBitCountSparse(u32 n)
24{
25 u8 count = 0;
26
27 while (n)
28 {
29 count++;
30 n &= (n - 1);
31 }
32
33 return count;
34}
35
36/* Time proportional with the number of 0's */
37u8 CsrBitCountDense(u32 n)
38{
39 u8 count = 8 * sizeof(u32);
40
41 n ^= (u32) (-1);
42
43 while (n)
44 {
45 count--;
46 n &= (n - 1);
47 }
48
49 return count;
50}
51
52/*------------------------------------------------------------------*/
53/* Base conversion */ 19/* Base conversion */
54/*------------------------------------------------------------------*/ 20/*------------------------------------------------------------------*/
55u8 CsrHexStrToUint8(const char *string, u8 *returnValue)
56{
57 u16 currentIndex = 0;
58 *returnValue = 0;
59 if ((string[currentIndex] == '0') && (CSR_TOUPPER(string[currentIndex + 1]) == 'X'))
60 {
61 string += 2;
62 }
63 if (((string[currentIndex] >= '0') && (string[currentIndex] <= '9')) || ((CSR_TOUPPER(string[currentIndex]) >= 'A') && (CSR_TOUPPER(string[currentIndex]) <= 'F')))
64 {
65 while (((string[currentIndex] >= '0') && (string[currentIndex] <= '9')) || ((CSR_TOUPPER(string[currentIndex]) >= 'A') && (CSR_TOUPPER(string[currentIndex]) <= 'F')))
66 {
67 *returnValue = (u8) (*returnValue * 16 + (((string[currentIndex] >= '0') && (string[currentIndex] <= '9')) ? string[currentIndex] - '0' : CSR_TOUPPER(string[currentIndex]) - 'A' + 10));
68 currentIndex++;
69 if (currentIndex >= 2)
70 {
71 break;
72 }
73 }
74 return TRUE;
75 }
76 return FALSE;
77}
78
79u8 CsrHexStrToUint16(const char *string, u16 *returnValue)
80{
81 u16 currentIndex = 0;
82 *returnValue = 0;
83 if ((string[currentIndex] == '0') && (CSR_TOUPPER(string[currentIndex + 1]) == 'X'))
84 {
85 string += 2;
86 }
87 if (((string[currentIndex] >= '0') && (string[currentIndex] <= '9')) || ((CSR_TOUPPER(string[currentIndex]) >= 'A') && (CSR_TOUPPER(string[currentIndex]) <= 'F')))
88 {
89 while (((string[currentIndex] >= '0') && (string[currentIndex] <= '9')) || ((CSR_TOUPPER(string[currentIndex]) >= 'A') && (CSR_TOUPPER(string[currentIndex]) <= 'F')))
90 {
91 *returnValue = (u16) (*returnValue * 16 + (((string[currentIndex] >= '0') && (string[currentIndex] <= '9')) ? string[currentIndex] - '0' : CSR_TOUPPER(string[currentIndex]) - 'A' + 10));
92 currentIndex++;
93 if (currentIndex >= 4)
94 {
95 break;
96 }
97 }
98 return TRUE;
99 }
100 return FALSE;
101}
102
103u8 CsrHexStrToUint32(const char *string, u32 *returnValue)
104{
105 u16 currentIndex = 0;
106 *returnValue = 0;
107 if ((string[currentIndex] == '0') && (CSR_TOUPPER(string[currentIndex + 1]) == 'X'))
108 {
109 string += 2;
110 }
111 if (((string[currentIndex] >= '0') && (string[currentIndex] <= '9')) || ((CSR_TOUPPER(string[currentIndex]) >= 'A') && (CSR_TOUPPER(string[currentIndex]) <= 'F')))
112 {
113 while (((string[currentIndex] >= '0') && (string[currentIndex] <= '9')) || ((CSR_TOUPPER(string[currentIndex]) >= 'A') && (CSR_TOUPPER(string[currentIndex]) <= 'F')))
114 {
115 *returnValue = *returnValue * 16 + (((string[currentIndex] >= '0') && (string[currentIndex] <= '9')) ? string[currentIndex] - '0' : CSR_TOUPPER(string[currentIndex]) - 'A' + 10);
116 currentIndex++;
117 if (currentIndex >= 8)
118 {
119 break;
120 }
121 }
122 return TRUE;
123 }
124 return FALSE;
125}
126
127u32 CsrPow(u32 base, u32 exponent)
128{
129 if (exponent == 0)
130 {
131 return 1;
132 }
133 else
134 {
135 u32 i, t = base;
136
137 for (i = 1; i < exponent; i++)
138 {
139 t = t * base;
140 }
141 return t;
142 }
143}
144
145/* Convert signed 32 bit (or less) integer to string */ 21/* Convert signed 32 bit (or less) integer to string */
146#define I2B10_MAX 12
147void CsrIntToBase10(s32 number, char *str)
148{
149 s32 digit;
150 u8 index;
151 char res[I2B10_MAX];
152 u8 foundDigit = FALSE;
153
154 for (digit = 0; digit < I2B10_MAX; digit++)
155 {
156 res[digit] = '\0';
157 }
158
159 /* Catch sign - and deal with positive numbers only afterwards */
160 index = 0;
161 if (number < 0)
162 {
163 res[index++] = '-';
164 number = -1 * number;
165 }
166
167 digit = 1000000000;
168 if (number > 0)
169 {
170 while ((index < I2B10_MAX - 1) && (digit > 0))
171 {
172 /* If the foundDigit flag is TRUE, this routine should be proceeded.
173 Otherwise the number which has '0' digit cannot be converted correctly */
174 if (((number / digit) > 0) || foundDigit)
175 {
176 foundDigit = TRUE; /* set foundDigit flag to TRUE*/
177 res[index++] = (char) ('0' + (number / digit));
178 number = number % digit;
179 }
180
181 digit = digit / 10;
182 }
183 }
184 else
185 {
186 res[index] = (char) '0';
187 }
188
189 CsrStrCpy(str, res);
190}
191
192void CsrUInt16ToHex(u16 number, char *str) 22void CsrUInt16ToHex(u16 number, char *str)
193{ 23{
194 u16 index; 24 u16 index;
@@ -203,20 +33,6 @@ void CsrUInt16ToHex(u16 number, char *str)
203 str[4] = '\0'; 33 str[4] = '\0';
204} 34}
205 35
206void CsrUInt32ToHex(u32 number, char *str)
207{
208 u16 index;
209 u32 currentValue;
210
211 for (index = 0; index < 8; index++)
212 {
213 currentValue = (u32) (number & 0x0000000F);
214 number >>= 4;
215 str[7 - index] = (char) (currentValue > 9 ? currentValue + 55 : currentValue + '0');
216 }
217 str[8] = '\0';
218}
219
220/*------------------------------------------------------------------*/ 36/*------------------------------------------------------------------*/
221/* String */ 37/* String */
222/*------------------------------------------------------------------*/ 38/*------------------------------------------------------------------*/
@@ -244,19 +60,6 @@ s32 CsrMemCmp(const void *buf1, const void *buf2, size_t count)
244 return memcmp(buf1, buf2, count); 60 return memcmp(buf1, buf2, count);
245} 61}
246EXPORT_SYMBOL_GPL(CsrMemCmp); 62EXPORT_SYMBOL_GPL(CsrMemCmp);
247
248void *CsrMemDup(const void *buf1, size_t count)
249{
250 void *buf2 = NULL;
251
252 if (buf1)
253 {
254 buf2 = CsrPmemAlloc(count);
255 CsrMemCpy(buf2, buf1, count);
256 }
257
258 return buf2;
259}
260#endif 63#endif
261 64
262#ifndef CSR_USE_STDC_LIB 65#ifndef CSR_USE_STDC_LIB
@@ -270,21 +73,6 @@ char *CsrStrNCpy(char *dest, const char *src, size_t count)
270 return strncpy(dest, src, count); 73 return strncpy(dest, src, count);
271} 74}
272 75
273char *CsrStrCat(char *dest, const char *src)
274{
275 return strcat(dest, src);
276}
277
278char *CsrStrNCat(char *dest, const char *src, size_t count)
279{
280 return strncat(dest, src, count);
281}
282
283char *CsrStrStr(const char *string1, const char *string2)
284{
285 return strstr(string1, string2);
286}
287
288size_t CsrStrLen(const char *string) 76size_t CsrStrLen(const char *string)
289{ 77{
290 return strlen(string); 78 return strlen(string);
@@ -313,39 +101,6 @@ s32 CsrVsnprintf(char *string, size_t count, const char *format, va_list args)
313} 101}
314EXPORT_SYMBOL_GPL(CsrVsnprintf); 102EXPORT_SYMBOL_GPL(CsrVsnprintf);
315 103
316char *CsrStrNCpyZero(char *dest,
317 const char *src,
318 size_t count)
319{
320 CsrStrNCpy(dest, src, count - 1);
321 dest[count - 1] = '\0';
322 return dest;
323}
324
325/* Convert string with base 10 to integer */
326u32 CsrStrToInt(const char *str)
327{
328 s16 i;
329 u32 res;
330 u32 digit;
331
332 res = 0;
333 digit = 1;
334
335 /* Start from the string end */
336 for (i = (u16) (CsrStrLen(str) - 1); i >= 0; i--)
337 {
338 /* Only convert numbers */
339 if ((str[i] >= '0') && (str[i] <= '9'))
340 {
341 res += digit * (str[i] - '0');
342 digit = digit * 10;
343 }
344 }
345
346 return res;
347}
348
349char *CsrStrDup(const char *string) 104char *CsrStrDup(const char *string)
350{ 105{
351 char *copy; 106 char *copy;
@@ -361,82 +116,6 @@ char *CsrStrDup(const char *string)
361 return copy; 116 return copy;
362} 117}
363 118
364int CsrStrNICmp(const char *string1,
365 const char *string2,
366 size_t count)
367{
368 u32 index;
369 int returnValue = 0;
370
371 for (index = 0; index < count; index++)
372 {
373 if (CSR_TOUPPER(string1[index]) != CSR_TOUPPER(string2[index]))
374 {
375 if (CSR_TOUPPER(string1[index]) > CSR_TOUPPER(string2[index]))
376 {
377 returnValue = 1;
378 }
379 else
380 {
381 returnValue = -1;
382 }
383 break;
384 }
385 if (string1[index] == '\0')
386 {
387 break;
388 }
389 }
390 return returnValue;
391}
392
393const char *CsrGetBaseName(const char *file)
394{
395 const char *pch;
396 static const char dotDir[] = ".";
397
398 if (!file)
399 {
400 return NULL;
401 }
402
403 if (file[0] == '\0')
404 {
405 return dotDir;
406 }
407
408 pch = file + CsrStrLen(file) - 1;
409
410 while (*pch != '\\' && *pch != '/' && *pch != ':')
411 {
412 if (pch == file)
413 {
414 return pch;
415 }
416 --pch;
417 }
418
419 return ++pch;
420}
421
422/*------------------------------------------------------------------*/
423/* Misc */
424/*------------------------------------------------------------------*/
425u8 CsrIsSpace(u8 c)
426{
427 switch (c)
428 {
429 case '\t':
430 case '\n':
431 case '\f':
432 case '\r':
433 case ' ':
434 return TRUE;
435 default:
436 return FALSE;
437 }
438}
439
440MODULE_DESCRIPTION("CSR Operating System Kernel Abstraction"); 119MODULE_DESCRIPTION("CSR Operating System Kernel Abstraction");
441MODULE_AUTHOR("Cambridge Silicon Radio Ltd."); 120MODULE_AUTHOR("Cambridge Silicon Radio Ltd.");
442MODULE_LICENSE("GPL and additional rights"); 121MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/staging/csr/csr_util.h b/drivers/staging/csr/csr_util.h
index a124c73a5d6e..3561344f67bf 100644
--- a/drivers/staging/csr/csr_util.h
+++ b/drivers/staging/csr/csr_util.h
@@ -19,21 +19,9 @@ extern "C" {
19#include "csr_macro.h" 19#include "csr_macro.h"
20 20
21/*------------------------------------------------------------------*/ 21/*------------------------------------------------------------------*/
22/* Bits - intended to operate on u32 values */
23/*------------------------------------------------------------------*/
24u8 CsrBitCountSparse(u32 n);
25u8 CsrBitCountDense(u32 n);
26
27/*------------------------------------------------------------------*/
28/* Base conversion */ 22/* Base conversion */
29/*------------------------------------------------------------------*/ 23/*------------------------------------------------------------------*/
30u8 CsrHexStrToUint8(const char *string, u8 *returnValue);
31u8 CsrHexStrToUint16(const char *string, u16 *returnValue);
32u8 CsrHexStrToUint32(const char *string, u32 *returnValue);
33u32 CsrPow(u32 base, u32 exponent);
34void CsrIntToBase10(s32 number, char *str);
35void CsrUInt16ToHex(u16 number, char *str); 24void CsrUInt16ToHex(u16 number, char *str);
36void CsrUInt32ToHex(u32 number, char *str);
37 25
38/*------------------------------------------------------------------*/ 26/*------------------------------------------------------------------*/
39/* Standard C Library functions */ 27/* Standard C Library functions */
@@ -43,13 +31,10 @@ void CsrUInt32ToHex(u32 number, char *str);
43#define CsrMemMove memmove 31#define CsrMemMove memmove
44#define CsrStrCpy strcpy 32#define CsrStrCpy strcpy
45#define CsrStrNCpy strncpy 33#define CsrStrNCpy strncpy
46#define CsrStrCat strcat
47#define CsrStrNCat strncat
48#define CsrMemCmp(s1, s2, n) ((s32) memcmp((s1), (s2), (n))) 34#define CsrMemCmp(s1, s2, n) ((s32) memcmp((s1), (s2), (n)))
49#define CsrStrCmp(s1, s2) ((s32) strcmp((s1), (s2))) 35#define CsrStrCmp(s1, s2) ((s32) strcmp((s1), (s2)))
50#define CsrStrNCmp(s1, s2, n) ((s32) strncmp((s1), (s2), (n))) 36#define CsrStrNCmp(s1, s2, n) ((s32) strncmp((s1), (s2), (n)))
51#define CsrStrChr strchr 37#define CsrStrChr strchr
52#define CsrStrStr strstr
53#define CsrMemSet memset 38#define CsrMemSet memset
54#define CsrStrLen strlen 39#define CsrStrLen strlen
55#else /* !CSR_USE_STDC_LIB */ 40#else /* !CSR_USE_STDC_LIB */
@@ -57,13 +42,10 @@ void *CsrMemCpy(void *dest, const void *src, size_t count);
57void *CsrMemMove(void *dest, const void *src, size_t count); 42void *CsrMemMove(void *dest, const void *src, size_t count);
58char *CsrStrCpy(char *dest, const char *src); 43char *CsrStrCpy(char *dest, const char *src);
59char *CsrStrNCpy(char *dest, const char *src, size_t count); 44char *CsrStrNCpy(char *dest, const char *src, size_t count);
60char *CsrStrCat(char *dest, const char *src);
61char *CsrStrNCat(char *dest, const char *src, size_t count);
62s32 CsrMemCmp(const void *buf1, const void *buf2, size_t count); 45s32 CsrMemCmp(const void *buf1, const void *buf2, size_t count);
63s32 CsrStrCmp(const char *string1, const char *string2); 46s32 CsrStrCmp(const char *string1, const char *string2);
64s32 CsrStrNCmp(const char *string1, const char *string2, size_t count); 47s32 CsrStrNCmp(const char *string1, const char *string2, size_t count);
65char *CsrStrChr(const char *string, char c); 48char *CsrStrChr(const char *string, char c);
66char *CsrStrStr(const char *string1, const char *string2);
67void *CsrMemSet(void *dest, u8 c, size_t count); 49void *CsrMemSet(void *dest, u8 c, size_t count);
68size_t CsrStrLen(const char *string); 50size_t CsrStrLen(const char *string);
69#endif /* !CSR_USE_STDC_LIB */ 51#endif /* !CSR_USE_STDC_LIB */
@@ -72,21 +54,8 @@ s32 CsrVsnprintf(char *string, size_t count, const char *format, va_list args);
72/*------------------------------------------------------------------*/ 54/*------------------------------------------------------------------*/
73/* Non-standard utility functions */ 55/* Non-standard utility functions */
74/*------------------------------------------------------------------*/ 56/*------------------------------------------------------------------*/
75void *CsrMemDup(const void *buf1, size_t count);
76int CsrStrNICmp(const char *string1, const char *string2, size_t count);
77char *CsrStrDup(const char *string); 57char *CsrStrDup(const char *string);
78u32 CsrStrToInt(const char *string);
79char *CsrStrNCpyZero(char *dest, const char *src, size_t count);
80
81/*------------------------------------------------------------------*/
82/* Filename */
83/*------------------------------------------------------------------*/
84const char *CsrGetBaseName(const char *file);
85 58
86/*------------------------------------------------------------------*/
87/* Misc */
88/*------------------------------------------------------------------*/
89u8 CsrIsSpace(u8 c);
90#define CsrOffsetOf(st, m) ((size_t) & ((st *) 0)->m) 59#define CsrOffsetOf(st, m) ((size_t) & ((st *) 0)->m)
91 60
92#ifdef __cplusplus 61#ifdef __cplusplus