Messages in this thread Patch in this message | | | From | David Brownell <> | Subject | [patch 2.6.28-rc7] regulator: catch some registration errors | Date | Mon, 1 Dec 2008 21:50:35 -0800 |
| |
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, ®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;
| |