regulator: Remove ifdefs for debugfs code
[pandora-kernel.git] / drivers / regulator / core.c
index ca86f39..603e39f 100644 (file)
@@ -13,8 +13,6 @@
  *
  */
 
-#define pr_fmt(fmt) "%s: " fmt, __func__
-
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/debugfs.h>
@@ -54,9 +52,7 @@ static LIST_HEAD(regulator_map_list);
 static bool has_full_constraints;
 static bool board_wants_dummy_regulator;
 
-#ifdef CONFIG_DEBUG_FS
 static struct dentry *debugfs_root;
-#endif
 
 /*
  * struct regulator_map
@@ -84,9 +80,7 @@ struct regulator {
        char *supply_name;
        struct device_attribute dev_attr;
        struct regulator_dev *rdev;
-#ifdef CONFIG_DEBUG_FS
        struct dentry *debugfs;
-#endif
 };
 
 static int _regulator_is_enabled(struct regulator_dev *rdev);
@@ -807,6 +801,11 @@ static void print_constraints(struct regulator_dev *rdev)
                count += sprintf(buf + count, "standby");
 
        rdev_info(rdev, "%s\n", buf);
+
+       if ((constraints->min_uV != constraints->max_uV) &&
+           !(constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE))
+               rdev_warn(rdev,
+                         "Voltage range but no REGULATOR_CHANGE_VOLTAGE\n");
 }
 
 static int machine_constraints_voltage(struct regulator_dev *rdev,
@@ -1142,12 +1141,10 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
                        goto attr_err;
        }
 
-#ifdef CONFIG_DEBUG_FS
        regulator->debugfs = debugfs_create_dir(regulator->supply_name,
                                                rdev->debugfs);
-       if (IS_ERR_OR_NULL(regulator->debugfs)) {
+       if (!regulator->debugfs) {
                rdev_warn(rdev, "Failed to create debugfs directory\n");
-               regulator->debugfs = NULL;
        } else {
                debugfs_create_u32("uA_load", 0444, regulator->debugfs,
                                   &regulator->uA_load);
@@ -1156,7 +1153,6 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
                debugfs_create_u32("max_uV", 0444, regulator->debugfs,
                                   &regulator->max_uV);
        }
-#endif
 
        mutex_unlock(&rdev->mutex);
        return regulator;
@@ -1365,9 +1361,7 @@ void regulator_put(struct regulator *regulator)
        mutex_lock(&regulator_list_mutex);
        rdev = regulator->rdev;
 
-#ifdef CONFIG_DEBUG_FS
        debugfs_remove_recursive(regulator->debugfs);
-#endif
 
        /* remove any sysfs entries */
        if (regulator->dev) {
@@ -2394,7 +2388,7 @@ int regulator_bulk_get(struct device *dev, int num_consumers,
        return 0;
 
 err:
-       for (i = 0; i < num_consumers && consumers[i].consumer; i++)
+       while (--i >= 0)
                regulator_put(consumers[i].consumer);
 
        return ret;
@@ -2444,12 +2438,9 @@ int regulator_bulk_enable(int num_consumers,
        return 0;
 
 err:
-       for (i = 0; i < num_consumers; i++)
-               if (consumers[i].ret == 0)
-                       regulator_disable(consumers[i].consumer);
-               else
-                       pr_err("Failed to enable %s: %d\n",
-                              consumers[i].supply, consumers[i].ret);
+       pr_err("Failed to enable %s: %d\n", consumers[i].supply, ret);
+       while (--i >= 0)
+               regulator_disable(consumers[i].consumer);
 
        return ret;
 }
@@ -2463,8 +2454,8 @@ EXPORT_SYMBOL_GPL(regulator_bulk_enable);
  * @return         0 on success, an errno on failure
  *
  * This convenience API allows consumers to disable multiple regulator
- * clients in a single API call.  If any consumers cannot be enabled
- * then any others that were disabled will be disabled again prior to
+ * clients in a single API call.  If any consumers cannot be disabled
+ * then any others that were disabled will be enabled again prior to
  * return.
  */
 int regulator_bulk_disable(int num_consumers,
@@ -2473,7 +2464,7 @@ int regulator_bulk_disable(int num_consumers,
        int i;
        int ret;
 
-       for (i = 0; i < num_consumers; i++) {
+       for (i = num_consumers - 1; i >= 0; --i) {
                ret = regulator_disable(consumers[i].consumer);
                if (ret != 0)
                        goto err;
@@ -2483,7 +2474,7 @@ int regulator_bulk_disable(int num_consumers,
 
 err:
        pr_err("Failed to disable %s: %d\n", consumers[i].supply, ret);
-       for (--i; i >= 0; --i)
+       for (++i; i < num_consumers; ++i)
                regulator_enable(consumers[i].consumer);
 
        return ret;
@@ -2710,11 +2701,9 @@ static int add_regulator_attributes(struct regulator_dev *rdev)
 
 static void rdev_init_debugfs(struct regulator_dev *rdev)
 {
-#ifdef CONFIG_DEBUG_FS
        rdev->debugfs = debugfs_create_dir(rdev_get_name(rdev), debugfs_root);
-       if (IS_ERR(rdev->debugfs) || !rdev->debugfs) {
+       if (!rdev->debugfs) {
                rdev_warn(rdev, "Failed to create debugfs directory\n");
-               rdev->debugfs = NULL;
                return;
        }
 
@@ -2722,7 +2711,6 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
                           &rdev->use_count);
        debugfs_create_u32("open_count", 0444, rdev->debugfs,
                           &rdev->open_count);
-#endif
 }
 
 /**
@@ -2900,9 +2888,7 @@ void regulator_unregister(struct regulator_dev *rdev)
                return;
 
        mutex_lock(&regulator_list_mutex);
-#ifdef CONFIG_DEBUG_FS
        debugfs_remove_recursive(rdev->debugfs);
-#endif
        flush_work_sync(&rdev->disable_work.work);
        WARN_ON(rdev->open_count);
        unset_regulator_supplies(rdev);
@@ -3112,12 +3098,14 @@ static ssize_t supply_map_read_file(struct file *file, char __user *user_buf,
 
        return ret;
 }
+#endif
 
 static const struct file_operations supply_map_fops = {
+#ifdef CONFIG_DEBUG_FS
        .read = supply_map_read_file,
        .llseek = default_llseek,
-};
 #endif
+};
 
 static int __init regulator_init(void)
 {
@@ -3125,17 +3113,12 @@ static int __init regulator_init(void)
 
        ret = class_register(&regulator_class);
 
-#ifdef CONFIG_DEBUG_FS
        debugfs_root = debugfs_create_dir("regulator", NULL);
-       if (IS_ERR(debugfs_root) || !debugfs_root) {
+       if (!debugfs_root)
                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
+       debugfs_create_file("supply_map", 0444, debugfs_root, NULL,
+                           &supply_map_fops);
 
        regulator_dummy_init();