[PATCH 2/5] regulator: add function to determine if a regulator is in bypass mode

From: Tim Harvey
Date: Fri Oct 31 2014 - 00:28:21 EST


Regulators can be configured to allow bypass mode and can be told by a consumer
that they are allowed to go into bypass mode from that consumer's perspective.
This adds a function to determine if the regulator actually has gone into
bypass mode (meaning all consumers allowed it to do so).

Cc: linux-pm@xxxxxxxxxxxxxxx
Signed-off-by: Tim Harvey <tharvey@xxxxxxxxxxxxx>
---
drivers/regulator/core.c | 23 +++++++++++++++++++++++
include/linux/regulator/consumer.h | 6 ++++++
2 files changed, 29 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 6d4a627..904c271 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3150,6 +3150,29 @@ int regulator_allow_bypass(struct regulator *regulator, bool enable)
EXPORT_SYMBOL_GPL(regulator_allow_bypass);

/**
+ * regulator_is_bypass - determine if a regulator is in bypass mode
+ *
+ * @regulator: Regulator to configure
+ *
+ * return positive if regulator is in bypass mode.
+ */
+int regulator_is_bypass(struct regulator *regulator)
+{
+ struct regulator_dev *rdev = regulator->rdev;
+ int ret;
+
+ if (!regulator)
+ return -EINVAL;
+
+ mutex_lock(&rdev->mutex);
+ ret = regulator->bypass ? 1 : 0;
+ mutex_unlock(&rdev->mutex);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(regulator_is_bypass);
+
+/**
* regulator_register_notifier - register regulator event notifier
* @regulator: regulator source
* @nb: notifier block
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 972090a..a766946 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -237,6 +237,7 @@ unsigned int regulator_get_mode(struct regulator *regulator);
int regulator_set_optimum_mode(struct regulator *regulator, int load_uA);

int regulator_allow_bypass(struct regulator *regulator, bool allow);
+int regulator_is_bypass(struct regulator *regulator);

struct regmap *regulator_get_regmap(struct regulator *regulator);
int regulator_get_hardware_vsel_register(struct regulator *regulator,
@@ -493,6 +494,11 @@ static inline int regulator_allow_bypass(struct regulator *regulator,
return 0;
}

+static inline int regulator_is_bypass(struct regulator *regulator)
+{
+ return 0;
+}
+
static inline struct regmap *regulator_get_regmap(struct regulator *regulator)
{
return ERR_PTR(-EOPNOTSUPP);
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/