Commit 9357cc60 authored by Sachin Kamat's avatar Sachin Kamat Committed by Gustavo Padovan

Bluetooth: Use devm_kzalloc in bcm203x.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 de9b9212
...@@ -177,7 +177,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id ...@@ -177,7 +177,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
if (intf->cur_altsetting->desc.bInterfaceNumber != 0) if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
return -ENODEV; return -ENODEV;
data = kzalloc(sizeof(*data), GFP_KERNEL); data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL);
if (!data) { if (!data) {
BT_ERR("Can't allocate memory for data structure"); BT_ERR("Can't allocate memory for data structure");
return -ENOMEM; return -ENOMEM;
...@@ -189,14 +189,12 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id ...@@ -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); data->urb = usb_alloc_urb(0, GFP_KERNEL);
if (!data->urb) { if (!data->urb) {
BT_ERR("Can't allocate URB"); BT_ERR("Can't allocate URB");
kfree(data);
return -ENOMEM; return -ENOMEM;
} }
if (request_firmware(&firmware, "BCM2033-MD.hex", &udev->dev) < 0) { if (request_firmware(&firmware, "BCM2033-MD.hex", &udev->dev) < 0) {
BT_ERR("Mini driver request failed"); BT_ERR("Mini driver request failed");
usb_free_urb(data->urb); usb_free_urb(data->urb);
kfree(data);
return -EIO; return -EIO;
} }
...@@ -209,7 +207,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id ...@@ -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"); BT_ERR("Can't allocate memory for mini driver");
release_firmware(firmware); release_firmware(firmware);
usb_free_urb(data->urb); usb_free_urb(data->urb);
kfree(data);
return -ENOMEM; return -ENOMEM;
} }
...@@ -224,7 +221,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id ...@@ -224,7 +221,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
BT_ERR("Firmware request failed"); BT_ERR("Firmware request failed");
usb_free_urb(data->urb); usb_free_urb(data->urb);
kfree(data->buffer); kfree(data->buffer);
kfree(data);
return -EIO; return -EIO;
} }
...@@ -236,7 +232,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id ...@@ -236,7 +232,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
release_firmware(firmware); release_firmware(firmware);
usb_free_urb(data->urb); usb_free_urb(data->urb);
kfree(data->buffer); kfree(data->buffer);
kfree(data);
return -ENOMEM; return -ENOMEM;
} }
...@@ -271,7 +266,6 @@ static void bcm203x_disconnect(struct usb_interface *intf) ...@@ -271,7 +266,6 @@ static void bcm203x_disconnect(struct usb_interface *intf)
usb_free_urb(data->urb); usb_free_urb(data->urb);
kfree(data->fw_data); kfree(data->fw_data);
kfree(data->buffer); kfree(data->buffer);
kfree(data);
} }
static struct usb_driver bcm203x_driver = { static struct usb_driver bcm203x_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