regulator: add a new API regulator_set_voltage_tol()
authorShawn Guo <shawn.guo@linaro.org>
Sun, 5 Aug 2012 15:05:20 +0000 (23:05 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 8 Aug 2012 13:34:41 +0000 (14:34 +0100)
There are some use cases where a voltage range could be reasonably
specified by a target voltage and tolerance.  Add a new API
regulator_set_voltage_tol() wrapping regulator_set_voltage() call
to ease the users.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
include/linux/regulator/consumer.h

index da339fd8c7559de74ad46dd3536f4b95981c89d8..21603524bdb2a218dc921751b12d0d6dcf8f3666 100644 (file)
@@ -352,4 +352,11 @@ static inline void regulator_set_drvdata(struct regulator *regulator,
 
 #endif
 
+static inline int regulator_set_voltage_tol(struct regulator *regulator,
+                                           int new_uV, int tol_uV)
+{
+       return regulator_set_voltage(regulator,
+                                    new_uV - tol_uV, new_uV + tol_uV);
+}
+
 #endif