linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Mark Brown <broonie@kernel.org>, Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	linux-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Applied "regulator: core: have _regulator_get() accept get_type argument" to the regulator tree
Date: Sat, 04 Feb 2017 11:48:10 +0100	[thread overview]
Message-ID: <E1cZxt4-0000c4-Tj@finisterre> (raw)
In-Reply-To: <20170203215604.23285-3-dmitry.torokhov@gmail.com>

The patch

   regulator: core: have _regulator_get() accept get_type argument

has been applied to the regulator tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From a8bd42a97741aefa5942605fa87418fc8a6c4169 Mon Sep 17 00:00:00 2001
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Fri, 3 Feb 2017 13:56:02 -0800
Subject: [PATCH] regulator: core: have _regulator_get() accept get_type
 argument

Instead of separate "exclusive" and "allow_dummy" arguments, that formed 3
valid combinations (normal, exclusive and optional) and an invalid one,
let's accept explicit "get_type", like we did in devm-managed code.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/core.c     | 23 ++++++++++++++---------
 drivers/regulator/devres.c   | 21 +--------------------
 drivers/regulator/internal.h | 10 ++++++++++
 3 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index b0ee068310c5..206c274c0003 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1580,14 +1580,19 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
 }
 
 /* Internal regulator request function */
-static struct regulator *_regulator_get(struct device *dev, const char *id,
-					bool exclusive, bool allow_dummy)
+struct regulator *_regulator_get(struct device *dev, const char *id,
+				 enum regulator_get_type get_type)
 {
 	struct regulator_dev *rdev;
 	struct regulator *regulator;
 	const char *devname = NULL;
 	int ret;
 
+	if (get_type >= MAX_GET_TYPE) {
+		dev_err(dev, "invalid type %d in %s\n", get_type, __func__);
+		return ERR_PTR(-EINVAL);
+	}
+
 	if (id == NULL) {
 		pr_err("get() with no identifier\n");
 		return ERR_PTR(-EINVAL);
@@ -1616,7 +1621,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
 	 * Assume that a regulator is physically present and enabled
 	 * even if it isn't hooked up and just provide a dummy.
 	 */
-	if (have_full_constraints() && allow_dummy) {
+	if (have_full_constraints() && get_type == NORMAL_GET) {
 		pr_warn("%s supply %s not found, using dummy regulator\n",
 			devname, id);
 
@@ -1624,7 +1629,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
 		get_device(&rdev->dev);
 		goto found;
 	/* Don't log an error when called from regulator_get_optional() */
-	} else if (!have_full_constraints() || exclusive) {
+	} else if (!have_full_constraints() || get_type == EXCLUSIVE_GET) {
 		dev_warn(dev, "dummy supplies not allowed\n");
 	}
 
@@ -1637,7 +1642,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
 		return regulator;
 	}
 
-	if (exclusive && rdev->open_count) {
+	if (get_type == EXCLUSIVE_GET && rdev->open_count) {
 		regulator = ERR_PTR(-EBUSY);
 		put_device(&rdev->dev);
 		return regulator;
@@ -1665,7 +1670,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
 	}
 
 	rdev->open_count++;
-	if (exclusive) {
+	if (get_type == EXCLUSIVE_GET) {
 		rdev->exclusive = 1;
 
 		ret = _regulator_is_enabled(rdev);
@@ -1693,7 +1698,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
  */
 struct regulator *regulator_get(struct device *dev, const char *id)
 {
-	return _regulator_get(dev, id, false, true);
+	return _regulator_get(dev, id, NORMAL_GET);
 }
 EXPORT_SYMBOL_GPL(regulator_get);
 
@@ -1720,7 +1725,7 @@ EXPORT_SYMBOL_GPL(regulator_get);
  */
 struct regulator *regulator_get_exclusive(struct device *dev, const char *id)
 {
-	return _regulator_get(dev, id, true, false);
+	return _regulator_get(dev, id, EXCLUSIVE_GET);
 }
 EXPORT_SYMBOL_GPL(regulator_get_exclusive);
 
@@ -1746,7 +1751,7 @@ EXPORT_SYMBOL_GPL(regulator_get_exclusive);
  */
 struct regulator *regulator_get_optional(struct device *dev, const char *id)
 {
-	return _regulator_get(dev, id, false, false);
+	return _regulator_get(dev, id, OPTIONAL_GET);
 }
 EXPORT_SYMBOL_GPL(regulator_get_optional);
 
diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c
index 6ec1d400adae..965d1d31ec8c 100644
--- a/drivers/regulator/devres.c
+++ b/drivers/regulator/devres.c
@@ -19,12 +19,6 @@
 
 #include "internal.h"
 
-enum {
-	NORMAL_GET,
-	EXCLUSIVE_GET,
-	OPTIONAL_GET,
-};
-
 static void devm_regulator_release(struct device *dev, void *res)
 {
 	regulator_put(*(struct regulator **)res);
@@ -39,20 +33,7 @@ static struct regulator *_devm_regulator_get(struct device *dev, const char *id,
 	if (!ptr)
 		return ERR_PTR(-ENOMEM);
 
-	switch (get_type) {
-	case NORMAL_GET:
-		regulator = regulator_get(dev, id);
-		break;
-	case EXCLUSIVE_GET:
-		regulator = regulator_get_exclusive(dev, id);
-		break;
-	case OPTIONAL_GET:
-		regulator = regulator_get_optional(dev, id);
-		break;
-	default:
-		regulator = ERR_PTR(-EINVAL);
-	}
-
+	regulator = _regulator_get(dev, id, get_type);
 	if (!IS_ERR(regulator)) {
 		*ptr = regulator;
 		devres_add(dev, ptr);
diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h
index c74ac8734023..1dd575b28564 100644
--- a/drivers/regulator/internal.h
+++ b/drivers/regulator/internal.h
@@ -51,4 +51,14 @@ regulator_of_get_init_data(struct device *dev,
 }
 #endif
 
+enum regulator_get_type {
+	NORMAL_GET,
+	EXCLUSIVE_GET,
+	OPTIONAL_GET,
+	MAX_GET_TYPE
+};
+
+struct regulator *_regulator_get(struct device *dev, const char *id,
+				 enum regulator_get_type get_type);
+
 #endif
-- 
2.11.0

  reply	other threads:[~2017-02-04 10:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-03 21:56 [PATCH 1/5] regulator: core: remove dead code in _regulator_get() Dmitry Torokhov
2017-02-03 21:56 ` [PATCH 2/5] regulator: core: have regulator_dev_lookup() return ERR_PTR-encoded errors Dmitry Torokhov
2017-02-04 10:11   ` Mark Brown
2017-02-04 18:19     ` [PATCH v2 " Dmitry Torokhov
2017-02-05 14:49       ` Mark Brown
2017-02-05 23:49       ` Mark Brown
2017-02-06 13:37       ` Applied "regulator: core: have regulator_dev_lookup() return ERR_PTR-encoded errors" to the regulator tree Mark Brown
2017-02-03 21:56 ` [PATCH 3/5] regulator: core: have _regulator_get() accept get_type argument Dmitry Torokhov
2017-02-04 10:48   ` Mark Brown [this message]
2017-02-03 21:56 ` [PATCH 4/5] regulator: core: simplify _regulator_get() Dmitry Torokhov
2017-02-04 10:34   ` Mark Brown
2017-02-04 18:27     ` Dmitry Torokhov
2017-02-05 16:08       ` Mark Brown
2017-02-08 18:34   ` Applied "regulator: core: simplify _regulator_get()" to the regulator tree Mark Brown
2017-02-03 21:56 ` [PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies Dmitry Torokhov
2017-02-04 11:48   ` Mark Brown
2017-02-04 17:45     ` Dmitry Torokhov
2017-02-05 16:12       ` Mark Brown
2017-02-07  0:56         ` Dmitry Torokhov
2017-02-08 18:19           ` Mark Brown
2017-02-04 10:48 ` Applied "regulator: core: remove dead code in _regulator_get()" to the regulator tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1cZxt4-0000c4-Tj@finisterre \
    --to=broonie@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).