* [PM-WIP-OPP] [PATCH] cleaner ceil function for uv to vsel conversion
@ 2010-01-11 5:53 Romit Dasgupta
2010-01-11 22:29 ` Kevin Hilman
0 siblings, 1 reply; 5+ messages in thread
From: Romit Dasgupta @ 2010-01-11 5:53 UTC (permalink / raw)
To: khilman; +Cc: nm, linux-omap
Cleaner ceil function.
Signed-off-by: Romit Dasgupta <romit@ti.com>
---
diff --git a/arch/arm/plat-omap/opp_twl_tps.c b/arch/arm/plat-omap/opp_twl_tps.c
index e0db39b..1caa414 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;
- vsel = ((uv / 100) - 6000) / 125;
+ return (((uv + 99) / 100 - 6000) + 124) / 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;
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PM-WIP-OPP] [PATCH] cleaner ceil function for uv to vsel conversion
2010-01-11 5:53 [PM-WIP-OPP] [PATCH] cleaner ceil function for uv to vsel conversion Romit Dasgupta
@ 2010-01-11 22:29 ` Kevin Hilman
2010-01-12 8:58 ` Romit Dasgupta
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Hilman @ 2010-01-11 22:29 UTC (permalink / raw)
To: romit; +Cc: nm, linux-omap
Romit Dasgupta <romit@ti.com> writes:
> Cleaner ceil function.
Needs better subject and better changelog.
Subject should probably be something like: OMAP:
[PATCH] OPP: TWL/TPS: optimize uv to vsel function
And changelog should describe the motiviation for the patch or a
description of the problem you're trying to solve. IOW, is this a
correctness fix, or an optimization, etc. Looks to me like it's tring
to compensate for some rounding issues, but please describe in detail
in the changelog.
Thanks,
Kevin
> Signed-off-by: Romit Dasgupta <romit@ti.com>
> ---
> diff --git a/arch/arm/plat-omap/opp_twl_tps.c b/arch/arm/plat-omap/opp_twl_tps.c
> index e0db39b..1caa414 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;
>
> - vsel = ((uv / 100) - 6000) / 125;
> + return (((uv + 99) / 100 - 6000) + 124) / 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;
> }
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PM-WIP-OPP] [PATCH] cleaner ceil function for uv to vsel conversion
2010-01-11 22:29 ` Kevin Hilman
@ 2010-01-12 8:58 ` Romit Dasgupta
2010-01-12 12:08 ` Nishanth Menon
0 siblings, 1 reply; 5+ messages in thread
From: Romit Dasgupta @ 2010-01-12 8:58 UTC (permalink / raw)
To: Kevin Hilman; +Cc: Menon, Nishanth, linux-omap@vger.kernel.org
Kevin Hilman wrote:
> Romit Dasgupta <romit@ti.com> writes:
>
>> Cleaner ceil function.
>
> Needs better subject and better changelog.
>
> Subject should probably be something like: OMAP:
>
> [PATCH] OPP: TWL/TPS: optimize uv to vsel function
>
> And changelog should describe the motiviation for the patch or a
> description of the problem you're trying to solve.
The description of the problem is "Cleaner ceil function for uv to vsel
conversion".
I think this patch is simple enough for people on this list to understand the
optimization. I am sorry I cant be more descriptive.
> IOW, is this a
> correctness fix, or an optimization, etc. Looks to me like it's tring
> to compensate for some rounding issues, but please describe in detail
> in the changelog.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PM-WIP-OPP] [PATCH] cleaner ceil function for uv to vsel conversion
2010-01-12 8:58 ` Romit Dasgupta
@ 2010-01-12 12:08 ` Nishanth Menon
2010-01-12 12:13 ` Romit Dasgupta
0 siblings, 1 reply; 5+ messages in thread
From: Nishanth Menon @ 2010-01-12 12:08 UTC (permalink / raw)
To: Romit Dasgupta; +Cc: Kevin Hilman, linux-omap@vger.kernel.org
Romit Dasgupta said the following on 01/12/2010 02:58 AM:
> Kevin Hilman wrote:
>
>> Romit Dasgupta <romit@ti.com> writes:
>>
>>
>>> Cleaner ceil function.
>>>
>> Needs better subject and better changelog.
>>
>> Subject should probably be something like: OMAP:
>>
>> [PATCH] OPP: TWL/TPS: optimize uv to vsel function
>>
>> And changelog should describe the motiviation for the patch or a
>> description of the problem you're trying to solve.
>>
> The description of the problem is "Cleaner ceil function for uv to vsel
> conversion".
>
> I think this patch is simple enough for people on this list to understand the
> optimization. I am sorry I cant be more descriptive.
>
>
here is a try:
-----
From patchwork Thu Dec 31 13:29:05 2009
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [pm-wip-opp] [PATCH] opp: twl/tps: optimize uv to vsel function
Date: Thu, 31 Dec 2009 13:29:05 -0000
From: Dasgupta, Romit <romit@ti.com>
X-Patchwork-Id: 70374
For integer values x and y; int div x / y causes truncation. Current
omap_twl_uv_to_vsel function implements an equivalent of ceil which
is based on an if condition to check truncation and round up.
We can do this in a more optimal manner without the if condition.
The round up is handled by adding the round off factor prior to
truncation as:
(x + (y - 1)) / y
---
Currently putting signed-off in --- section. If Romit is ok, please
re-send as needed.
Signed-off-by: Dasgupta, Romit <romit@ti.com>
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;
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PM-WIP-OPP] [PATCH] cleaner ceil function for uv to vsel conversion
2010-01-12 12:08 ` Nishanth Menon
@ 2010-01-12 12:13 ` Romit Dasgupta
0 siblings, 0 replies; 5+ messages in thread
From: Romit Dasgupta @ 2010-01-12 12:13 UTC (permalink / raw)
To: Nishanth Menon; +Cc: Kevin Hilman, linux-omap@vger.kernel.org
>> The description of the problem is "Cleaner ceil function for uv to vsel
>> conversion".
>>
>> I think this patch is simple enough for people on this list to understand the
>> optimization. I am sorry I cant be more descriptive.
>>
>>
> here is a try:
> -----
>
> From patchwork Thu Dec 31 13:29:05 2009
> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [pm-wip-opp] [PATCH] opp: twl/tps: optimize uv to vsel function
> Date: Thu, 31 Dec 2009 13:29:05 -0000
> From: Dasgupta, Romit <romit@ti.com>
> X-Patchwork-Id: 70374
>
>
> For integer values x and y; int div x / y causes truncation. Current
> omap_twl_uv_to_vsel function implements an equivalent of ceil which
> is based on an if condition to check truncation and round up.
> We can do this in a more optimal manner without the if condition.
> The round up is handled by adding the round off factor prior to
> truncation as:
> (x + (y - 1)) / y
>
Wow that is nice... Please send it if you can and add your Signed-off for the work!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-01-12 12:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-11 5:53 [PM-WIP-OPP] [PATCH] cleaner ceil function for uv to vsel conversion Romit Dasgupta
2010-01-11 22:29 ` Kevin Hilman
2010-01-12 8:58 ` Romit Dasgupta
2010-01-12 12:08 ` Nishanth Menon
2010-01-12 12:13 ` Romit Dasgupta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox