Skip to contentSkip to conversation

OPP layer and additional cleanups.

PATCH In review Romit Dasgupta 2 participants 2 messages Dec 31, 2009 – Jan 4, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/10 OPP layer and additional cleanups.

Cleaner way to take care of the precision loss during integer division.

arch/arm/plat-omap/opp_twl_tps.c +2 -9
index e0db39b..43dee2d 100644
@@ -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;
 }
Acked-by on v1 1/10
#1 lore raw

Dasgupta, Romit had written, on 12/31/2009 07:29 AM, the following:

Quoted 2 lines

Cleaner way to take care of the precision loss during integer division.

please sign-off your patch and fix subject.

Quoted 14 lines
arch/arm/plat-omap/opp_twl_tps.c +2 -1
index e0db39b..43dee2d 100644
@@ -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;

arch/arm/plat-omap/opp_twl_tps.c unsigned long omap_twl_vsel_to_uv(const u8 vsel) · line 42

Quoted 10 lines
arch/arm/plat-omap/opp_twl_tps.c +0 -8
 
-	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.

Signature · 2 lines
Regards,
Nishanth Menon