From patchwork Wed Feb 10 07:58:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 78293 X-Patchwork-Delegate: omar.ramirez@ti.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1A80daI001732 for ; Wed, 10 Feb 2010 08:00:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752075Ab0BJIAh (ORCPT ); Wed, 10 Feb 2010 03:00:37 -0500 Received: from smtp.nokia.com ([192.100.122.230]:32620 "EHLO mgw-mx03.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752003Ab0BJIAh (ORCPT ); Wed, 10 Feb 2010 03:00:37 -0500 Received: from esebh106.NOE.Nokia.com (esebh106.ntc.nokia.com [172.21.138.213]) by mgw-mx03.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o1A80Xe1012492 for ; Wed, 10 Feb 2010 10:00:34 +0200 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by esebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 10 Feb 2010 10:00:33 +0200 Received: from mgw-da02.ext.nokia.com ([147.243.128.26]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 10 Feb 2010 10:00:33 +0200 Received: from dilbert.research.nokia.com (esdhcp035124.research.nokia.com [172.21.35.124]) by mgw-da02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o1A80Ru5009850 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Wed, 10 Feb 2010 10:00:29 +0200 Received: from andy by dilbert.research.nokia.com with local (Exim 4.69) (envelope-from ) id 1Nf7TO-00073u-2L; Wed, 10 Feb 2010 09:58:58 +0200 From: Andy Shevchenko To: linux-omap Cc: Andy Shevchenko Subject: [PATCH] dspbridge: Simplify Atoi() method (v2) Date: Wed, 10 Feb 2010 09:58:58 +0200 Message-Id: <1265788738-27123-1-git-send-email-andy.shevchenko@gmail.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <4B7213C1.1040300@ti.com> References: <4B7213C1.1040300@ti.com> X-OriginalArrivalTime: 10 Feb 2010 08:00:33.0577 (UTC) FILETIME=[1F1AB190:01CAAA27] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 10 Feb 2010 08:00:40 +0000 (UTC) diff --git a/drivers/dsp/bridge/rmgr/dbdcd.c b/drivers/dsp/bridge/rmgr/dbdcd.c index 9efb7dc..a460d1a 100644 --- a/drivers/dsp/bridge/rmgr/dbdcd.c +++ b/drivers/dsp/bridge/rmgr/dbdcd.c @@ -1001,50 +1001,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 && tolower(pch[strlen(pch) - 1]) == 'h') { + base = 16; } - return result; + return simple_strtoul(pch, NULL, base); } /*