Skip to contentSkip to conversation

cw1200: Introduce the use of devm_kzalloc

PATCH New Himangi Saraogi 1 participant 1 message Aug 2, 2014 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cw1200: Introduce the use of devm_kzalloc

This patch introduces the use of devm_kzalloc and does away with the kfrees in the probe and remove functions.

---
 drivers/net/wireless/cw1200/cw1200_spi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/wireless/cw1200/cw1200_spi.c +1 -3
index 40078f5..964b64a 100644
@@ -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));
 
Signature · 1 line
1.9.1