Commit 0213cd8d authored by Sachin Kamat's avatar Sachin Kamat Committed by Gustavo Padovan

Bluetooth: Use devm_kzalloc in bfusb.c file

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent 9357cc60
...@@ -653,7 +653,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i ...@@ -653,7 +653,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
} }
/* Initialize control structure and load firmware */ /* 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) { if (!data) {
BT_ERR("Can't allocate memory for control structure"); BT_ERR("Can't allocate memory for control structure");
goto done; goto done;
...@@ -674,7 +674,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i ...@@ -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) { if (request_firmware(&firmware, "bfubase.frm", &udev->dev) < 0) {
BT_ERR("Firmware request failed"); BT_ERR("Firmware request failed");
goto error; goto done;
} }
BT_DBG("firmware data %p size %zu", firmware->data, firmware->size); 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 ...@@ -690,7 +690,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
hdev = hci_alloc_dev(); hdev = hci_alloc_dev();
if (!hdev) { if (!hdev) {
BT_ERR("Can't allocate HCI device"); BT_ERR("Can't allocate HCI device");
goto error; goto done;
} }
data->hdev = hdev; data->hdev = hdev;
...@@ -708,7 +708,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i ...@@ -708,7 +708,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
if (hci_register_dev(hdev) < 0) { if (hci_register_dev(hdev) < 0) {
BT_ERR("Can't register HCI device"); BT_ERR("Can't register HCI device");
hci_free_dev(hdev); hci_free_dev(hdev);
goto error; goto done;
} }
usb_set_intfdata(intf, data); usb_set_intfdata(intf, data);
...@@ -718,9 +718,6 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i ...@@ -718,9 +718,6 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
release: release:
release_firmware(firmware); release_firmware(firmware);
error:
kfree(data);
done: done:
return -EIO; return -EIO;
} }
...@@ -741,7 +738,6 @@ static void bfusb_disconnect(struct usb_interface *intf) ...@@ -741,7 +738,6 @@ static void bfusb_disconnect(struct usb_interface *intf)
hci_unregister_dev(hdev); hci_unregister_dev(hdev);
hci_free_dev(hdev); hci_free_dev(hdev);
kfree(data);
} }
static struct usb_driver bfusb_driver = { static struct usb_driver bfusb_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment