All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] Use devm_kzalloc in bluetooth drivers
@ 2012-07-27  7:08 Sachin Kamat
  2012-07-27  7:08 ` [PATCH 01/11] Bluetooth: Use devm_kzalloc in bcm203x.c file Sachin Kamat
                   ` (12 more replies)
  0 siblings, 13 replies; 16+ messages in thread
From: Sachin Kamat @ 2012-07-27  7:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, johan.hedberg, sachin.kamat, patches

devm_kzalloc() is a device managed function which eliminates the need
to free memory explicitly thereby saving some cleanup code and making
the exit code simpler.

This series is based on the following tree and is compile tested.
git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git

Sachin Kamat (11):
  Bluetooth: Use devm_kzalloc in bcm203x.c file.
  Bluetooth: Use devm_kzalloc in bfusb.c file
  Bluetooth: Use devm_kzalloc in bluecard_cs.c file
  Bluetooth: Use devm_kzalloc in bpa10x.c file
  Bluetooth: Use devm_kzalloc in bt3c_cs.c file
  Bluetooth: Use devm_kzalloc in btmrvl_sdio.c file
  Bluetooth: Use devm_kzalloc in btsdio.c file
  Bluetooth: Use devm_kzalloc in btuart_cs.c file
  Bluetooth: Use devm_kzalloc in btusb.c file
  Bluetooth: Use devm_kzalloc in btwilink.c file
  Bluetooth: Use devm_kzalloc in dtl1_cs.c file

 drivers/bluetooth/bcm203x.c     |    8 +-------
 drivers/bluetooth/bfusb.c       |   12 ++++--------
 drivers/bluetooth/bluecard_cs.c |    5 +----
 drivers/bluetooth/bpa10x.c      |    8 ++------
 drivers/bluetooth/bt3c_cs.c     |    5 +----
 drivers/bluetooth/btmrvl_sdio.c |   15 ++++-----------
 drivers/bluetooth/btsdio.c      |    8 ++------
 drivers/bluetooth/btuart_cs.c   |    5 +----
 drivers/bluetooth/btusb.c       |   13 +++----------
 drivers/bluetooth/btwilink.c    |    8 ++------
 drivers/bluetooth/dtl1_cs.c     |    3 +--
 11 files changed, 22 insertions(+), 68 deletions(-)

-- 
1.7.4.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 01/11] Bluetooth: Use devm_kzalloc in bcm203x.c file.
  2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
@ 2012-07-27  7:08 ` Sachin Kamat
  2012-07-27  7:08 ` [PATCH 02/11] Bluetooth: Use devm_kzalloc in bfusb.c file Sachin Kamat
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Sachin Kamat @ 2012-07-27  7:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, johan.hedberg, sachin.kamat, patches

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/bluetooth/bcm203x.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index 37ae175..364f82b 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -177,7 +177,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
 	if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
 		return -ENODEV;
 
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL);
 	if (!data) {
 		BT_ERR("Can't allocate memory for data structure");
 		return -ENOMEM;
@@ -189,14 +189,12 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
 	data->urb = usb_alloc_urb(0, GFP_KERNEL);
 	if (!data->urb) {
 		BT_ERR("Can't allocate URB");
-		kfree(data);
 		return -ENOMEM;
 	}
 
 	if (request_firmware(&firmware, "BCM2033-MD.hex", &udev->dev) < 0) {
 		BT_ERR("Mini driver request failed");
 		usb_free_urb(data->urb);
-		kfree(data);
 		return -EIO;
 	}
 
@@ -209,7 +207,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
 		BT_ERR("Can't allocate memory for mini driver");
 		release_firmware(firmware);
 		usb_free_urb(data->urb);
-		kfree(data);
 		return -ENOMEM;
 	}
 
@@ -224,7 +221,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
 		BT_ERR("Firmware request failed");
 		usb_free_urb(data->urb);
 		kfree(data->buffer);
-		kfree(data);
 		return -EIO;
 	}
 
@@ -236,7 +232,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
 		release_firmware(firmware);
 		usb_free_urb(data->urb);
 		kfree(data->buffer);
-		kfree(data);
 		return -ENOMEM;
 	}
 
@@ -271,7 +266,6 @@ static void bcm203x_disconnect(struct usb_interface *intf)
 	usb_free_urb(data->urb);
 	kfree(data->fw_data);
 	kfree(data->buffer);
-	kfree(data);
 }
 
 static struct usb_driver bcm203x_driver = {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 02/11] Bluetooth: Use devm_kzalloc in bfusb.c file
  2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
  2012-07-27  7:08 ` [PATCH 01/11] Bluetooth: Use devm_kzalloc in bcm203x.c file Sachin Kamat
@ 2012-07-27  7:08 ` Sachin Kamat
  2012-07-27  7:08 ` [PATCH 03/11] Bluetooth: Use devm_kzalloc in bluecard_cs.c file Sachin Kamat
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Sachin Kamat @ 2012-07-27  7:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, johan.hedberg, sachin.kamat, patches

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/bluetooth/bfusb.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
index 32e8251..995aee9 100644
--- a/drivers/bluetooth/bfusb.c
+++ b/drivers/bluetooth/bfusb.c
@@ -653,7 +653,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 	}
 
 	/* Initialize control structure and load firmware */
-	data = kzalloc(sizeof(struct bfusb_data), GFP_KERNEL);
+	data = devm_kzalloc(&intf->dev, sizeof(struct bfusb_data), GFP_KERNEL);
 	if (!data) {
 		BT_ERR("Can't allocate memory for control structure");
 		goto done;
@@ -674,7 +674,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 
 	if (request_firmware(&firmware, "bfubase.frm", &udev->dev) < 0) {
 		BT_ERR("Firmware request failed");
-		goto error;
+		goto done;
 	}
 
 	BT_DBG("firmware data %p size %zu", firmware->data, firmware->size);
@@ -690,7 +690,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 	hdev = hci_alloc_dev();
 	if (!hdev) {
 		BT_ERR("Can't allocate HCI device");
-		goto error;
+		goto done;
 	}
 
 	data->hdev = hdev;
@@ -708,7 +708,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 	if (hci_register_dev(hdev) < 0) {
 		BT_ERR("Can't register HCI device");
 		hci_free_dev(hdev);
-		goto error;
+		goto done;
 	}
 
 	usb_set_intfdata(intf, data);
@@ -718,9 +718,6 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 release:
 	release_firmware(firmware);
 
-error:
-	kfree(data);
-
 done:
 	return -EIO;
 }
@@ -741,7 +738,6 @@ static void bfusb_disconnect(struct usb_interface *intf)
 
 	hci_unregister_dev(hdev);
 	hci_free_dev(hdev);
-	kfree(data);
 }
 
 static struct usb_driver bfusb_driver = {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 03/11] Bluetooth: Use devm_kzalloc in bluecard_cs.c file
  2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
  2012-07-27  7:08 ` [PATCH 01/11] Bluetooth: Use devm_kzalloc in bcm203x.c file Sachin Kamat
  2012-07-27  7:08 ` [PATCH 02/11] Bluetooth: Use devm_kzalloc in bfusb.c file Sachin Kamat
@ 2012-07-27  7:08 ` Sachin Kamat
  2012-07-27  7:08 ` [PATCH 04/11] Bluetooth: Use devm_kzalloc in bpa10x.c file Sachin Kamat
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Sachin Kamat @ 2012-07-27  7:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, johan.hedberg, sachin.kamat, patches

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/bluetooth/bluecard_cs.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index 66c3a67..0c0838d 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -849,7 +849,7 @@ static int bluecard_probe(struct pcmcia_device *link)
 	bluecard_info_t *info;
 
 	/* Create new info device */
-	info = kzalloc(sizeof(*info), GFP_KERNEL);
+	info = devm_kzalloc(&link->dev, sizeof(*info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
@@ -864,10 +864,7 @@ static int bluecard_probe(struct pcmcia_device *link)
 
 static void bluecard_detach(struct pcmcia_device *link)
 {
-	bluecard_info_t *info = link->priv;
-
 	bluecard_release(link);
-	kfree(info);
 }
 
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 04/11] Bluetooth: Use devm_kzalloc in bpa10x.c file
  2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
                   ` (2 preceding siblings ...)
  2012-07-27  7:08 ` [PATCH 03/11] Bluetooth: Use devm_kzalloc in bluecard_cs.c file Sachin Kamat
@ 2012-07-27  7:08 ` Sachin Kamat
  2012-07-27  7:08 ` [PATCH 05/11] Bluetooth: Use devm_kzalloc in bt3c_cs.c file Sachin Kamat
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Sachin Kamat @ 2012-07-27  7:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, johan.hedberg, sachin.kamat, patches

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/bluetooth/bpa10x.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index 29caaed..2fe4a80 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -443,7 +443,7 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id *
 	if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
 		return -ENODEV;
 
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
@@ -453,10 +453,8 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id *
 	init_usb_anchor(&data->rx_anchor);
 
 	hdev = hci_alloc_dev();
-	if (!hdev) {
-		kfree(data);
+	if (!hdev)
 		return -ENOMEM;
-	}
 
 	hdev->bus = HCI_USB;
 	hci_set_drvdata(hdev, data);
@@ -475,7 +473,6 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id *
 	err = hci_register_dev(hdev);
 	if (err < 0) {
 		hci_free_dev(hdev);
-		kfree(data);
 		return err;
 	}
 
@@ -500,7 +497,6 @@ static void bpa10x_disconnect(struct usb_interface *intf)
 	hci_free_dev(data->hdev);
 	kfree_skb(data->rx_skb[0]);
 	kfree_skb(data->rx_skb[1]);
-	kfree(data);
 }
 
 static struct usb_driver bpa10x_driver = {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 05/11] Bluetooth: Use devm_kzalloc in bt3c_cs.c file
  2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
                   ` (3 preceding siblings ...)
  2012-07-27  7:08 ` [PATCH 04/11] Bluetooth: Use devm_kzalloc in bpa10x.c file Sachin Kamat
@ 2012-07-27  7:08 ` Sachin Kamat
  2012-07-27  7:08 ` [PATCH 06/11] Bluetooth: Use devm_kzalloc in btmrvl_sdio.c file Sachin Kamat
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Sachin Kamat @ 2012-07-27  7:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, johan.hedberg, sachin.kamat, patches

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/bluetooth/bt3c_cs.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 8925b6d..7ffd3f4 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -638,7 +638,7 @@ static int bt3c_probe(struct pcmcia_device *link)
 	bt3c_info_t *info;
 
 	/* Create new info device */
-	info = kzalloc(sizeof(*info), GFP_KERNEL);
+	info = devm_kzalloc(&link->dev, sizeof(*info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
@@ -654,10 +654,7 @@ static int bt3c_probe(struct pcmcia_device *link)
 
 static void bt3c_detach(struct pcmcia_device *link)
 {
-	bt3c_info_t *info = link->priv;
-
 	bt3c_release(link);
-	kfree(info);
 }
 
 static int bt3c_check_config(struct pcmcia_device *p_dev, void *priv_data)
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 06/11] Bluetooth: Use devm_kzalloc in btmrvl_sdio.c file
  2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
                   ` (4 preceding siblings ...)
  2012-07-27  7:08 ` [PATCH 05/11] Bluetooth: Use devm_kzalloc in bt3c_cs.c file Sachin Kamat
@ 2012-07-27  7:08 ` Sachin Kamat
  2012-07-27  7:08 ` [PATCH 07/11] Bluetooth: Use devm_kzalloc in btsdio.c file Sachin Kamat
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Sachin Kamat @ 2012-07-27  7:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, johan.hedberg, sachin.kamat, patches

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/bluetooth/btmrvl_sdio.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index 6a9e971..03b3acb 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -956,11 +956,9 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
 	BT_INFO("vendor=0x%x, device=0x%x, class=%d, fn=%d",
 			id->vendor, id->device, id->class, func->num);
 
-	card = kzalloc(sizeof(*card), GFP_KERNEL);
-	if (!card) {
-		ret = -ENOMEM;
-		goto done;
-	}
+	card = devm_kzalloc(&func->dev, sizeof(*card), GFP_KERNEL);
+	if (!card)
+		return -ENOMEM;
 
 	card->func = func;
 
@@ -974,8 +972,7 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
 
 	if (btmrvl_sdio_register_dev(card) < 0) {
 		BT_ERR("Failed to register BT device!");
-		ret = -ENODEV;
-		goto free_card;
+		return -ENODEV;
 	}
 
 	/* Disable the interrupts on the card */
@@ -1023,9 +1020,6 @@ disable_host_int:
 	btmrvl_sdio_disable_host_int(card);
 unreg_dev:
 	btmrvl_sdio_unregister_dev(card);
-free_card:
-	kfree(card);
-done:
 	return ret;
 }
 
@@ -1047,7 +1041,6 @@ static void btmrvl_sdio_remove(struct sdio_func *func)
 			BT_DBG("unregester dev");
 			btmrvl_sdio_unregister_dev(card);
 			btmrvl_remove_card(card->priv);
-			kfree(card);
 		}
 	}
 }
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 07/11] Bluetooth: Use devm_kzalloc in btsdio.c file
  2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
                   ` (5 preceding siblings ...)
  2012-07-27  7:08 ` [PATCH 06/11] Bluetooth: Use devm_kzalloc in btmrvl_sdio.c file Sachin Kamat
@ 2012-07-27  7:08 ` Sachin Kamat
  2012-07-27  7:08 ` [PATCH 08/11] Bluetooth: Use devm_kzalloc in btuart_cs.c file Sachin Kamat
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Sachin Kamat @ 2012-07-27  7:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, johan.hedberg, sachin.kamat, patches

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/bluetooth/btsdio.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c
index e10ea03..4a99097 100644
--- a/drivers/bluetooth/btsdio.c
+++ b/drivers/bluetooth/btsdio.c
@@ -304,7 +304,7 @@ static int btsdio_probe(struct sdio_func *func,
 		tuple = tuple->next;
 	}
 
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	data = devm_kzalloc(&func->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
@@ -315,10 +315,8 @@ static int btsdio_probe(struct sdio_func *func,
 	skb_queue_head_init(&data->txq);
 
 	hdev = hci_alloc_dev();
-	if (!hdev) {
-		kfree(data);
+	if (!hdev)
 		return -ENOMEM;
-	}
 
 	hdev->bus = HCI_SDIO;
 	hci_set_drvdata(hdev, data);
@@ -340,7 +338,6 @@ static int btsdio_probe(struct sdio_func *func,
 	err = hci_register_dev(hdev);
 	if (err < 0) {
 		hci_free_dev(hdev);
-		kfree(data);
 		return err;
 	}
 
@@ -366,7 +363,6 @@ static void btsdio_remove(struct sdio_func *func)
 	hci_unregister_dev(hdev);
 
 	hci_free_dev(hdev);
-	kfree(data);
 }
 
 static struct sdio_driver btsdio_driver = {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 08/11] Bluetooth: Use devm_kzalloc in btuart_cs.c file
  2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
                   ` (6 preceding siblings ...)
  2012-07-27  7:08 ` [PATCH 07/11] Bluetooth: Use devm_kzalloc in btsdio.c file Sachin Kamat
@ 2012-07-27  7:08 ` Sachin Kamat
  2012-07-27  7:08 ` [PATCH 09/11] Bluetooth: Use devm_kzalloc in btusb.c file Sachin Kamat
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Sachin Kamat @ 2012-07-27  7:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, johan.hedberg, sachin.kamat, patches

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/bluetooth/btuart_cs.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 21e803a..2f510a8 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -567,7 +567,7 @@ static int btuart_probe(struct pcmcia_device *link)
 	btuart_info_t *info;
 
 	/* Create new info device */
-	info = kzalloc(sizeof(*info), GFP_KERNEL);
+	info = devm_kzalloc(&link->dev, sizeof(*info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
@@ -583,10 +583,7 @@ static int btuart_probe(struct pcmcia_device *link)
 
 static void btuart_detach(struct pcmcia_device *link)
 {
-	btuart_info_t *info = link->priv;
-
 	btuart_release(link);
-	kfree(info);
 }
 
 static int btuart_check_config(struct pcmcia_device *p_dev, void *priv_data)
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 09/11] Bluetooth: Use devm_kzalloc in btusb.c file
  2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
                   ` (7 preceding siblings ...)
  2012-07-27  7:08 ` [PATCH 08/11] Bluetooth: Use devm_kzalloc in btuart_cs.c file Sachin Kamat
@ 2012-07-27  7:08 ` Sachin Kamat
  2012-07-27  7:08 ` [PATCH 10/11] Bluetooth: Use devm_kzalloc in btwilink.c file Sachin Kamat
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Sachin Kamat @ 2012-07-27  7:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, johan.hedberg, sachin.kamat, patches

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/bluetooth/btusb.c |   13 +++----------
 1 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index e272214..f637c25 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -952,7 +952,7 @@ static int btusb_probe(struct usb_interface *intf,
 			return -ENODEV;
 	}
 
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
@@ -975,10 +975,8 @@ static int btusb_probe(struct usb_interface *intf,
 		}
 	}
 
-	if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) {
-		kfree(data);
+	if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep)
 		return -ENODEV;
-	}
 
 	data->cmdreq_type = USB_TYPE_CLASS;
 
@@ -998,10 +996,8 @@ static int btusb_probe(struct usb_interface *intf,
 	init_usb_anchor(&data->deferred);
 
 	hdev = hci_alloc_dev();
-	if (!hdev) {
-		kfree(data);
+	if (!hdev)
 		return -ENOMEM;
-	}
 
 	hdev->bus = HCI_USB;
 	hci_set_drvdata(hdev, data);
@@ -1069,7 +1065,6 @@ static int btusb_probe(struct usb_interface *intf,
 							data->isoc, data);
 		if (err < 0) {
 			hci_free_dev(hdev);
-			kfree(data);
 			return err;
 		}
 	}
@@ -1077,7 +1072,6 @@ static int btusb_probe(struct usb_interface *intf,
 	err = hci_register_dev(hdev);
 	if (err < 0) {
 		hci_free_dev(hdev);
-		kfree(data);
 		return err;
 	}
 
@@ -1110,7 +1104,6 @@ static void btusb_disconnect(struct usb_interface *intf)
 		usb_driver_release_interface(&btusb_driver, data->isoc);
 
 	hci_free_dev(hdev);
-	kfree(data);
 }
 
 #ifdef CONFIG_PM
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 10/11] Bluetooth: Use devm_kzalloc in btwilink.c file
  2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
                   ` (8 preceding siblings ...)
  2012-07-27  7:08 ` [PATCH 09/11] Bluetooth: Use devm_kzalloc in btusb.c file Sachin Kamat
@ 2012-07-27  7:08 ` Sachin Kamat
  2012-07-27  7:08 ` [PATCH 11/11] Bluetooth: Use devm_kzalloc in dtl1_cs.c file Sachin Kamat
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Sachin Kamat @ 2012-07-27  7:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, johan.hedberg, sachin.kamat, patches

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/bluetooth/btwilink.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
index 8869469..4ad7b35 100644
--- a/drivers/bluetooth/btwilink.c
+++ b/drivers/bluetooth/btwilink.c
@@ -297,16 +297,14 @@ static int bt_ti_probe(struct platform_device *pdev)
 	struct hci_dev *hdev;
 	int err;
 
-	hst = kzalloc(sizeof(struct ti_st), GFP_KERNEL);
+	hst = devm_kzalloc(&pdev->dev, sizeof(struct ti_st), GFP_KERNEL);
 	if (!hst)
 		return -ENOMEM;
 
 	/* Expose "hciX" device to user space */
 	hdev = hci_alloc_dev();
-	if (!hdev) {
-		kfree(hst);
+	if (!hdev)
 		return -ENOMEM;
-	}
 
 	BT_DBG("hdev %p", hdev);
 
@@ -321,7 +319,6 @@ static int bt_ti_probe(struct platform_device *pdev)
 	err = hci_register_dev(hdev);
 	if (err < 0) {
 		BT_ERR("Can't register HCI device error %d", err);
-		kfree(hst);
 		hci_free_dev(hdev);
 		return err;
 	}
@@ -347,7 +344,6 @@ static int bt_ti_remove(struct platform_device *pdev)
 	hci_unregister_dev(hdev);
 
 	hci_free_dev(hdev);
-	kfree(hst);
 
 	dev_set_drvdata(&pdev->dev, NULL);
 	return 0;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 11/11] Bluetooth: Use devm_kzalloc in dtl1_cs.c file
  2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
                   ` (9 preceding siblings ...)
  2012-07-27  7:08 ` [PATCH 10/11] Bluetooth: Use devm_kzalloc in btwilink.c file Sachin Kamat
@ 2012-07-27  7:08 ` Sachin Kamat
  2012-08-06 16:08 ` [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
  2012-08-06 17:30 ` Gustavo Padovan
  12 siblings, 0 replies; 16+ messages in thread
From: Sachin Kamat @ 2012-07-27  7:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, johan.hedberg, sachin.kamat, patches

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/bluetooth/dtl1_cs.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index 97a7784..036cb36 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -550,7 +550,7 @@ static int dtl1_probe(struct pcmcia_device *link)
 	dtl1_info_t *info;
 
 	/* Create new info device */
-	info = kzalloc(sizeof(*info), GFP_KERNEL);
+	info = devm_kzalloc(&link->dev, sizeof(*info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
@@ -569,7 +569,6 @@ static void dtl1_detach(struct pcmcia_device *link)
 
 	dtl1_close(info);
 	pcmcia_disable_device(link);
-	kfree(info);
 }
 
 static int dtl1_confcheck(struct pcmcia_device *p_dev, void *priv_data)
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 00/11] Use devm_kzalloc in bluetooth drivers
  2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
                   ` (10 preceding siblings ...)
  2012-07-27  7:08 ` [PATCH 11/11] Bluetooth: Use devm_kzalloc in dtl1_cs.c file Sachin Kamat
@ 2012-08-06 16:08 ` Sachin Kamat
  2012-08-06 16:37   ` Marcel Holtmann
  2012-08-06 17:30 ` Gustavo Padovan
  12 siblings, 1 reply; 16+ messages in thread
From: Sachin Kamat @ 2012-08-06 16:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, gustavo, johan.hedberg, sachin.kamat, patches

Hi,

Any comments regarding this patch set?

On 27 July 2012 12:38, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> devm_kzalloc() is a device managed function which eliminates the need
> to free memory explicitly thereby saving some cleanup code and making
> the exit code simpler.
>
> This series is based on the following tree and is compile tested.
> git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git
>
> Sachin Kamat (11):
>   Bluetooth: Use devm_kzalloc in bcm203x.c file.
>   Bluetooth: Use devm_kzalloc in bfusb.c file
>   Bluetooth: Use devm_kzalloc in bluecard_cs.c file
>   Bluetooth: Use devm_kzalloc in bpa10x.c file
>   Bluetooth: Use devm_kzalloc in bt3c_cs.c file
>   Bluetooth: Use devm_kzalloc in btmrvl_sdio.c file
>   Bluetooth: Use devm_kzalloc in btsdio.c file
>   Bluetooth: Use devm_kzalloc in btuart_cs.c file
>   Bluetooth: Use devm_kzalloc in btusb.c file
>   Bluetooth: Use devm_kzalloc in btwilink.c file
>   Bluetooth: Use devm_kzalloc in dtl1_cs.c file
>
>  drivers/bluetooth/bcm203x.c     |    8 +-------
>  drivers/bluetooth/bfusb.c       |   12 ++++--------
>  drivers/bluetooth/bluecard_cs.c |    5 +----
>  drivers/bluetooth/bpa10x.c      |    8 ++------
>  drivers/bluetooth/bt3c_cs.c     |    5 +----
>  drivers/bluetooth/btmrvl_sdio.c |   15 ++++-----------
>  drivers/bluetooth/btsdio.c      |    8 ++------
>  drivers/bluetooth/btuart_cs.c   |    5 +----
>  drivers/bluetooth/btusb.c       |   13 +++----------
>  drivers/bluetooth/btwilink.c    |    8 ++------
>  drivers/bluetooth/dtl1_cs.c     |    3 +--
>  11 files changed, 22 insertions(+), 68 deletions(-)
>
> --
> 1.7.4.1
>



-- 
With warm regards,
Sachin

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 00/11] Use devm_kzalloc in bluetooth drivers
  2012-08-06 16:08 ` [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
@ 2012-08-06 16:37   ` Marcel Holtmann
  0 siblings, 0 replies; 16+ messages in thread
From: Marcel Holtmann @ 2012-08-06 16:37 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-bluetooth, gustavo, johan.hedberg, patches

Hi Sachin,

> Any comments regarding this patch set?

I am fine with it.

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 00/11] Use devm_kzalloc in bluetooth drivers
  2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
                   ` (11 preceding siblings ...)
  2012-08-06 16:08 ` [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
@ 2012-08-06 17:30 ` Gustavo Padovan
  2012-08-07  3:25   ` Sachin Kamat
  12 siblings, 1 reply; 16+ messages in thread
From: Gustavo Padovan @ 2012-08-06 17:30 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-bluetooth, marcel, johan.hedberg, patches

Hi Sachin,

* Sachin Kamat <sachin.kamat@linaro.org> [2012-07-27 12:38:30 +0530]:

> devm_kzalloc() is a device managed function which eliminates the need
> to free memory explicitly thereby saving some cleanup code and making
> the exit code simpler.
> 
> This series is based on the following tree and is compile tested.
> git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git
> 
> Sachin Kamat (11):
>   Bluetooth: Use devm_kzalloc in bcm203x.c file.
>   Bluetooth: Use devm_kzalloc in bfusb.c file
>   Bluetooth: Use devm_kzalloc in bluecard_cs.c file
>   Bluetooth: Use devm_kzalloc in bpa10x.c file
>   Bluetooth: Use devm_kzalloc in bt3c_cs.c file
>   Bluetooth: Use devm_kzalloc in btmrvl_sdio.c file
>   Bluetooth: Use devm_kzalloc in btsdio.c file
>   Bluetooth: Use devm_kzalloc in btuart_cs.c file
>   Bluetooth: Use devm_kzalloc in btusb.c file
>   Bluetooth: Use devm_kzalloc in btwilink.c file
>   Bluetooth: Use devm_kzalloc in dtl1_cs.c file
> 
>  drivers/bluetooth/bcm203x.c     |    8 +-------
>  drivers/bluetooth/bfusb.c       |   12 ++++--------
>  drivers/bluetooth/bluecard_cs.c |    5 +----
>  drivers/bluetooth/bpa10x.c      |    8 ++------
>  drivers/bluetooth/bt3c_cs.c     |    5 +----
>  drivers/bluetooth/btmrvl_sdio.c |   15 ++++-----------
>  drivers/bluetooth/btsdio.c      |    8 ++------
>  drivers/bluetooth/btuart_cs.c   |    5 +----
>  drivers/bluetooth/btusb.c       |   13 +++----------
>  drivers/bluetooth/btwilink.c    |    8 ++------
>  drivers/bluetooth/dtl1_cs.c     |    3 +--
>  11 files changed, 22 insertions(+), 68 deletions(-)

The whole series have been applied to bluetooth-next. Thanks.

	Gustavo

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 00/11] Use devm_kzalloc in bluetooth drivers
  2012-08-06 17:30 ` Gustavo Padovan
@ 2012-08-07  3:25   ` Sachin Kamat
  0 siblings, 0 replies; 16+ messages in thread
From: Sachin Kamat @ 2012-08-07  3:25 UTC (permalink / raw)
  To: Gustavo Padovan, Sachin Kamat, linux-bluetooth, marcel,
	johan.hedberg, patches

Thanks Marcel and Gustavo.


On 6 August 2012 23:00, Gustavo Padovan <gustavo@padovan.org> wrote:
> Hi Sachin,
>
> * Sachin Kamat <sachin.kamat@linaro.org> [2012-07-27 12:38:30 +0530]:
>
>> devm_kzalloc() is a device managed function which eliminates the need
>> to free memory explicitly thereby saving some cleanup code and making
>> the exit code simpler.
>>
>> This series is based on the following tree and is compile tested.
>> git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git
>>
>> Sachin Kamat (11):
>>   Bluetooth: Use devm_kzalloc in bcm203x.c file.
>>   Bluetooth: Use devm_kzalloc in bfusb.c file
>>   Bluetooth: Use devm_kzalloc in bluecard_cs.c file
>>   Bluetooth: Use devm_kzalloc in bpa10x.c file
>>   Bluetooth: Use devm_kzalloc in bt3c_cs.c file
>>   Bluetooth: Use devm_kzalloc in btmrvl_sdio.c file
>>   Bluetooth: Use devm_kzalloc in btsdio.c file
>>   Bluetooth: Use devm_kzalloc in btuart_cs.c file
>>   Bluetooth: Use devm_kzalloc in btusb.c file
>>   Bluetooth: Use devm_kzalloc in btwilink.c file
>>   Bluetooth: Use devm_kzalloc in dtl1_cs.c file
>>
>>  drivers/bluetooth/bcm203x.c     |    8 +-------
>>  drivers/bluetooth/bfusb.c       |   12 ++++--------
>>  drivers/bluetooth/bluecard_cs.c |    5 +----
>>  drivers/bluetooth/bpa10x.c      |    8 ++------
>>  drivers/bluetooth/bt3c_cs.c     |    5 +----
>>  drivers/bluetooth/btmrvl_sdio.c |   15 ++++-----------
>>  drivers/bluetooth/btsdio.c      |    8 ++------
>>  drivers/bluetooth/btuart_cs.c   |    5 +----
>>  drivers/bluetooth/btusb.c       |   13 +++----------
>>  drivers/bluetooth/btwilink.c    |    8 ++------
>>  drivers/bluetooth/dtl1_cs.c     |    3 +--
>>  11 files changed, 22 insertions(+), 68 deletions(-)
>
> The whole series have been applied to bluetooth-next. Thanks.
>
>         Gustavo



-- 
With warm regards,
Sachin

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-08-07  3:25 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-27  7:08 [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
2012-07-27  7:08 ` [PATCH 01/11] Bluetooth: Use devm_kzalloc in bcm203x.c file Sachin Kamat
2012-07-27  7:08 ` [PATCH 02/11] Bluetooth: Use devm_kzalloc in bfusb.c file Sachin Kamat
2012-07-27  7:08 ` [PATCH 03/11] Bluetooth: Use devm_kzalloc in bluecard_cs.c file Sachin Kamat
2012-07-27  7:08 ` [PATCH 04/11] Bluetooth: Use devm_kzalloc in bpa10x.c file Sachin Kamat
2012-07-27  7:08 ` [PATCH 05/11] Bluetooth: Use devm_kzalloc in bt3c_cs.c file Sachin Kamat
2012-07-27  7:08 ` [PATCH 06/11] Bluetooth: Use devm_kzalloc in btmrvl_sdio.c file Sachin Kamat
2012-07-27  7:08 ` [PATCH 07/11] Bluetooth: Use devm_kzalloc in btsdio.c file Sachin Kamat
2012-07-27  7:08 ` [PATCH 08/11] Bluetooth: Use devm_kzalloc in btuart_cs.c file Sachin Kamat
2012-07-27  7:08 ` [PATCH 09/11] Bluetooth: Use devm_kzalloc in btusb.c file Sachin Kamat
2012-07-27  7:08 ` [PATCH 10/11] Bluetooth: Use devm_kzalloc in btwilink.c file Sachin Kamat
2012-07-27  7:08 ` [PATCH 11/11] Bluetooth: Use devm_kzalloc in dtl1_cs.c file Sachin Kamat
2012-08-06 16:08 ` [PATCH 00/11] Use devm_kzalloc in bluetooth drivers Sachin Kamat
2012-08-06 16:37   ` Marcel Holtmann
2012-08-06 17:30 ` Gustavo Padovan
2012-08-07  3:25   ` Sachin Kamat

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.