From patchwork Wed Feb 3 10:14:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 76674 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 o13AHADx032680 for ; Wed, 3 Feb 2010 10:17:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932417Ab0BCKRJ (ORCPT ); Wed, 3 Feb 2010 05:17:09 -0500 Received: from smtp.nokia.com ([192.100.105.134]:56557 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932276Ab0BCKRH (ORCPT ); Wed, 3 Feb 2010 05:17:07 -0500 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o13AGkGv014060 for ; Wed, 3 Feb 2010 04:17:04 -0600 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 3 Feb 2010 12:16:15 +0200 Received: from mgw-da02.ext.nokia.com ([147.243.128.26]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 3 Feb 2010 12:16:07 +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 o13AG1uJ021568 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Wed, 3 Feb 2010 12:16:03 +0200 Received: from andy by dilbert.research.nokia.com with local (Exim 4.69) (envelope-from ) id 1NccFy-00044Y-5l; Wed, 03 Feb 2010 12:14:46 +0200 From: Andy Shevchenko To: linux-omap Cc: Andy Shevchenko Subject: [PATCH] dspbridge: Simplify Atoi() method Date: Wed, 3 Feb 2010 12:14:46 +0200 Message-Id: <1265192086-15633-1-git-send-email-andy.shevchenko@gmail.com> X-Mailer: git-send-email 1.5.6.5 X-OriginalArrivalTime: 03 Feb 2010 10:16:07.0858 (UTC) FILETIME=[E69F3920:01CAA4B9] 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, 03 Feb 2010 10:17:10 +0000 (UTC) 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); } /*