diff mbox

dspbridge: Simplify Atoi() method

Message ID 1265192086-15633-1-git-send-email-andy.shevchenko@gmail.com (mailing list archive)
State Not Applicable
Delegated to:
Headers show

Commit Message

Andy Shevchenko Feb. 3, 2010, 10:14 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/dsp/bridge/rmgr/dbdcd.c b/drivers/dsp/bridge/rmgr/dbdcd.c
index caa57f1..fe2ed57 100644
--- a/drivers/dsp/bridge/rmgr/dbdcd.c
+++ b/drivers/dsp/bridge/rmgr/dbdcd.c
@@ -1002,50 +1002,20 @@  DSP_STATUS DCD_UnregisterObject(IN struct DSP_UUID *pUuid,
  */
 static s32 Atoi(char *pszBuf)
 {
-	s32 result = 0;
 	char *pch = pszBuf;
-	char c;
-	char first;
-	s32 base = 10;
-	s32 len;
+	s32 base = 0;
 
 	while (isspace(*pch))
 		pch++;
 
-	first = *pch;
-	if (first == '-' || first == '+') {
+	if (*pch == '-' || *pch == '+') {
+		base = 10;
 		pch++;
-	} else {
-		/* Determine if base 10 or base 16 */
-		len = strlen(pch);
-		if (len  > 1) {
-			c = pch[1];
-			if ((*pch == '0' && (c == 'x' || c == 'X'))) {
-				base = 16;
-				pch += 2;
-			}
-			c = pch[len - 1];
-			if (c == 'h' || c == 'H')
-				base = 16;
-
-		}
-	}
-
-	while (isdigit(c = *pch) || ((base == 16) && isxdigit(c))) {
-		result *= base;
-		if ('A' <= c && c <= 'F') {
-			c = c - 'A' + 10;
-		} else {
-			if ('a' <= c && c <= 'f')
-				c = c - 'a' + 10;
-			else
-				c -= '0';
-		}
-		result += c;
-		++pch;
+	} else if (*pch && (pch[strlen(pch) - 1] | 0x20 == 'h')) {
+		base = 16;
 	}
 
-	return result;
+	return simple_strtoul(pch, NULL, base);
 }
 
 /*