Merge branch 'for-linus' of git://opensource.wolfsonmicro.com/regulator
[pandora-kernel.git] / drivers / regulator / core.c
index d0bde70..67fa2a3 100644 (file)
@@ -1425,7 +1425,7 @@ int regulator_enable(struct regulator *regulator)
        ret = _regulator_enable(rdev);
        mutex_unlock(&rdev->mutex);
 
-       if (ret != 0)
+       if (ret != 0 && rdev->supply)
                regulator_disable(rdev->supply);
 
        return ret;
@@ -1599,13 +1599,18 @@ static void regulator_disable_work(struct work_struct *work)
 int regulator_disable_deferred(struct regulator *regulator, int ms)
 {
        struct regulator_dev *rdev = regulator->rdev;
+       int ret;
 
        mutex_lock(&rdev->mutex);
        rdev->deferred_disables++;
        mutex_unlock(&rdev->mutex);
 
-       return schedule_delayed_work(&rdev->disable_work,
-                                    msecs_to_jiffies(ms));
+       ret = schedule_delayed_work(&rdev->disable_work,
+                                   msecs_to_jiffies(ms));
+       if (ret < 0)
+               return ret;
+       else
+               return 0;
 }
 EXPORT_SYMBOL_GPL(regulator_disable_deferred);
 
@@ -2966,6 +2971,43 @@ void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data)
 }
 EXPORT_SYMBOL_GPL(regulator_get_init_drvdata);
 
+#ifdef CONFIG_DEBUG_FS
+static ssize_t supply_map_read_file(struct file *file, char __user *user_buf,
+                                   size_t count, loff_t *ppos)
+{
+       char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+       ssize_t len, ret = 0;
+       struct regulator_map *map;
+
+       if (!buf)
+               return -ENOMEM;
+
+       list_for_each_entry(map, &regulator_map_list, list) {
+               len = snprintf(buf + ret, PAGE_SIZE - ret,
+                              "%s -> %s.%s\n",
+                              rdev_get_name(map->regulator), map->dev_name,
+                              map->supply);
+               if (len >= 0)
+                       ret += len;
+               if (ret > PAGE_SIZE) {
+                       ret = PAGE_SIZE;
+                       break;
+               }
+       }
+
+       ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+
+       kfree(buf);
+
+       return ret;
+}
+
+static const struct file_operations supply_map_fops = {
+       .read = supply_map_read_file,
+       .llseek = default_llseek,
+};
+#endif
+
 static int __init regulator_init(void)
 {
        int ret;
@@ -2978,6 +3020,10 @@ static int __init regulator_init(void)
                pr_warn("regulator: Failed to create debugfs directory\n");
                debugfs_root = NULL;
        }
+
+       if (IS_ERR(debugfs_create_file("supply_map", 0444, debugfs_root,
+                                      NULL, &supply_map_fops)))
+               pr_warn("regulator: Failed to create supplies debugfs\n");
 #endif
 
        regulator_dummy_init();