aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-04-17 21:34:34 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-18 05:26:24 -0400
commit5abe0c4005dea3a67051eb1942916f9d0f6a1796 (patch)
treeaf776caa2fcce5d6e0fa5402d257f26c650937bc
parent62bc4d4a702654cf5aefbb32c766991fb45bf15a (diff)
regulator: userspace-consumer: Convert to use devm_* APIs
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--drivers/regulator/userspace-consumer.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c
index 518667ef9a0d..a7c8deb5f28f 100644
--- a/drivers/regulator/userspace-consumer.c
+++ b/drivers/regulator/userspace-consumer.c
@@ -115,7 +115,9 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
115 if (!pdata) 115 if (!pdata)
116 return -EINVAL; 116 return -EINVAL;
117 117
118 drvdata = kzalloc(sizeof(struct userspace_consumer_data), GFP_KERNEL); 118 drvdata = devm_kzalloc(&pdev->dev,
119 sizeof(struct userspace_consumer_data),
120 GFP_KERNEL);
119 if (drvdata == NULL) 121 if (drvdata == NULL)
120 return -ENOMEM; 122 return -ENOMEM;
121 123
@@ -125,16 +127,16 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
125 127
126 mutex_init(&drvdata->lock); 128 mutex_init(&drvdata->lock);
127 129
128 ret = regulator_bulk_get(&pdev->dev, drvdata->num_supplies, 130 ret = devm_regulator_bulk_get(&pdev->dev, drvdata->num_supplies,
129 drvdata->supplies); 131 drvdata->supplies);
130 if (ret) { 132 if (ret) {
131 dev_err(&pdev->dev, "Failed to get supplies: %d\n", ret); 133 dev_err(&pdev->dev, "Failed to get supplies: %d\n", ret);
132 goto err_alloc_supplies; 134 return ret;
133 } 135 }
134 136
135 ret = sysfs_create_group(&pdev->dev.kobj, &attr_group); 137 ret = sysfs_create_group(&pdev->dev.kobj, &attr_group);
136 if (ret != 0) 138 if (ret != 0)
137 goto err_create_attrs; 139 return ret;
138 140
139 if (pdata->init_on) { 141 if (pdata->init_on) {
140 ret = regulator_bulk_enable(drvdata->num_supplies, 142 ret = regulator_bulk_enable(drvdata->num_supplies,
@@ -154,11 +156,6 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
154err_enable: 156err_enable:
155 sysfs_remove_group(&pdev->dev.kobj, &attr_group); 157 sysfs_remove_group(&pdev->dev.kobj, &attr_group);
156 158
157err_create_attrs:
158 regulator_bulk_free(drvdata->num_supplies, drvdata->supplies);
159
160err_alloc_supplies:
161 kfree(drvdata);
162 return ret; 159 return ret;
163} 160}
164 161
@@ -171,9 +168,6 @@ static int regulator_userspace_consumer_remove(struct platform_device *pdev)
171 if (data->enabled) 168 if (data->enabled)
172 regulator_bulk_disable(data->num_supplies, data->supplies); 169 regulator_bulk_disable(data->num_supplies, data->supplies);
173 170
174 regulator_bulk_free(data->num_supplies, data->supplies);
175 kfree(data);
176
177 return 0; 171 return 0;
178} 172}
179 173