aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/virtual.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/virtual.c')
-rw-r--r--drivers/regulator/virtual.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c
index e953c1810c7..5c1d75662b8 100644
--- a/drivers/regulator/virtual.c
+++ b/drivers/regulator/virtual.c
@@ -27,17 +27,18 @@ struct virtual_consumer_data {
27 unsigned int mode; 27 unsigned int mode;
28}; 28};
29 29
30static void update_voltage_constraints(struct virtual_consumer_data *data) 30static void update_voltage_constraints(struct device *dev,
31 struct virtual_consumer_data *data)
31{ 32{
32 int ret; 33 int ret;
33 34
34 if (data->min_uV && data->max_uV 35 if (data->min_uV && data->max_uV
35 && data->min_uV <= data->max_uV) { 36 && data->min_uV <= data->max_uV) {
36 ret = regulator_set_voltage(data->regulator, 37 ret = regulator_set_voltage(data->regulator,
37 data->min_uV, data->max_uV); 38 data->min_uV, data->max_uV);
38 if (ret != 0) { 39 if (ret != 0) {
39 printk(KERN_ERR "regulator_set_voltage() failed: %d\n", 40 dev_err(dev,
40 ret); 41 "regulator_set_voltage() failed: %d\n", ret);
41 return; 42 return;
42 } 43 }
43 } 44 }
@@ -47,7 +48,7 @@ static void update_voltage_constraints(struct virtual_consumer_data *data)
47 if (ret == 0) 48 if (ret == 0)
48 data->enabled = 1; 49 data->enabled = 1;
49 else 50 else
50 printk(KERN_ERR "regulator_enable() failed: %d\n", 51 dev_err(dev, "regulator_enable() failed: %d\n",
51 ret); 52 ret);
52 } 53 }
53 54
@@ -56,13 +57,13 @@ static void update_voltage_constraints(struct virtual_consumer_data *data)
56 if (ret == 0) 57 if (ret == 0)
57 data->enabled = 0; 58 data->enabled = 0;
58 else 59 else
59 printk(KERN_ERR "regulator_disable() failed: %d\n", 60 dev_err(dev, "regulator_disable() failed: %d\n",
60 ret); 61 ret);
61 } 62 }
62} 63}
63 64
64static void update_current_limit_constraints(struct virtual_consumer_data 65static void update_current_limit_constraints(struct device *dev,
65 *data) 66 struct virtual_consumer_data *data)
66{ 67{
67 int ret; 68 int ret;
68 69
@@ -71,8 +72,9 @@ static void update_current_limit_constraints(struct virtual_consumer_data
71 ret = regulator_set_current_limit(data->regulator, 72 ret = regulator_set_current_limit(data->regulator,
72 data->min_uA, data->max_uA); 73 data->min_uA, data->max_uA);
73 if (ret != 0) { 74 if (ret != 0) {
74 pr_err("regulator_set_current_limit() failed: %d\n", 75 dev_err(dev,
75 ret); 76 "regulator_set_current_limit() failed: %d\n",
77 ret);
76 return; 78 return;
77 } 79 }
78 } 80 }
@@ -82,7 +84,7 @@ static void update_current_limit_constraints(struct virtual_consumer_data
82 if (ret == 0) 84 if (ret == 0)
83 data->enabled = 1; 85 data->enabled = 1;
84 else 86 else
85 printk(KERN_ERR "regulator_enable() failed: %d\n", 87 dev_err(dev, "regulator_enable() failed: %d\n",
86 ret); 88 ret);
87 } 89 }
88 90
@@ -91,7 +93,7 @@ static void update_current_limit_constraints(struct virtual_consumer_data
91 if (ret == 0) 93 if (ret == 0)
92 data->enabled = 0; 94 data->enabled = 0;
93 else 95 else
94 printk(KERN_ERR "regulator_disable() failed: %d\n", 96 dev_err(dev, "regulator_disable() failed: %d\n",
95 ret); 97 ret);
96 } 98 }
97} 99}
@@ -115,7 +117,7 @@ static ssize_t set_min_uV(struct device *dev, struct device_attribute *attr,
115 mutex_lock(&data->lock); 117 mutex_lock(&data->lock);
116 118
117 data->min_uV = val; 119 data->min_uV = val;
118 update_voltage_constraints(data); 120 update_voltage_constraints(dev, data);
119 121
120 mutex_unlock(&data->lock); 122 mutex_unlock(&data->lock);
121 123
@@ -141,7 +143,7 @@ static ssize_t set_max_uV(struct device *dev, struct device_attribute *attr,
141 mutex_lock(&data->lock); 143 mutex_lock(&data->lock);
142 144
143 data->max_uV = val; 145 data->max_uV = val;
144 update_voltage_constraints(data); 146 update_voltage_constraints(dev, data);
145 147
146 mutex_unlock(&data->lock); 148 mutex_unlock(&data->lock);
147 149
@@ -167,7 +169,7 @@ static ssize_t set_min_uA(struct device *dev, struct device_attribute *attr,
167 mutex_lock(&data->lock); 169 mutex_lock(&data->lock);
168 170
169 data->min_uA = val; 171 data->min_uA = val;
170 update_current_limit_constraints(data); 172 update_current_limit_constraints(dev, data);
171 173
172 mutex_unlock(&data->lock); 174 mutex_unlock(&data->lock);
173 175
@@ -193,7 +195,7 @@ static ssize_t set_max_uA(struct device *dev, struct device_attribute *attr,
193 mutex_lock(&data->lock); 195 mutex_lock(&data->lock);
194 196
195 data->max_uA = val; 197 data->max_uA = val;
196 update_current_limit_constraints(data); 198 update_current_limit_constraints(dev, data);
197 199
198 mutex_unlock(&data->lock); 200 mutex_unlock(&data->lock);
199 201