lkml.org 
[lkml]   [2008]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[patch 2.6.28-rc7] regulator: catch some registration errors
Date
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;

\
 
 \ /
  Last update: 2008-12-02 07:21    [W:0.055 / U:0.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site