aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHimangi Saraogi <himangi774@gmail.com>2014-08-07 07:02:45 -0400
committerJohn W. Linville <linville@tuxdriver.com>2014-08-25 16:17:39 -0400
commit372e3a846814656d5e514167484f684f828fff56 (patch)
treeee3cc80815cfd0447be9913d495e2d4b8af008be
parent560ce3087292603dafb2603ee12cab0ff6c20aee (diff)
wireless: wlcore: Use devm_kzalloc
This patch introduces the use of devm_kzalloc and does away with the kfrees in the probe and remove functions. Also, a couple of labels and the initial assignment of the ret variable in the probe function are removed. Signed-off-by: Himangi Saraogi <himangi774@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ti/wlcore/spi.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/drivers/net/wireless/ti/wlcore/spi.c b/drivers/net/wireless/ti/wlcore/spi.c
index 392c882b28f0..69601f6741d9 100644
--- a/drivers/net/wireless/ti/wlcore/spi.c
+++ b/drivers/net/wireless/ti/wlcore/spi.c
@@ -327,23 +327,22 @@ static int wl1271_probe(struct spi_device *spi)
327 struct wl12xx_spi_glue *glue; 327 struct wl12xx_spi_glue *glue;
328 struct wlcore_platdev_data pdev_data; 328 struct wlcore_platdev_data pdev_data;
329 struct resource res[1]; 329 struct resource res[1];
330 int ret = -ENOMEM; 330 int ret;
331 331
332 memset(&pdev_data, 0x00, sizeof(pdev_data)); 332 memset(&pdev_data, 0x00, sizeof(pdev_data));
333 333
334 pdev_data.pdata = dev_get_platdata(&spi->dev); 334 pdev_data.pdata = dev_get_platdata(&spi->dev);
335 if (!pdev_data.pdata) { 335 if (!pdev_data.pdata) {
336 dev_err(&spi->dev, "no platform data\n"); 336 dev_err(&spi->dev, "no platform data\n");
337 ret = -ENODEV; 337 return -ENODEV;
338 goto out;
339 } 338 }
340 339
341 pdev_data.if_ops = &spi_ops; 340 pdev_data.if_ops = &spi_ops;
342 341
343 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 342 glue = devm_kzalloc(&spi->dev, sizeof(*glue), GFP_KERNEL);
344 if (!glue) { 343 if (!glue) {
345 dev_err(&spi->dev, "can't allocate glue\n"); 344 dev_err(&spi->dev, "can't allocate glue\n");
346 goto out; 345 return -ENOMEM;
347 } 346 }
348 347
349 glue->dev = &spi->dev; 348 glue->dev = &spi->dev;
@@ -357,14 +356,13 @@ static int wl1271_probe(struct spi_device *spi)
357 ret = spi_setup(spi); 356 ret = spi_setup(spi);
358 if (ret < 0) { 357 if (ret < 0) {
359 dev_err(glue->dev, "spi_setup failed\n"); 358 dev_err(glue->dev, "spi_setup failed\n");
360 goto out_free_glue; 359 return ret;
361 } 360 }
362 361
363 glue->core = platform_device_alloc("wl12xx", PLATFORM_DEVID_AUTO); 362 glue->core = platform_device_alloc("wl12xx", PLATFORM_DEVID_AUTO);
364 if (!glue->core) { 363 if (!glue->core) {
365 dev_err(glue->dev, "can't allocate platform_device\n"); 364 dev_err(glue->dev, "can't allocate platform_device\n");
366 ret = -ENOMEM; 365 return -ENOMEM;
367 goto out_free_glue;
368 } 366 }
369 367
370 glue->core->dev.parent = &spi->dev; 368 glue->core->dev.parent = &spi->dev;
@@ -398,11 +396,6 @@ static int wl1271_probe(struct spi_device *spi)
398 396
399out_dev_put: 397out_dev_put:
400 platform_device_put(glue->core); 398 platform_device_put(glue->core);
401
402out_free_glue:
403 kfree(glue);
404
405out:
406 return ret; 399 return ret;
407} 400}
408 401
@@ -411,7 +404,6 @@ static int wl1271_remove(struct spi_device *spi)
411 struct wl12xx_spi_glue *glue = spi_get_drvdata(spi); 404 struct wl12xx_spi_glue *glue = spi_get_drvdata(spi);
412 405
413 platform_device_unregister(glue->core); 406 platform_device_unregister(glue->core);
414 kfree(glue);
415 407
416 return 0; 408 return 0;
417} 409}