Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1573473 > unrolled thread

[PATCH 1/5] regulator: core: remove dead code in _regulator_get()

Started byDmitry Torokhov <dmitry.torokhov@gmail.com>
First post2017-02-03 23:00 +0100
Last post2017-02-04 11:50 +0100
Articles 10 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/5] regulator: core: remove dead code in _regulator_get() Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-02-03 23:00 +0100
    [PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-02-03 23:00 +0100
      Re: [PATCH 5/5] regulator: core: lower severity level of message  about using dummy supplies Mark Brown <broonie@kernel.org> - 2017-02-04 12:50 +0100
        Re: [PATCH 5/5] regulator: core: lower severity level of message  about using dummy supplies Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-02-04 18:50 +0100
          Re: [PATCH 5/5] regulator: core: lower severity level of message  about using dummy supplies Mark Brown <broonie@kernel.org> - 2017-02-05 17:20 +0100
            Re: [PATCH 5/5] regulator: core: lower severity level of message  about using dummy supplies Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-02-07 02:00 +0100
              Re: [PATCH 5/5] regulator: core: lower severity level of message  about using dummy supplies Mark Brown <broonie@kernel.org> - 2017-02-08 19:20 +0100
    [PATCH 3/5] regulator: core: have _regulator_get() accept get_type argument Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-02-03 23:00 +0100
      Applied "regulator: core: have _regulator_get() accept get_type argument" to the regulator tree Mark Brown <broonie@kernel.org> - 2017-02-04 11:50 +0100
    Applied "regulator: core: remove dead code in _regulator_get()" to the regulator tree Mark Brown <broonie@kernel.org> - 2017-02-04 11:50 +0100

#1573473 — [PATCH 1/5] regulator: core: remove dead code in _regulator_get()

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2017-02-03 23:00 +0100
Subject[PATCH 1/5] regulator: core: remove dead code in _regulator_get()
Message-ID<t6U3D-7uQ-13@gated-at.bofh.it>
There is no point in assigning value to 'ret' before calling
regulator_dev_lookup() as it will clobber 'ret' anyway.

Also, let's explicitly return -PROBE_DEFER when try_module_get() fails,
instead of relying that earlier initialization of "regulator" carries
correct value.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/regulator/core.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 04baac9a165b..b0ee068310c5 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1584,7 +1584,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
 					bool exclusive, bool allow_dummy)
 {
 	struct regulator_dev *rdev;
-	struct regulator *regulator = ERR_PTR(-EPROBE_DEFER);
+	struct regulator *regulator;
 	const char *devname = NULL;
 	int ret;
 
@@ -1596,11 +1596,6 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
 	if (dev)
 		devname = dev_name(dev);
 
-	if (have_full_constraints())
-		ret = -ENODEV;
-	else
-		ret = -EPROBE_DEFER;
-
 	rdev = regulator_dev_lookup(dev, id, &ret);
 	if (rdev)
 		goto found;
@@ -1656,6 +1651,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
 	}
 
 	if (!try_module_get(rdev->owner)) {
+		regulator = ERR_PTR(-EPROBE_DEFER);
 		put_device(&rdev->dev);
 		return regulator;
 	}
-- 
2.11.0.483.g087da7b7c-goog

[toc] | [next] | [standalone]


#1573474 — [PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2017-02-03 23:00 +0100
Subject[PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies
Message-ID<t6U3E-7uQ-25@gated-at.bofh.it>
In reply to#1573473
Use of dummy supplies is normal and common occurrence in the kernel, let's
lower severity from warning to info.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/regulator/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e39bb2d41038..1d3aff7e2bb1 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1622,7 +1622,7 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
 			 * enabled, even if it isn't hooked up, and just
 			 * provide a dummy.
 			 */
-			dev_warn(dev,
+			dev_info(dev,
 				 "%s supply %s not found, using dummy regulator\n",
 				 devname, id);
 			rdev = dummy_regulator_rdev;
-- 
2.11.0.483.g087da7b7c-goog

[toc] | [prev] | [next] | [standalone]


#1573660 — Re: [PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies

FromMark Brown <broonie@kernel.org>
Date2017-02-04 12:50 +0100
SubjectRe: [PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies
Message-ID<t770R-8ii-13@gated-at.bofh.it>
In reply to#1573474

[Multipart message — attachments visible in raw view] — view raw

On Fri, Feb 03, 2017 at 01:56:04PM -0800, Dmitry Torokhov wrote:
> Use of dummy supplies is normal and common occurrence in the kernel, let's
> lower severity from warning to info.

It really shouldn't be either of these things, at least on DT systems.

[toc] | [prev] | [next] | [standalone]


#1573720 — Re: [PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2017-02-04 18:50 +0100
SubjectRe: [PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies
Message-ID<t7cDf-3QH-1@gated-at.bofh.it>
In reply to#1573660
On Sat, Feb 04, 2017 at 12:48:19PM +0100, Mark Brown wrote:
> On Fri, Feb 03, 2017 at 01:56:04PM -0800, Dmitry Torokhov wrote:
> > Use of dummy supplies is normal and common occurrence in the kernel, let's
> > lower severity from warning to info.
> 
> It really shouldn't be either of these things, at least on DT systems.

But it definitely happens on ACPI systems for drivers for peripherals
that we share between both x86 and ARM.

-- 
Dmitry

[toc] | [prev] | [next] | [standalone]


#1573924 — Re: [PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies

FromMark Brown <broonie@kernel.org>
Date2017-02-05 17:20 +0100
SubjectRe: [PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies
Message-ID<t7xHJ-1ay-45@gated-at.bofh.it>
In reply to#1573720

[Multipart message — attachments visible in raw view] — view raw

On Sat, Feb 04, 2017 at 09:45:02AM -0800, Dmitry Torokhov wrote:
> On Sat, Feb 04, 2017 at 12:48:19PM +0100, Mark Brown wrote:

> > It really shouldn't be either of these things, at least on DT systems.

> But it definitely happens on ACPI systems for drivers for peripherals
> that we share between both x86 and ARM.

Something that makes the warning informational only on ACPI systems
would be fine.

[toc] | [prev] | [next] | [standalone]


#1575289 — Re: [PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2017-02-07 02:00 +0100
SubjectRe: [PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies
Message-ID<t82it-3XP-1@gated-at.bofh.it>
In reply to#1573924
On Sun, Feb 05, 2017 at 05:12:46PM +0100, Mark Brown wrote:
> On Sat, Feb 04, 2017 at 09:45:02AM -0800, Dmitry Torokhov wrote:
> > On Sat, Feb 04, 2017 at 12:48:19PM +0100, Mark Brown wrote:
> 
> > > It really shouldn't be either of these things, at least on DT systems.
> 
> > But it definitely happens on ACPI systems for drivers for peripherals
> > that we share between both x86 and ARM.
> 
> Something that makes the warning informational only on ACPI systems
> would be fine.

I can definitely select the severity based on acpi_disabled flag, but I
think you should reconsider: from what I have seen in the kernel quite a
few driversi, even OF-specific ones, select regulator_get_optional() for
no good reason other than to avoid this "scary" warning. If its severity
were reduced quite a few drivers could be switched to normal
regulator_get().

Candidates for conversion (not complete, just examples):

drivers/input/touchscreen/zforce_ts.c
drivers/input/touchscreen/tsc200x-core.c
drivers/power/avs/rockchip-io-domain.c
drivers/mfd/stmpe.c

... and more...

Thanks.

-- 
Dmitry

[toc] | [prev] | [next] | [standalone]


#1576799 — Re: [PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies

FromMark Brown <broonie@kernel.org>
Date2017-02-08 19:20 +0100
SubjectRe: [PATCH 5/5] regulator: core: lower severity level of message about using dummy supplies
Message-ID<t8F0u-3Hv-17@gated-at.bofh.it>
In reply to#1575289

[Multipart message — attachments visible in raw view] — view raw

On Mon, Feb 06, 2017 at 04:56:55PM -0800, Dmitry Torokhov wrote:

> I can definitely select the severity based on acpi_disabled flag, but I
> think you should reconsider: from what I have seen in the kernel quite a
> few driversi, even OF-specific ones, select regulator_get_optional() for
> no good reason other than to avoid this "scary" warning. If its severity
> were reduced quite a few drivers could be switched to normal
> regulator_get().

We had problems with people writing obviously problematic code long
before we had the warning (or optional regulators), I'm really
unconvinced that the warning has anything much to do with it.  There
will also be some code that predates dummy regulators, or where that
support was new enough that people weren't aware of it.  We get exactly
the same sort of problem with people writing constraints that are clear
nonsense (things like a supply named with a specific voltage but a large
voltage range).

> Candidates for conversion (not complete, just examples):

> drivers/input/touchscreen/zforce_ts.c
> drivers/input/touchscreen/tsc200x-core.c

These are broken, yes.  The zforce code at least is old enough that it
might predate dummy supplies.

> drivers/power/avs/rockchip-io-domain.c

This clearly cares about the voltages and could never work with a dummy
regulator, it is potentially a good use of optional supplies as far as I
can see (though I'm unsure about what an I/O domain without a reference
supply would mean).

> drivers/mfd/stmpe.c

This is again just obviously not good, it just logs but doesn't act on a
failure to enable the power supplies.

[toc] | [prev] | [next] | [standalone]


#1573478 — [PATCH 3/5] regulator: core: have _regulator_get() accept get_type argument

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2017-02-03 23:00 +0100
Subject[PATCH 3/5] regulator: core: have _regulator_get() accept get_type argument
Message-ID<t6U3E-7uQ-27@gated-at.bofh.it>
In reply to#1573473
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>
---
 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 25aca2096ac9..e495767fee85 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);
@@ -1617,7 +1622,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);
 
@@ -1625,7 +1630,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");
 	}
 
@@ -1638,7 +1643,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;
@@ -1666,7 +1671,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);
@@ -1694,7 +1699,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);
 
@@ -1721,7 +1726,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);
 
@@ -1747,7 +1752,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.483.g087da7b7c-goog

[toc] | [prev] | [next] | [standalone]


#1573645 — Applied "regulator: core: have _regulator_get() accept get_type argument" to the regulator tree

FromMark Brown <broonie@kernel.org>
Date2017-02-04 11:50 +0100
SubjectApplied "regulator: core: have _regulator_get() accept get_type argument" to the regulator tree
Message-ID<t764N-7Fv-1@gated-at.bofh.it>
In reply to#1573478
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

[toc] | [prev] | [next] | [standalone]


#1573648 — Applied "regulator: core: remove dead code in _regulator_get()" to the regulator tree

FromMark Brown <broonie@kernel.org>
Date2017-02-04 11:50 +0100
SubjectApplied "regulator: core: remove dead code in _regulator_get()" to the regulator tree
Message-ID<t764O-7Fv-11@gated-at.bofh.it>
In reply to#1573473
The patch

   regulator: core: remove dead code in _regulator_get()

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 7d245afa24b3ed911f6fd90079d70932ac5e5923 Mon Sep 17 00:00:00 2001
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: Fri, 3 Feb 2017 13:56:00 -0800
Subject: [PATCH] regulator: core: remove dead code in _regulator_get()

There is no point in assigning value to 'ret' before calling
regulator_dev_lookup() as it will clobber 'ret' anyway.

Also, let's explicitly return -PROBE_DEFER when try_module_get() fails,
instead of relying that earlier initialization of "regulator" carries
correct value.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/core.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 04baac9a165b..b0ee068310c5 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1584,7 +1584,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
 					bool exclusive, bool allow_dummy)
 {
 	struct regulator_dev *rdev;
-	struct regulator *regulator = ERR_PTR(-EPROBE_DEFER);
+	struct regulator *regulator;
 	const char *devname = NULL;
 	int ret;
 
@@ -1596,11 +1596,6 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
 	if (dev)
 		devname = dev_name(dev);
 
-	if (have_full_constraints())
-		ret = -ENODEV;
-	else
-		ret = -EPROBE_DEFER;
-
 	rdev = regulator_dev_lookup(dev, id, &ret);
 	if (rdev)
 		goto found;
@@ -1656,6 +1651,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
 	}
 
 	if (!try_module_get(rdev->owner)) {
+		regulator = ERR_PTR(-EPROBE_DEFER);
 		put_device(&rdev->dev);
 		return regulator;
 	}
-- 
2.11.0

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web