Commit 5b2652b6 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman

staging: tidspbridge: gen: simplify and clean up

There is recently added hex_to_bin() kernel's method which we could use
instead of custom long function.
Signed-off-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Cc: Ohad Ben-Cohen <ohad@wizery.com>
Cc: linux-omap@vger.kernel.org
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4f551c8f
...@@ -54,61 +54,19 @@ void uuid_uuid_to_string(IN struct dsp_uuid *uuid_obj, OUT char *pszUuid, ...@@ -54,61 +54,19 @@ void uuid_uuid_to_string(IN struct dsp_uuid *uuid_obj, OUT char *pszUuid,
DBC_ENSURE(i != -1); DBC_ENSURE(i != -1);
} }
/* static s32 uuid_hex_to_bin(char *buf, s32 len)
* ======== htoi ========
* Purpose:
* Converts a hex value to a decimal integer.
*/
static int htoi(char c)
{ {
switch (c) { s32 i;
case '0': s32 result = 0;
return 0;
case '1': for (i = 0; i < len; i++) {
return 1; value = hex_to_bin(*buf++);
case '2': result *= 16;
return 2; if (value > 0)
case '3': result += value;
return 3;
case '4':
return 4;
case '5':
return 5;
case '6':
return 6;
case '7':
return 7;
case '8':
return 8;
case '9':
return 9;
case 'A':
return 10;
case 'B':
return 11;
case 'C':
return 12;
case 'D':
return 13;
case 'E':
return 14;
case 'F':
return 15;
case 'a':
return 10;
case 'b':
return 11;
case 'c':
return 12;
case 'd':
return 13;
case 'e':
return 14;
case 'f':
return 15;
} }
return 0;
return result;
} }
/* /*
...@@ -118,106 +76,37 @@ static int htoi(char c) ...@@ -118,106 +76,37 @@ static int htoi(char c)
*/ */
void uuid_uuid_from_string(IN char *pszUuid, OUT struct dsp_uuid *uuid_obj) void uuid_uuid_from_string(IN char *pszUuid, OUT struct dsp_uuid *uuid_obj)
{ {
char c; s32 j;
s32 i, j;
s32 result;
char *temp = pszUuid;
result = 0; uuid_obj->ul_data1 = uuid_hex_to_bin(pszUuid, 8);
for (i = 0; i < 8; i++) { pszUuid += 8;
/* Get first character in string */
c = *temp;
/* Increase the results by new value */
result *= 16;
result += htoi(c);
/* Go to next character in string */
temp++;
}
uuid_obj->ul_data1 = result;
/* Step over underscore */ /* Step over underscore */
temp++; pszUuid++;
result = 0; uuid_obj->us_data2 = (u16) uuid_hex_to_bin(pszUuid, 4);
for (i = 0; i < 4; i++) { pszUuid += 4;
/* Get first character in string */
c = *temp;
/* Increase the results by new value */
result *= 16;
result += htoi(c);
/* Go to next character in string */
temp++;
}
uuid_obj->us_data2 = (u16) result;
/* Step over underscore */ /* Step over underscore */
temp++; pszUuid++;
result = 0;
for (i = 0; i < 4; i++) {
/* Get first character in string */
c = *temp;
/* Increase the results by new value */ uuid_obj->us_data3 = (u16) uuid_hex_to_bin(pszUuid, 4);
result *= 16; pszUuid += 4;
result += htoi(c);
/* Go to next character in string */
temp++;
}
uuid_obj->us_data3 = (u16) result;
/* Step over underscore */ /* Step over underscore */
temp++; pszUuid++;
result = 0;
for (i = 0; i < 2; i++) {
/* Get first character in string */
c = *temp;
/* Increase the results by new value */ uuid_obj->uc_data4 = (u8) uuid_hex_to_bin(pszUuid, 2);
result *= 16; pszUuid += 2;
result += htoi(c);
/* Go to next character in string */ uuid_obj->uc_data5 = (u8) uuid_hex_to_bin(pszUuid, 2);
temp++; pszUuid += 2;
}
uuid_obj->uc_data4 = (u8) result;
result = 0;
for (i = 0; i < 2; i++) {
/* Get first character in string */
c = *temp;
/* Increase the results by new value */
result *= 16;
result += htoi(c);
/* Go to next character in string */
temp++;
}
uuid_obj->uc_data5 = (u8) result;
/* Step over underscore */ /* Step over underscore */
temp++; pszUuid++;
for (j = 0; j < 6; j++) { for (j = 0; j < 6; j++) {
result = 0; uuid_obj->uc_data6[j] = (u8) uuid_hex_to_bin(pszUuid, 2);
for (i = 0; i < 2; i++) { pszUuid += 2;
/* Get first character in string */
c = *temp;
/* Increase the results by new value */
result *= 16;
result += htoi(c);
/* Go to next character in string */
temp++;
}
uuid_obj->uc_data6[j] = (u8) result;
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment