aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/fixed.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-06-29 12:33:15 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-07-01 14:12:59 -0400
commitf141822b15635daa94610c5527806fa315f59f4d (patch)
tree95800ff6dec1780cde5086b979f64479f929564e /drivers/regulator/fixed.c
parentd172f319c1094ef22d2a00f43e8a7da4dd02c8f3 (diff)
regulator: fixed: support deferred probe for DT GPIOs
of_get_named_gpio() needs the driver hosting the GPIO that the DT property references to have been probed. Detect this specific failure, and defer the probe of the whole regulator until this API can complete. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/fixed.c')
-rw-r--r--drivers/regulator/fixed.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 8bda3654ae51..b8c3a910502a 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -61,11 +61,11 @@ of_get_fixed_voltage_config(struct device *dev)
61 config = devm_kzalloc(dev, sizeof(struct fixed_voltage_config), 61 config = devm_kzalloc(dev, sizeof(struct fixed_voltage_config),
62 GFP_KERNEL); 62 GFP_KERNEL);
63 if (!config) 63 if (!config)
64 return NULL; 64 return ERR_PTR(-ENOMEM);
65 65
66 config->init_data = of_get_regulator_init_data(dev, dev->of_node); 66 config->init_data = of_get_regulator_init_data(dev, dev->of_node);
67 if (!config->init_data) 67 if (!config->init_data)
68 return NULL; 68 return ERR_PTR(-EINVAL);
69 69
70 init_data = config->init_data; 70 init_data = config->init_data;
71 init_data->constraints.apply_uV = 0; 71 init_data->constraints.apply_uV = 0;
@@ -76,13 +76,26 @@ of_get_fixed_voltage_config(struct device *dev)
76 } else { 76 } else {
77 dev_err(dev, 77 dev_err(dev,
78 "Fixed regulator specified with variable voltages\n"); 78 "Fixed regulator specified with variable voltages\n");
79 return NULL; 79 return ERR_PTR(-EINVAL);
80 } 80 }
81 81
82 if (init_data->constraints.boot_on) 82 if (init_data->constraints.boot_on)
83 config->enabled_at_boot = true; 83 config->enabled_at_boot = true;
84 84
85 config->gpio = of_get_named_gpio(np, "gpio", 0); 85 config->gpio = of_get_named_gpio(np, "gpio", 0);
86 /*
87 * of_get_named_gpio() currently returns ENODEV rather than
88 * EPROBE_DEFER. This code attempts to be compatible with both
89 * for now; the ENODEV check can be removed once the API is fixed.
90 * of_get_named_gpio() doesn't differentiate between a missing
91 * property (which would be fine here, since the GPIO is optional)
92 * and some other error. Patches have been posted for both issues.
93 * Once they are check in, we should replace this with:
94 * if (config->gpio < 0 && config->gpio != -ENOENT)
95 */
96 if ((config->gpio == -ENODEV) || (config->gpio == -EPROBE_DEFER))
97 return ERR_PTR(-EPROBE_DEFER);
98
86 delay = of_get_property(np, "startup-delay-us", NULL); 99 delay = of_get_property(np, "startup-delay-us", NULL);
87 if (delay) 100 if (delay)
88 config->startup_delay = be32_to_cpu(*delay); 101 config->startup_delay = be32_to_cpu(*delay);
@@ -172,10 +185,13 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
172 struct regulator_config cfg = { }; 185 struct regulator_config cfg = { };
173 int ret; 186 int ret;
174 187
175 if (pdev->dev.of_node) 188 if (pdev->dev.of_node) {
176 config = of_get_fixed_voltage_config(&pdev->dev); 189 config = of_get_fixed_voltage_config(&pdev->dev);
177 else 190 if (IS_ERR(config))
191 return PTR_ERR(config);
192 } else {
178 config = pdev->dev.platform_data; 193 config = pdev->dev.platform_data;
194 }
179 195
180 if (!config) 196 if (!config)
181 return -ENOMEM; 197 return -ENOMEM;