From patchwork Tue Jan 12 12:08:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 72356 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0CC8G2q005343 for ; Tue, 12 Jan 2010 12:08:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751500Ab0ALMIO (ORCPT ); Tue, 12 Jan 2010 07:08:14 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751243Ab0ALMIO (ORCPT ); Tue, 12 Jan 2010 07:08:14 -0500 Received: from mail-yx0-f187.google.com ([209.85.210.187]:38149 "EHLO mail-yx0-f187.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751233Ab0ALMIN (ORCPT ); Tue, 12 Jan 2010 07:08:13 -0500 Received: by yxe17 with SMTP id 17so21262632yxe.33 for ; Tue, 12 Jan 2010 04:08:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=5arRqi4kYVeb6s9tomNeBABLX2+Qb6FrfADtyVfANQc=; b=E6j0bFBl5cZcTzFEG5fJiU4w45DiG0TJswHChriH/c1TAYHSvMMTM+svNYsBleGB9d J3UhAYL4MMaWF08pP8LkQ996JQ7dkUWGVeORFurwYhFDmfGu0X9ARKZygixVSDOLSLKe g+a4dytht2u3laxo769Xgh7mBpFByzhKEFoX8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=nqDW1i63s52VlOv2k9MrtCHp5wzjS3uV8q44oJEkhWmDpX8Jh2qCSO4/AH/j4SX0S0 PG5BBaK7te8+wYUdd4n/MExeXRHxVdqAmibdrLJyKCKi9mswheJHy0H4LgcgbZW0szrG mAAXLnBWx6AK5Q2wDVXOYilMdkFD/F+bM4/Bs= Received: by 10.91.153.1 with SMTP id f1mr3965447ago.21.1263298092245; Tue, 12 Jan 2010 04:08:12 -0800 (PST) Received: from ?192.168.1.3? (cpe-76-184-242-93.tx.res.rr.com [76.184.242.93]) by mx.google.com with ESMTPS id 16sm13027584gxk.11.2010.01.12.04.08.10 (version=SSLv3 cipher=RC4-MD5); Tue, 12 Jan 2010 04:08:11 -0800 (PST) Message-ID: <4B4C6629.2040100@gmail.com> Date: Tue, 12 Jan 2010 06:08:09 -0600 From: Nishanth Menon User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Romit Dasgupta CC: Kevin Hilman , "linux-omap@vger.kernel.org" Subject: Re: [PM-WIP-OPP] [PATCH] cleaner ceil function for uv to vsel conversion References: <1263189218.16324.3.camel@boson> <876378mg2a.fsf@deeprootsystems.com> <4B4C39BB.5090409@ti.com> In-Reply-To: <4B4C39BB.5090409@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/arch/arm/plat-omap/opp_twl_tps.c b/arch/arm/plat-omap/opp_twl_tps.c index e0db39b..43dee2d 100644 --- a/arch/arm/plat-omap/opp_twl_tps.c +++ b/arch/arm/plat-omap/opp_twl_tps.c @@ -36,14 +36,7 @@ unsigned long omap_twl_vsel_to_uv(const u8 vsel) */ u8 omap_twl_uv_to_vsel(unsigned long uv) { - u8 vsel; + /* Takes care of precision loss due to integer division */ + return (((uv + 99) / 100 - 6000) + 124) / 125; - vsel = ((uv / 100) - 6000) / 125; - - /* round off to higher voltage */ - /* XXX Surely not the best way to handle this. */ - if (uv > omap_twl_vsel_to_uv(vsel)) - vsel++; - - return vsel; }