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; } -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html