* [PATCH] regulator: Add devm_regulator_get_exclusive()
@ 2013-08-25 15:54 Matthias Kaehlcke
2013-08-29 18:39 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Matthias Kaehlcke @ 2013-08-25 15:54 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel
Add a resource managed regulator_get_exclusive()
Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
---
drivers/regulator/core.c | 30 ++++++++++++++++++++++++++++++
include/linux/regulator/consumer.h | 2 ++
2 files changed, 32 insertions(+)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 288c75a..0e8ff09 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1435,6 +1435,36 @@ static void _regulator_put(struct regulator *regulator)
}
/**
+ * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive()
+ * @dev: device for regulator "consumer"
+ * @id: Supply name or regulator ID.
+ *
+ * Managed regulator_get_exclusive(). Regulators returned from this function
+ * are automatically regulator_put() on driver detach. See regulator_get() for
+ * more information.
+ */
+struct regulator *devm_regulator_get_exclusive(struct device *dev,
+ const char *id)
+{
+ struct regulator **ptr, *regulator;
+
+ ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL);
+ if (!ptr)
+ return ERR_PTR(-ENOMEM);
+
+ regulator = _regulator_get(dev, id, 1);
+ if (!IS_ERR(regulator)) {
+ *ptr = regulator;
+ devres_add(dev, ptr);
+ } else {
+ devres_free(ptr);
+ }
+
+ return regulator;
+}
+EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive);
+
+/**
* regulator_put - "free" the regulator source
* @regulator: regulator source
*
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 3a76389..399d4a1 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -137,6 +137,8 @@ struct regulator *__must_check devm_regulator_get(struct device *dev,
const char *id);
struct regulator *__must_check regulator_get_exclusive(struct device *dev,
const char *id);
+struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev,
+ const char *id);
void regulator_put(struct regulator *regulator);
void devm_regulator_put(struct regulator *regulator);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: Add devm_regulator_get_exclusive()
2013-08-25 15:54 [PATCH] regulator: Add devm_regulator_get_exclusive() Matthias Kaehlcke
@ 2013-08-29 18:39 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2013-08-29 18:39 UTC (permalink / raw)
To: Matthias Kaehlcke, Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 256 bytes --]
On Sun, Aug 25, 2013 at 05:54:13PM +0200, Matthias Kaehlcke wrote:
> Add a resource managed regulator_get_exclusive()
>
> Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
Applied, thanks. Though I'm a bit suspicous of exclusive() usage...
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-08-29 18:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-25 15:54 [PATCH] regulator: Add devm_regulator_get_exclusive() Matthias Kaehlcke
2013-08-29 18:39 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.