diff options
author | Stephen Warren <swarren@nvidia.com> | 2011-11-22 20:21:15 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-11-23 05:24:10 -0500 |
commit | f2296d7bf19a210a462a57bb90b1c9263d18a4ee (patch) | |
tree | f1e36cfba34ab48d47d160fe2a13878cc7976c2c /sound/soc/tegra | |
parent | 99c92ae4ffca81f4dfba3b7648734c56d0b32d4c (diff) |
ASoC: Tegra DAS: Use devm_ APIs and module_platform_driver
module_platform_drive saves some boiler-plate code.
The devm_ APIs remove the need to manually clean up allocations,
thus removing some code.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/tegra')
-rw-r--r-- | sound/soc/tegra/tegra_das.c | 45 |
1 files changed, 10 insertions, 35 deletions
diff --git a/sound/soc/tegra/tegra_das.c b/sound/soc/tegra/tegra_das.c index 3b55a44146af..fa3a4426cbdd 100644 --- a/sound/soc/tegra/tegra_das.c +++ b/sound/soc/tegra/tegra_das.c | |||
@@ -172,11 +172,11 @@ static int __devinit tegra_das_probe(struct platform_device *pdev) | |||
172 | if (das) | 172 | if (das) |
173 | return -ENODEV; | 173 | return -ENODEV; |
174 | 174 | ||
175 | das = kzalloc(sizeof(struct tegra_das), GFP_KERNEL); | 175 | das = devm_kzalloc(&pdev->dev, sizeof(struct tegra_das), GFP_KERNEL); |
176 | if (!das) { | 176 | if (!das) { |
177 | dev_err(&pdev->dev, "Can't allocate tegra_das\n"); | 177 | dev_err(&pdev->dev, "Can't allocate tegra_das\n"); |
178 | ret = -ENOMEM; | 178 | ret = -ENOMEM; |
179 | goto exit; | 179 | goto err; |
180 | } | 180 | } |
181 | das->dev = &pdev->dev; | 181 | das->dev = &pdev->dev; |
182 | 182 | ||
@@ -184,22 +184,22 @@ static int __devinit tegra_das_probe(struct platform_device *pdev) | |||
184 | if (!res) { | 184 | if (!res) { |
185 | dev_err(&pdev->dev, "No memory resource\n"); | 185 | dev_err(&pdev->dev, "No memory resource\n"); |
186 | ret = -ENODEV; | 186 | ret = -ENODEV; |
187 | goto err_free; | 187 | goto err; |
188 | } | 188 | } |
189 | 189 | ||
190 | region = request_mem_region(res->start, resource_size(res), | 190 | region = devm_request_mem_region(&pdev->dev, res->start, |
191 | pdev->name); | 191 | resource_size(res), pdev->name); |
192 | if (!region) { | 192 | if (!region) { |
193 | dev_err(&pdev->dev, "Memory region already claimed\n"); | 193 | dev_err(&pdev->dev, "Memory region already claimed\n"); |
194 | ret = -EBUSY; | 194 | ret = -EBUSY; |
195 | goto err_free; | 195 | goto err; |
196 | } | 196 | } |
197 | 197 | ||
198 | das->regs = ioremap(res->start, resource_size(res)); | 198 | das->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); |
199 | if (!das->regs) { | 199 | if (!das->regs) { |
200 | dev_err(&pdev->dev, "ioremap failed\n"); | 200 | dev_err(&pdev->dev, "ioremap failed\n"); |
201 | ret = -ENOMEM; | 201 | ret = -ENOMEM; |
202 | goto err_release; | 202 | goto err; |
203 | } | 203 | } |
204 | 204 | ||
205 | tegra_das_debug_add(das); | 205 | tegra_das_debug_add(das); |
@@ -208,32 +208,18 @@ static int __devinit tegra_das_probe(struct platform_device *pdev) | |||
208 | 208 | ||
209 | return 0; | 209 | return 0; |
210 | 210 | ||
211 | err_release: | 211 | err: |
212 | release_mem_region(res->start, resource_size(res)); | ||
213 | err_free: | ||
214 | kfree(das); | ||
215 | das = NULL; | 212 | das = NULL; |
216 | exit: | ||
217 | return ret; | 213 | return ret; |
218 | } | 214 | } |
219 | 215 | ||
220 | static int __devexit tegra_das_remove(struct platform_device *pdev) | 216 | static int __devexit tegra_das_remove(struct platform_device *pdev) |
221 | { | 217 | { |
222 | struct resource *res; | ||
223 | |||
224 | if (!das) | 218 | if (!das) |
225 | return -ENODEV; | 219 | return -ENODEV; |
226 | 220 | ||
227 | platform_set_drvdata(pdev, NULL); | ||
228 | |||
229 | tegra_das_debug_remove(das); | 221 | tegra_das_debug_remove(das); |
230 | 222 | ||
231 | iounmap(das->regs); | ||
232 | |||
233 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
234 | release_mem_region(res->start, resource_size(res)); | ||
235 | |||
236 | kfree(das); | ||
237 | das = NULL; | 223 | das = NULL; |
238 | 224 | ||
239 | return 0; | 225 | return 0; |
@@ -246,18 +232,7 @@ static struct platform_driver tegra_das_driver = { | |||
246 | .name = DRV_NAME, | 232 | .name = DRV_NAME, |
247 | }, | 233 | }, |
248 | }; | 234 | }; |
249 | 235 | module_platform_driver(tegra_das_driver); | |
250 | static int __init tegra_das_modinit(void) | ||
251 | { | ||
252 | return platform_driver_register(&tegra_das_driver); | ||
253 | } | ||
254 | module_init(tegra_das_modinit); | ||
255 | |||
256 | static void __exit tegra_das_modexit(void) | ||
257 | { | ||
258 | platform_driver_unregister(&tegra_das_driver); | ||
259 | } | ||
260 | module_exit(tegra_das_modexit); | ||
261 | 236 | ||
262 | MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); | 237 | MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); |
263 | MODULE_DESCRIPTION("Tegra DAS driver"); | 238 | MODULE_DESCRIPTION("Tegra DAS driver"); |