* [PATCH 1/10] OPP layer and additional cleanups.
@ 2009-12-31 13:29 Romit Dasgupta
2010-01-04 22:04 ` Nishanth Menon
0 siblings, 1 reply; 2+ messages in thread
From: Romit Dasgupta @ 2009-12-31 13:29 UTC (permalink / raw)
To: paul, nm, khilman; +Cc: linux-omap@vger.kernel.org
Cleaner way to take care of the precision loss during integer division.
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] 2+ messages in thread
* Re: [PATCH 1/10] OPP layer and additional cleanups.
2009-12-31 13:29 [PATCH 1/10] OPP layer and additional cleanups Romit Dasgupta
@ 2010-01-04 22:04 ` Nishanth Menon
0 siblings, 0 replies; 2+ messages in thread
From: Nishanth Menon @ 2010-01-04 22:04 UTC (permalink / raw)
To: Dasgupta, Romit
Cc: paul@pwsan.com, khilman@deeprootsystems.com,
linux-omap@vger.kernel.org
Dasgupta, Romit had written, on 12/31/2009 07:29 AM, the following:
> Cleaner way to take care of the precision loss during integer division.
>
please sign-off your patch and fix subject.
>
> 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;
> }
>
>
Nice, thanks.
Acked-by: Nishanth Menon <nm@ti.com>
--
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-01-04 22:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-31 13:29 [PATCH 1/10] OPP layer and additional cleanups Romit Dasgupta
2010-01-04 22:04 ` Nishanth Menon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox