[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1336962817.24732.1.camel@phoenix>
Date: Mon, 14 May 2012 10:33:37 +0800
From: Axel Lin <axel.lin@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Mark Brown <broonie@...nsource.wolfsonmicro.com>,
Liam Girdwood <lrg@...com>
Subject: [PATCH] regulator: core: Ensure simple linear voltage mappings
falls within the specified range
Integer division may truncate the result.
Use DIV_ROUND_UP to ensure simple linear voltage mappings falls within the
specified range.
Signed-off-by: Axel Lin <axel.lin@...il.com>
---
drivers/regulator/core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 5751f5e..8918271 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2047,7 +2047,7 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev,
return -EINVAL;
}
- ret = (min_uV - rdev->desc->min_uV) / rdev->desc->uV_step;
+ ret = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step);
if (ret < 0)
return ret;
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists