[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200812012150.36342.david-b@pacbell.net>
Date: Mon, 1 Dec 2008 21:50:35 -0800
From: David Brownell <david-b@...bell.net>
To: Mark Brown <broonie@...ena.org.uk>, lrg@...mlogic.co.uk
Cc: lkml <linux-kernel@...r.kernel.org>
Subject: [patch 2.6.28-rc7] regulator: catch some registration errors
From: David Brownell <dbrownell@...rs.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@...rs.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, ®ulator_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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists