mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Mark Brown <broonie@sirena.org.uk>, lrg@slimlogic.co.uk
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [patch 2.6.28-rc7] regulator: catch some registration errors
Date: Mon, 1 Dec 2008 21:50:35 -0800	[thread overview]
Message-ID: <200812012150.36342.david-b@pacbell.net> (raw)
In-Reply-To: <20081201225312.GA6699@sirena.org.uk>

From: David Brownell <dbrownell@users.sourceforge.net>

Prevent registration of duplicate "struct regulator" names.
They'd be unavailable, and clearly indicate something wrong.

Also make sure the consumer device is provided.  It's nonsensical
to omit these, and not a documented part of the interface.  Since
no code in mainline does such stuff, this is just anti-oops medicine.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---
 drivers/regulator/core.c |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -772,9 +772,23 @@ static int set_consumer_device_supply(st
 {
 	struct regulator_map *node;
 
-	if (supply == NULL)
+	if (supply == NULL || !consumer_dev)
 		return -EINVAL;
 
+	list_for_each_entry(node, &regulator_map_list, list) {
+		if (consumer_dev != node->dev)
+			continue;
+		if (strcmp(node->supply, supply) != 0)
+			continue;
+
+		dev_dbg(consumer_dev, "%s/%s is '%s' supply; fail %s/%s\n",
+				dev_name(&node->regulator->dev),
+				node->regulator->desc->name,
+				supply,
+				dev_name(&rdev->dev), rdev->desc->name);
+		return -EBUSY;
+	}
+
 	node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL);
 	if (node == NULL)
 		return -ENOMEM;

  parent reply	other threads:[~2008-12-02  6:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-01 21:35 [patch 2.6.28-rc6+] regulator: bugfixes and messaging cleanup David Brownell
2008-12-01 22:53 ` Mark Brown
2008-12-01 23:58   ` David Brownell
2008-12-02  1:22     ` Mark Brown
2008-12-02  5:50   ` [patch 2.6.28-rc7] regulator: init/link earlier David Brownell
2008-12-02 10:51     ` Mark Brown
2008-12-03 21:45     ` Liam Girdwood
2008-12-02  5:50   ` David Brownell [this message]
2008-12-02 13:32     ` [patch 2.6.28-rc7] regulator: catch some registration errors Mark Brown
2009-01-05 23:45       ` David Brownell
2009-01-06 10:10         ` Mark Brown
2009-01-06 10:21           ` David Brownell
2009-01-06 12:58             ` Mark Brown
2008-12-03 21:48     ` Liam Girdwood
2008-12-04 11:12       ` Mark Brown
2009-01-05 23:45         ` David Brownell
2009-01-06 10:33           ` 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=200812012150.36342.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=broonie@sirena.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@slimlogic.co.uk \
    /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

Powered by JetHome