cw1200: Introduce the use of devm_kzalloc
authorHimangi Saraogi <himangi774@gmail.com>
Sat, 2 Aug 2014 14:52:46 +0000 (20:22 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 25 Aug 2014 20:00:43 +0000 (16:00 -0400)
This patch introduces the use of devm_kzalloc and does away with the
kfrees in the probe and remove functions.

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>
drivers/net/wireless/cw1200/cw1200_spi.c

index 40078f5f932ec6b1ea3a26af5453f2bc5d2206ec..964b64ab7fe3a10aed8024f79abe6a23df6afb38 100644 (file)
@@ -398,7 +398,7 @@ static int cw1200_spi_probe(struct spi_device *func)
                return -1;
        }
 
-       self = kzalloc(sizeof(*self), GFP_KERNEL);
+       self = devm_kzalloc(&func->dev, sizeof(*self), GFP_KERNEL);
        if (!self) {
                pr_err("Can't allocate SPI hwbus_priv.");
                return -ENOMEM;
@@ -424,7 +424,6 @@ static int cw1200_spi_probe(struct spi_device *func)
        if (status) {
                cw1200_spi_irq_unsubscribe(self);
                cw1200_spi_off(plat_data);
-               kfree(self);
        }
 
        return status;
@@ -441,7 +440,6 @@ static int cw1200_spi_disconnect(struct spi_device *func)
                        cw1200_core_release(self->core);
                        self->core = NULL;
                }
-               kfree(self);
        }
        cw1200_spi_off(dev_get_platdata(&func->dev));