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@linaro.org> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
This commit is contained in:
parent
98921dbd00
commit
4f8d815849
1 changed files with 2 additions and 6 deletions
|
@ -297,16 +297,14 @@ static int bt_ti_probe(struct platform_device *pdev)
|
||||||
struct hci_dev *hdev;
|
struct hci_dev *hdev;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
hst = kzalloc(sizeof(struct ti_st), GFP_KERNEL);
|
hst = devm_kzalloc(&pdev->dev, sizeof(struct ti_st), GFP_KERNEL);
|
||||||
if (!hst)
|
if (!hst)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Expose "hciX" device to user space */
|
/* Expose "hciX" device to user space */
|
||||||
hdev = hci_alloc_dev();
|
hdev = hci_alloc_dev();
|
||||||
if (!hdev) {
|
if (!hdev)
|
||||||
kfree(hst);
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
BT_DBG("hdev %p", hdev);
|
BT_DBG("hdev %p", hdev);
|
||||||
|
|
||||||
|
@ -321,7 +319,6 @@ static int bt_ti_probe(struct platform_device *pdev)
|
||||||
err = hci_register_dev(hdev);
|
err = hci_register_dev(hdev);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
BT_ERR("Can't register HCI device error %d", err);
|
BT_ERR("Can't register HCI device error %d", err);
|
||||||
kfree(hst);
|
|
||||||
hci_free_dev(hdev);
|
hci_free_dev(hdev);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -347,7 +344,6 @@ static int bt_ti_remove(struct platform_device *pdev)
|
||||||
hci_unregister_dev(hdev);
|
hci_unregister_dev(hdev);
|
||||||
|
|
||||||
hci_free_dev(hdev);
|
hci_free_dev(hdev);
|
||||||
kfree(hst);
|
|
||||||
|
|
||||||
dev_set_drvdata(&pdev->dev, NULL);
|
dev_set_drvdata(&pdev->dev, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue