diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-07-27 03:08:39 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2012-08-06 14:03:02 -0400 |
commit | 98921dbd00c4e2e4bdd56423cb5edf98d57b45f7 (patch) | |
tree | e16d6911125fa785fc3406bdd0e12cf15a9e663f /drivers/bluetooth/btusb.c | |
parent | fdefa118ebbcadad4adbaaab067be06a96a48e15 (diff) |
Bluetooth: Use devm_kzalloc in btusb.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>
Diffstat (limited to 'drivers/bluetooth/btusb.c')
-rw-r--r-- | 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 e27221411036..f637c2550016 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c | |||
@@ -952,7 +952,7 @@ static int btusb_probe(struct usb_interface *intf, | |||
952 | return -ENODEV; | 952 | return -ENODEV; |
953 | } | 953 | } |
954 | 954 | ||
955 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 955 | data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL); |
956 | if (!data) | 956 | if (!data) |
957 | return -ENOMEM; | 957 | return -ENOMEM; |
958 | 958 | ||
@@ -975,10 +975,8 @@ static int btusb_probe(struct usb_interface *intf, | |||
975 | } | 975 | } |
976 | } | 976 | } |
977 | 977 | ||
978 | if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) { | 978 | if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) |
979 | kfree(data); | ||
980 | return -ENODEV; | 979 | return -ENODEV; |
981 | } | ||
982 | 980 | ||
983 | data->cmdreq_type = USB_TYPE_CLASS; | 981 | data->cmdreq_type = USB_TYPE_CLASS; |
984 | 982 | ||
@@ -998,10 +996,8 @@ static int btusb_probe(struct usb_interface *intf, | |||
998 | init_usb_anchor(&data->deferred); | 996 | init_usb_anchor(&data->deferred); |
999 | 997 | ||
1000 | hdev = hci_alloc_dev(); | 998 | hdev = hci_alloc_dev(); |
1001 | if (!hdev) { | 999 | if (!hdev) |
1002 | kfree(data); | ||
1003 | return -ENOMEM; | 1000 | return -ENOMEM; |
1004 | } | ||
1005 | 1001 | ||
1006 | hdev->bus = HCI_USB; | 1002 | hdev->bus = HCI_USB; |
1007 | hci_set_drvdata(hdev, data); | 1003 | hci_set_drvdata(hdev, data); |
@@ -1069,7 +1065,6 @@ static int btusb_probe(struct usb_interface *intf, | |||
1069 | data->isoc, data); | 1065 | data->isoc, data); |
1070 | if (err < 0) { | 1066 | if (err < 0) { |
1071 | hci_free_dev(hdev); | 1067 | hci_free_dev(hdev); |
1072 | kfree(data); | ||
1073 | return err; | 1068 | return err; |
1074 | } | 1069 | } |
1075 | } | 1070 | } |
@@ -1077,7 +1072,6 @@ static int btusb_probe(struct usb_interface *intf, | |||
1077 | err = hci_register_dev(hdev); | 1072 | err = hci_register_dev(hdev); |
1078 | if (err < 0) { | 1073 | if (err < 0) { |
1079 | hci_free_dev(hdev); | 1074 | hci_free_dev(hdev); |
1080 | kfree(data); | ||
1081 | return err; | 1075 | return err; |
1082 | } | 1076 | } |
1083 | 1077 | ||
@@ -1110,7 +1104,6 @@ static void btusb_disconnect(struct usb_interface *intf) | |||
1110 | usb_driver_release_interface(&btusb_driver, data->isoc); | 1104 | usb_driver_release_interface(&btusb_driver, data->isoc); |
1111 | 1105 | ||
1112 | hci_free_dev(hdev); | 1106 | hci_free_dev(hdev); |
1113 | kfree(data); | ||
1114 | } | 1107 | } |
1115 | 1108 | ||
1116 | #ifdef CONFIG_PM | 1109 | #ifdef CONFIG_PM |