diff options
Diffstat (limited to 'drivers/regulator/gpio-regulator.c')
-rw-r--r-- | drivers/regulator/gpio-regulator.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 989b23b377c0..5c3bcae478b9 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c | |||
@@ -133,7 +133,8 @@ static struct regulator_ops gpio_regulator_voltage_ops = { | |||
133 | }; | 133 | }; |
134 | 134 | ||
135 | static struct gpio_regulator_config * | 135 | static struct gpio_regulator_config * |
136 | of_get_gpio_regulator_config(struct device *dev, struct device_node *np) | 136 | of_get_gpio_regulator_config(struct device *dev, struct device_node *np, |
137 | const struct regulator_desc *desc) | ||
137 | { | 138 | { |
138 | struct gpio_regulator_config *config; | 139 | struct gpio_regulator_config *config; |
139 | const char *regtype; | 140 | const char *regtype; |
@@ -146,7 +147,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) | |||
146 | if (!config) | 147 | if (!config) |
147 | return ERR_PTR(-ENOMEM); | 148 | return ERR_PTR(-ENOMEM); |
148 | 149 | ||
149 | config->init_data = of_get_regulator_init_data(dev, np); | 150 | config->init_data = of_get_regulator_init_data(dev, np, desc); |
150 | if (!config->init_data) | 151 | if (!config->init_data) |
151 | return ERR_PTR(-EINVAL); | 152 | return ERR_PTR(-EINVAL); |
152 | 153 | ||
@@ -243,17 +244,18 @@ static int gpio_regulator_probe(struct platform_device *pdev) | |||
243 | struct regulator_config cfg = { }; | 244 | struct regulator_config cfg = { }; |
244 | int ptr, ret, state; | 245 | int ptr, ret, state; |
245 | 246 | ||
246 | if (np) { | ||
247 | config = of_get_gpio_regulator_config(&pdev->dev, np); | ||
248 | if (IS_ERR(config)) | ||
249 | return PTR_ERR(config); | ||
250 | } | ||
251 | |||
252 | drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), | 247 | drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), |
253 | GFP_KERNEL); | 248 | GFP_KERNEL); |
254 | if (drvdata == NULL) | 249 | if (drvdata == NULL) |
255 | return -ENOMEM; | 250 | return -ENOMEM; |
256 | 251 | ||
252 | if (np) { | ||
253 | config = of_get_gpio_regulator_config(&pdev->dev, np, | ||
254 | &drvdata->desc); | ||
255 | if (IS_ERR(config)) | ||
256 | return PTR_ERR(config); | ||
257 | } | ||
258 | |||
257 | drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL); | 259 | drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL); |
258 | if (drvdata->desc.name == NULL) { | 260 | if (drvdata->desc.name == NULL) { |
259 | dev_err(&pdev->dev, "Failed to allocate supply name\n"); | 261 | dev_err(&pdev->dev, "Failed to allocate supply name\n"); |