Skip to content

Commit 372e3a8

Browse files
himangi774linvjw
authored andcommitted
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>
1 parent 560ce30 commit 372e3a8

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

  • drivers/net/wireless/ti/wlcore

‎drivers/net/wireless/ti/wlcore/spi.c‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -327,23 +327,22 @@ static int wl1271_probe(struct spi_device *spi)
327327
struct wl12xx_spi_glue *glue;
328328
struct wlcore_platdev_data pdev_data;
329329
struct resource res[1];
330-
int ret = -ENOMEM;
330+
int ret;
331331

332332
memset(&pdev_data, 0x00, sizeof(pdev_data));
333333

334334
pdev_data.pdata = dev_get_platdata(&spi->dev);
335335
if (!pdev_data.pdata) {
336336
dev_err(&spi->dev, "no platform data\n");
337-
ret = -ENODEV;
338-
goto out;
337+
return -ENODEV;
339338
}
340339

341340
pdev_data.if_ops = &spi_ops;
342341

343-
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
342+
glue = devm_kzalloc(&spi->dev, sizeof(*glue), GFP_KERNEL);
344343
if (!glue) {
345344
dev_err(&spi->dev, "can't allocate glue\n");
346-
goto out;
345+
return -ENOMEM;
347346
}
348347

349348
glue->dev = &spi->dev;
@@ -357,14 +356,13 @@ static int wl1271_probe(struct spi_device *spi)
357356
ret = spi_setup(spi);
358357
if (ret < 0) {
359358
dev_err(glue->dev, "spi_setup failed\n");
360-
goto out_free_glue;
359+
return ret;
361360
}
362361

363362
glue->core = platform_device_alloc("wl12xx", PLATFORM_DEVID_AUTO);
364363
if (!glue->core) {
365364
dev_err(glue->dev, "can't allocate platform_device\n");
366-
ret = -ENOMEM;
367-
goto out_free_glue;
365+
return -ENOMEM;
368366
}
369367

370368
glue->core->dev.parent = &spi->dev;
@@ -398,11 +396,6 @@ static int wl1271_probe(struct spi_device *spi)
398396

399397
out_dev_put:
400398
platform_device_put(glue->core);
401-
402-
out_free_glue:
403-
kfree(glue);
404-
405-
out:
406399
return ret;
407400
}
408401

@@ -411,7 +404,6 @@ static int wl1271_remove(struct spi_device *spi)
411404
struct wl12xx_spi_glue *glue = spi_get_drvdata(spi);
412405

413406
platform_device_unregister(glue->core);
414-
kfree(glue);
415407

416408
return 0;
417409
}

0 commit comments

Comments
 (0)