aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/core.c67
-rw-r--r--include/linux/regulator/driver.h6
2 files changed, 29 insertions, 44 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ca86f39a0fdc..fc4ccf880cbc 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -13,8 +13,6 @@
13 * 13 *
14 */ 14 */
15 15
16#define pr_fmt(fmt) "%s: " fmt, __func__
17
18#include <linux/kernel.h> 16#include <linux/kernel.h>
19#include <linux/init.h> 17#include <linux/init.h>
20#include <linux/debugfs.h> 18#include <linux/debugfs.h>
@@ -54,9 +52,7 @@ static LIST_HEAD(regulator_map_list);
54static bool has_full_constraints; 52static bool has_full_constraints;
55static bool board_wants_dummy_regulator; 53static bool board_wants_dummy_regulator;
56 54
57#ifdef CONFIG_DEBUG_FS
58static struct dentry *debugfs_root; 55static struct dentry *debugfs_root;
59#endif
60 56
61/* 57/*
62 * struct regulator_map 58 * struct regulator_map
@@ -84,9 +80,7 @@ struct regulator {
84 char *supply_name; 80 char *supply_name;
85 struct device_attribute dev_attr; 81 struct device_attribute dev_attr;
86 struct regulator_dev *rdev; 82 struct regulator_dev *rdev;
87#ifdef CONFIG_DEBUG_FS
88 struct dentry *debugfs; 83 struct dentry *debugfs;
89#endif
90}; 84};
91 85
92static int _regulator_is_enabled(struct regulator_dev *rdev); 86static int _regulator_is_enabled(struct regulator_dev *rdev);
@@ -154,7 +148,7 @@ static struct device_node *of_get_regulator(struct device *dev, const char *supp
154 regnode = of_parse_phandle(dev->of_node, prop_name, 0); 148 regnode = of_parse_phandle(dev->of_node, prop_name, 0);
155 149
156 if (!regnode) { 150 if (!regnode) {
157 dev_warn(dev, "%s property in node %s references invalid phandle", 151 dev_dbg(dev, "Looking up %s property in node %s failed",
158 prop_name, dev->of_node->full_name); 152 prop_name, dev->of_node->full_name);
159 return NULL; 153 return NULL;
160 } 154 }
@@ -807,6 +801,11 @@ static void print_constraints(struct regulator_dev *rdev)
807 count += sprintf(buf + count, "standby"); 801 count += sprintf(buf + count, "standby");
808 802
809 rdev_info(rdev, "%s\n", buf); 803 rdev_info(rdev, "%s\n", buf);
804
805 if ((constraints->min_uV != constraints->max_uV) &&
806 !(constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE))
807 rdev_warn(rdev,
808 "Voltage range but no REGULATOR_CHANGE_VOLTAGE\n");
810} 809}
811 810
812static int machine_constraints_voltage(struct regulator_dev *rdev, 811static int machine_constraints_voltage(struct regulator_dev *rdev,
@@ -1142,12 +1141,10 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
1142 goto attr_err; 1141 goto attr_err;
1143 } 1142 }
1144 1143
1145#ifdef CONFIG_DEBUG_FS
1146 regulator->debugfs = debugfs_create_dir(regulator->supply_name, 1144 regulator->debugfs = debugfs_create_dir(regulator->supply_name,
1147 rdev->debugfs); 1145 rdev->debugfs);
1148 if (IS_ERR_OR_NULL(regulator->debugfs)) { 1146 if (!regulator->debugfs) {
1149 rdev_warn(rdev, "Failed to create debugfs directory\n"); 1147 rdev_warn(rdev, "Failed to create debugfs directory\n");
1150 regulator->debugfs = NULL;
1151 } else { 1148 } else {
1152 debugfs_create_u32("uA_load", 0444, regulator->debugfs, 1149 debugfs_create_u32("uA_load", 0444, regulator->debugfs,
1153 &regulator->uA_load); 1150 &regulator->uA_load);
@@ -1156,7 +1153,6 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
1156 debugfs_create_u32("max_uV", 0444, regulator->debugfs, 1153 debugfs_create_u32("max_uV", 0444, regulator->debugfs,
1157 &regulator->max_uV); 1154 &regulator->max_uV);
1158 } 1155 }
1159#endif
1160 1156
1161 mutex_unlock(&rdev->mutex); 1157 mutex_unlock(&rdev->mutex);
1162 return regulator; 1158 return regulator;
@@ -1365,9 +1361,7 @@ void regulator_put(struct regulator *regulator)
1365 mutex_lock(&regulator_list_mutex); 1361 mutex_lock(&regulator_list_mutex);
1366 rdev = regulator->rdev; 1362 rdev = regulator->rdev;
1367 1363
1368#ifdef CONFIG_DEBUG_FS
1369 debugfs_remove_recursive(regulator->debugfs); 1364 debugfs_remove_recursive(regulator->debugfs);
1370#endif
1371 1365
1372 /* remove any sysfs entries */ 1366 /* remove any sysfs entries */
1373 if (regulator->dev) { 1367 if (regulator->dev) {
@@ -1842,8 +1836,12 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
1842 if (ret < 0) 1836 if (ret < 0)
1843 return ret; 1837 return ret;
1844 old_selector = ret; 1838 old_selector = ret;
1845 delay = rdev->desc->ops->set_voltage_time_sel(rdev, 1839 ret = rdev->desc->ops->set_voltage_time_sel(rdev,
1846 old_selector, selector); 1840 old_selector, selector);
1841 if (ret < 0)
1842 rdev_warn(rdev, "set_voltage_time_sel() failed: %d\n", ret);
1843 else
1844 delay = ret;
1847 } 1845 }
1848 1846
1849 if (best_val != INT_MAX) { 1847 if (best_val != INT_MAX) {
@@ -2394,7 +2392,7 @@ int regulator_bulk_get(struct device *dev, int num_consumers,
2394 return 0; 2392 return 0;
2395 2393
2396err: 2394err:
2397 for (i = 0; i < num_consumers && consumers[i].consumer; i++) 2395 while (--i >= 0)
2398 regulator_put(consumers[i].consumer); 2396 regulator_put(consumers[i].consumer);
2399 2397
2400 return ret; 2398 return ret;
@@ -2444,12 +2442,9 @@ int regulator_bulk_enable(int num_consumers,
2444 return 0; 2442 return 0;
2445 2443
2446err: 2444err:
2447 for (i = 0; i < num_consumers; i++) 2445 pr_err("Failed to enable %s: %d\n", consumers[i].supply, ret);
2448 if (consumers[i].ret == 0) 2446 while (--i >= 0)
2449 regulator_disable(consumers[i].consumer); 2447 regulator_disable(consumers[i].consumer);
2450 else
2451 pr_err("Failed to enable %s: %d\n",
2452 consumers[i].supply, consumers[i].ret);
2453 2448
2454 return ret; 2449 return ret;
2455} 2450}
@@ -2463,8 +2458,8 @@ EXPORT_SYMBOL_GPL(regulator_bulk_enable);
2463 * @return 0 on success, an errno on failure 2458 * @return 0 on success, an errno on failure
2464 * 2459 *
2465 * This convenience API allows consumers to disable multiple regulator 2460 * This convenience API allows consumers to disable multiple regulator
2466 * clients in a single API call. If any consumers cannot be enabled 2461 * clients in a single API call. If any consumers cannot be disabled
2467 * then any others that were disabled will be disabled again prior to 2462 * then any others that were disabled will be enabled again prior to
2468 * return. 2463 * return.
2469 */ 2464 */
2470int regulator_bulk_disable(int num_consumers, 2465int regulator_bulk_disable(int num_consumers,
@@ -2473,7 +2468,7 @@ int regulator_bulk_disable(int num_consumers,
2473 int i; 2468 int i;
2474 int ret; 2469 int ret;
2475 2470
2476 for (i = 0; i < num_consumers; i++) { 2471 for (i = num_consumers - 1; i >= 0; --i) {
2477 ret = regulator_disable(consumers[i].consumer); 2472 ret = regulator_disable(consumers[i].consumer);
2478 if (ret != 0) 2473 if (ret != 0)
2479 goto err; 2474 goto err;
@@ -2483,7 +2478,7 @@ int regulator_bulk_disable(int num_consumers,
2483 2478
2484err: 2479err:
2485 pr_err("Failed to disable %s: %d\n", consumers[i].supply, ret); 2480 pr_err("Failed to disable %s: %d\n", consumers[i].supply, ret);
2486 for (--i; i >= 0; --i) 2481 for (++i; i < num_consumers; ++i)
2487 regulator_enable(consumers[i].consumer); 2482 regulator_enable(consumers[i].consumer);
2488 2483
2489 return ret; 2484 return ret;
@@ -2710,11 +2705,9 @@ static int add_regulator_attributes(struct regulator_dev *rdev)
2710 2705
2711static void rdev_init_debugfs(struct regulator_dev *rdev) 2706static void rdev_init_debugfs(struct regulator_dev *rdev)
2712{ 2707{
2713#ifdef CONFIG_DEBUG_FS
2714 rdev->debugfs = debugfs_create_dir(rdev_get_name(rdev), debugfs_root); 2708 rdev->debugfs = debugfs_create_dir(rdev_get_name(rdev), debugfs_root);
2715 if (IS_ERR(rdev->debugfs) || !rdev->debugfs) { 2709 if (!rdev->debugfs) {
2716 rdev_warn(rdev, "Failed to create debugfs directory\n"); 2710 rdev_warn(rdev, "Failed to create debugfs directory\n");
2717 rdev->debugfs = NULL;
2718 return; 2711 return;
2719 } 2712 }
2720 2713
@@ -2722,7 +2715,6 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
2722 &rdev->use_count); 2715 &rdev->use_count);
2723 debugfs_create_u32("open_count", 0444, rdev->debugfs, 2716 debugfs_create_u32("open_count", 0444, rdev->debugfs,
2724 &rdev->open_count); 2717 &rdev->open_count);
2725#endif
2726} 2718}
2727 2719
2728/** 2720/**
@@ -2900,9 +2892,7 @@ void regulator_unregister(struct regulator_dev *rdev)
2900 return; 2892 return;
2901 2893
2902 mutex_lock(&regulator_list_mutex); 2894 mutex_lock(&regulator_list_mutex);
2903#ifdef CONFIG_DEBUG_FS
2904 debugfs_remove_recursive(rdev->debugfs); 2895 debugfs_remove_recursive(rdev->debugfs);
2905#endif
2906 flush_work_sync(&rdev->disable_work.work); 2896 flush_work_sync(&rdev->disable_work.work);
2907 WARN_ON(rdev->open_count); 2897 WARN_ON(rdev->open_count);
2908 unset_regulator_supplies(rdev); 2898 unset_regulator_supplies(rdev);
@@ -3112,12 +3102,14 @@ static ssize_t supply_map_read_file(struct file *file, char __user *user_buf,
3112 3102
3113 return ret; 3103 return ret;
3114} 3104}
3105#endif
3115 3106
3116static const struct file_operations supply_map_fops = { 3107static const struct file_operations supply_map_fops = {
3108#ifdef CONFIG_DEBUG_FS
3117 .read = supply_map_read_file, 3109 .read = supply_map_read_file,
3118 .llseek = default_llseek, 3110 .llseek = default_llseek,
3119};
3120#endif 3111#endif
3112};
3121 3113
3122static int __init regulator_init(void) 3114static int __init regulator_init(void)
3123{ 3115{
@@ -3125,17 +3117,12 @@ static int __init regulator_init(void)
3125 3117
3126 ret = class_register(&regulator_class); 3118 ret = class_register(&regulator_class);
3127 3119
3128#ifdef CONFIG_DEBUG_FS
3129 debugfs_root = debugfs_create_dir("regulator", NULL); 3120 debugfs_root = debugfs_create_dir("regulator", NULL);
3130 if (IS_ERR(debugfs_root) || !debugfs_root) { 3121 if (!debugfs_root)
3131 pr_warn("regulator: Failed to create debugfs directory\n"); 3122 pr_warn("regulator: Failed to create debugfs directory\n");
3132 debugfs_root = NULL;
3133 }
3134 3123
3135 if (IS_ERR(debugfs_create_file("supply_map", 0444, debugfs_root, 3124 debugfs_create_file("supply_map", 0444, debugfs_root, NULL,
3136 NULL, &supply_map_fops))) 3125 &supply_map_fops);
3137 pr_warn("regulator: Failed to create supplies debugfs\n");
3138#endif
3139 3126
3140 regulator_dummy_init(); 3127 regulator_dummy_init();
3141 3128
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 4214b9a9d1c9..fa8b55b8191c 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -104,7 +104,7 @@ struct regulator_ops {
104 int (*disable) (struct regulator_dev *); 104 int (*disable) (struct regulator_dev *);
105 int (*is_enabled) (struct regulator_dev *); 105 int (*is_enabled) (struct regulator_dev *);
106 106
107 /* get/set regulator operating mode (defined in regulator.h) */ 107 /* get/set regulator operating mode (defined in consumer.h) */
108 int (*set_mode) (struct regulator_dev *, unsigned int mode); 108 int (*set_mode) (struct regulator_dev *, unsigned int mode);
109 unsigned int (*get_mode) (struct regulator_dev *); 109 unsigned int (*get_mode) (struct regulator_dev *);
110 110
@@ -135,7 +135,7 @@ struct regulator_ops {
135 int (*set_suspend_enable) (struct regulator_dev *); 135 int (*set_suspend_enable) (struct regulator_dev *);
136 int (*set_suspend_disable) (struct regulator_dev *); 136 int (*set_suspend_disable) (struct regulator_dev *);
137 137
138 /* set regulator suspend operating mode (defined in regulator.h) */ 138 /* set regulator suspend operating mode (defined in consumer.h) */
139 int (*set_suspend_mode) (struct regulator_dev *, unsigned int mode); 139 int (*set_suspend_mode) (struct regulator_dev *, unsigned int mode);
140}; 140};
141 141
@@ -207,9 +207,7 @@ struct regulator_dev {
207 207
208 void *reg_data; /* regulator_dev data */ 208 void *reg_data; /* regulator_dev data */
209 209
210#ifdef CONFIG_DEBUG_FS
211 struct dentry *debugfs; 210 struct dentry *debugfs;
212#endif
213}; 211};
214 212
215struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, 213struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,