aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/fixed.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/fixed.c')
-rw-r--r--drivers/regulator/fixed.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 354105eff1f8..6cfcbc8b6594 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -40,13 +40,15 @@ struct fixed_voltage_data {
40/** 40/**
41 * of_get_fixed_voltage_config - extract fixed_voltage_config structure info 41 * of_get_fixed_voltage_config - extract fixed_voltage_config structure info
42 * @dev: device requesting for fixed_voltage_config 42 * @dev: device requesting for fixed_voltage_config
43 * @desc: regulator description
43 * 44 *
44 * Populates fixed_voltage_config structure by extracting data from device 45 * Populates fixed_voltage_config structure by extracting data from device
45 * tree node, returns a pointer to the populated structure of NULL if memory 46 * tree node, returns a pointer to the populated structure of NULL if memory
46 * alloc fails. 47 * alloc fails.
47 */ 48 */
48static struct fixed_voltage_config * 49static struct fixed_voltage_config *
49of_get_fixed_voltage_config(struct device *dev) 50of_get_fixed_voltage_config(struct device *dev,
51 const struct regulator_desc *desc)
50{ 52{
51 struct fixed_voltage_config *config; 53 struct fixed_voltage_config *config;
52 struct device_node *np = dev->of_node; 54 struct device_node *np = dev->of_node;
@@ -57,7 +59,7 @@ of_get_fixed_voltage_config(struct device *dev)
57 if (!config) 59 if (!config)
58 return ERR_PTR(-ENOMEM); 60 return ERR_PTR(-ENOMEM);
59 61
60 config->init_data = of_get_regulator_init_data(dev, dev->of_node); 62 config->init_data = of_get_regulator_init_data(dev, dev->of_node, desc);
61 if (!config->init_data) 63 if (!config->init_data)
62 return ERR_PTR(-EINVAL); 64 return ERR_PTR(-EINVAL);
63 65
@@ -112,8 +114,14 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
112 struct regulator_config cfg = { }; 114 struct regulator_config cfg = { };
113 int ret; 115 int ret;
114 116
117 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data),
118 GFP_KERNEL);
119 if (!drvdata)
120 return -ENOMEM;
121
115 if (pdev->dev.of_node) { 122 if (pdev->dev.of_node) {
116 config = of_get_fixed_voltage_config(&pdev->dev); 123 config = of_get_fixed_voltage_config(&pdev->dev,
124 &drvdata->desc);
117 if (IS_ERR(config)) 125 if (IS_ERR(config))
118 return PTR_ERR(config); 126 return PTR_ERR(config);
119 } else { 127 } else {
@@ -123,11 +131,6 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
123 if (!config) 131 if (!config)
124 return -ENOMEM; 132 return -ENOMEM;
125 133
126 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data),
127 GFP_KERNEL);
128 if (!drvdata)
129 return -ENOMEM;
130
131 drvdata->desc.name = devm_kstrdup(&pdev->dev, 134 drvdata->desc.name = devm_kstrdup(&pdev->dev,
132 config->supply_name, 135 config->supply_name,
133 GFP_KERNEL); 136 GFP_KERNEL);