Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: btusb: refactor endpoint lookup

Use the common USB helper for looking up bulk and interrupt endpoints
instead of open coding.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Johan Hovold and committed by
Luiz Augusto von Dentz
5c31aaa0 68d39ea5

+8 -43
+8 -43
drivers/bluetooth/btusb.c
··· 3689 3689 { 3690 3690 struct btusb_data *data = hci_get_drvdata(hdev); 3691 3691 struct usb_interface *intf = data->diag; 3692 - int i; 3692 + int ret; 3693 3693 3694 3694 if (!data->diag) 3695 3695 return -ENODEV; 3696 3696 3697 - data->diag_tx_ep = NULL; 3698 - data->diag_rx_ep = NULL; 3699 - 3700 - for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { 3701 - struct usb_endpoint_descriptor *ep_desc; 3702 - 3703 - ep_desc = &intf->cur_altsetting->endpoint[i].desc; 3704 - 3705 - if (!data->diag_tx_ep && usb_endpoint_is_bulk_out(ep_desc)) { 3706 - data->diag_tx_ep = ep_desc; 3707 - continue; 3708 - } 3709 - 3710 - if (!data->diag_rx_ep && usb_endpoint_is_bulk_in(ep_desc)) { 3711 - data->diag_rx_ep = ep_desc; 3712 - continue; 3713 - } 3714 - } 3715 - 3716 - if (!data->diag_tx_ep || !data->diag_rx_ep) { 3697 + ret = usb_find_common_endpoints(intf->cur_altsetting, &data->diag_rx_ep, 3698 + &data->diag_tx_ep, NULL, NULL); 3699 + if (ret) { 3717 3700 bt_dev_err(hdev, "invalid diagnostic descriptors"); 3718 3701 return -ENODEV; 3719 3702 } ··· 4022 4039 static int btusb_probe(struct usb_interface *intf, 4023 4040 const struct usb_device_id *id) 4024 4041 { 4025 - struct usb_endpoint_descriptor *ep_desc; 4026 4042 struct gpio_desc *reset_gpio; 4027 4043 struct btusb_data *data; 4028 4044 struct hci_dev *hdev; 4029 4045 unsigned ifnum_base; 4030 - int i, err, priv_size; 4046 + int err, priv_size; 4031 4047 4032 4048 BT_DBG("intf %p id %p", intf, id); 4033 4049 ··· 4063 4081 if (!data) 4064 4082 return -ENOMEM; 4065 4083 4066 - for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { 4067 - ep_desc = &intf->cur_altsetting->endpoint[i].desc; 4068 - 4069 - if (!data->intr_ep && usb_endpoint_is_int_in(ep_desc)) { 4070 - data->intr_ep = ep_desc; 4071 - continue; 4072 - } 4073 - 4074 - if (!data->bulk_tx_ep && usb_endpoint_is_bulk_out(ep_desc)) { 4075 - data->bulk_tx_ep = ep_desc; 4076 - continue; 4077 - } 4078 - 4079 - if (!data->bulk_rx_ep && usb_endpoint_is_bulk_in(ep_desc)) { 4080 - data->bulk_rx_ep = ep_desc; 4081 - continue; 4082 - } 4083 - } 4084 - 4085 - if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) { 4084 + err = usb_find_common_endpoints(intf->cur_altsetting, &data->bulk_rx_ep, 4085 + &data->bulk_tx_ep, &data->intr_ep, NULL); 4086 + if (err) { 4086 4087 kfree(data); 4087 4088 return -ENODEV; 4088 4089 }