Bluetooth: Use devm_kzalloc in btwilink.c file

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sat Sep 29 10:59:26 EDT 2012


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=4f8d81584964730b08753da34f1e3fb7981cf742
Commit:     4f8d81584964730b08753da34f1e3fb7981cf742
Parent:     98921dbd00c4e2e4bdd56423cb5edf98d57b45f7
Author:     Sachin Kamat <sachin.kamat at linaro.org>
AuthorDate: Fri Jul 27 12:38:40 2012 +0530
Committer:  Gustavo Padovan <gustavo.padovan at collabora.co.uk>
CommitDate: Mon Aug 6 15:03:02 2012 -0300

    Bluetooth: Use devm_kzalloc in btwilink.c file
    
    devm_kzalloc() eliminates the need to free memory explicitly
    thereby saving some cleanup code.
    
    Signed-off-by: Sachin Kamat <sachin.kamat at linaro.org>
    Acked-by: Marcel Holtmann <marcel at holtmann.org>
    Signed-off-by: Gustavo Padovan <gustavo.padovan at collabora.co.uk>
---
 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;



More information about the linux-mtd-cvs mailing list