aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/fixed.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-03-21 16:04:44 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-01 06:59:26 -0400
commit9d442061da08e679ec8e7c004fd0450e799a2af7 (patch)
tree1128b231a84a87efc377bc00ff5899b5e63078a3 /drivers/regulator/fixed.c
parentc45bb35f8b76439f4b6c0efaca510f871e9b1840 (diff)
regulator: fixed: Don't supply voltage change ops when no GPIO is given
Rather than replicating the core support for always on regulators use a different set of ops with none of the enable related operations provided when we don't have any ops. This ensures that we automatically pick up any enhanced support for such regulators that the core has such as the warnings about regulation constraints that can't be used. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/fixed.c')
-rw-r--r--drivers/regulator/fixed.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 7d4f381d55af..8a1e22acc202 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -105,10 +105,8 @@ static int fixed_voltage_enable(struct regulator_dev *dev)
105{ 105{
106 struct fixed_voltage_data *data = rdev_get_drvdata(dev); 106 struct fixed_voltage_data *data = rdev_get_drvdata(dev);
107 107
108 if (gpio_is_valid(data->gpio)) { 108 gpio_set_value_cansleep(data->gpio, data->enable_high);
109 gpio_set_value_cansleep(data->gpio, data->enable_high); 109 data->is_enabled = true;
110 data->is_enabled = true;
111 }
112 110
113 return 0; 111 return 0;
114} 112}
@@ -117,10 +115,8 @@ static int fixed_voltage_disable(struct regulator_dev *dev)
117{ 115{
118 struct fixed_voltage_data *data = rdev_get_drvdata(dev); 116 struct fixed_voltage_data *data = rdev_get_drvdata(dev);
119 117
120 if (gpio_is_valid(data->gpio)) { 118 gpio_set_value_cansleep(data->gpio, !data->enable_high);
121 gpio_set_value_cansleep(data->gpio, !data->enable_high); 119 data->is_enabled = false;
122 data->is_enabled = false;
123 }
124 120
125 return 0; 121 return 0;
126} 122}
@@ -153,7 +149,7 @@ static int fixed_voltage_list_voltage(struct regulator_dev *dev,
153 return data->microvolts; 149 return data->microvolts;
154} 150}
155 151
156static struct regulator_ops fixed_voltage_ops = { 152static struct regulator_ops fixed_voltage_gpio_ops = {
157 .is_enabled = fixed_voltage_is_enabled, 153 .is_enabled = fixed_voltage_is_enabled,
158 .enable = fixed_voltage_enable, 154 .enable = fixed_voltage_enable,
159 .disable = fixed_voltage_disable, 155 .disable = fixed_voltage_disable,
@@ -162,6 +158,11 @@ static struct regulator_ops fixed_voltage_ops = {
162 .list_voltage = fixed_voltage_list_voltage, 158 .list_voltage = fixed_voltage_list_voltage,
163}; 159};
164 160
161static struct regulator_ops fixed_voltage_ops = {
162 .get_voltage = fixed_voltage_get_voltage,
163 .list_voltage = fixed_voltage_list_voltage,
164};
165
165static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev) 166static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
166{ 167{
167 struct fixed_voltage_config *config; 168 struct fixed_voltage_config *config;
@@ -192,7 +193,6 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
192 } 193 }
193 drvdata->desc.type = REGULATOR_VOLTAGE; 194 drvdata->desc.type = REGULATOR_VOLTAGE;
194 drvdata->desc.owner = THIS_MODULE; 195 drvdata->desc.owner = THIS_MODULE;
195 drvdata->desc.ops = &fixed_voltage_ops;
196 196
197 if (config->microvolts) 197 if (config->microvolts)
198 drvdata->desc.n_voltages = 1; 198 drvdata->desc.n_voltages = 1;
@@ -242,11 +242,10 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
242 goto err_gpio; 242 goto err_gpio;
243 } 243 }
244 244
245 drvdata->desc.ops = &fixed_voltage_gpio_ops;
246
245 } else { 247 } else {
246 /* Regulator without GPIO control is considered 248 drvdata->desc.ops = &fixed_voltage_ops;
247 * always enabled
248 */
249 drvdata->is_enabled = true;
250 } 249 }
251 250
252 drvdata->dev = regulator_register(&drvdata->desc, &pdev->dev, 251 drvdata->dev = regulator_register(&drvdata->desc, &pdev->dev,