Commit 50129f74 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: ftdi-elan: refactor endpoint retrieval

Use the new endpoint helpers to lookup the required bulk-in and bulk-out
endpoints.
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a8bbb0f8
...@@ -2700,10 +2700,8 @@ static int ftdi_elan_probe(struct usb_interface *interface, ...@@ -2700,10 +2700,8 @@ static int ftdi_elan_probe(struct usb_interface *interface,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
struct usb_host_interface *iface_desc; struct usb_host_interface *iface_desc;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *bulk_in, *bulk_out;
size_t buffer_size; int retval;
int i;
int retval = -ENOMEM;
struct usb_ftdi *ftdi; struct usb_ftdi *ftdi;
ftdi = kzalloc(sizeof(struct usb_ftdi), GFP_KERNEL); ftdi = kzalloc(sizeof(struct usb_ftdi), GFP_KERNEL);
...@@ -2720,31 +2718,25 @@ static int ftdi_elan_probe(struct usb_interface *interface, ...@@ -2720,31 +2718,25 @@ static int ftdi_elan_probe(struct usb_interface *interface,
ftdi->interface = interface; ftdi->interface = interface;
mutex_init(&ftdi->u132_lock); mutex_init(&ftdi->u132_lock);
ftdi->expected = 4; ftdi->expected = 4;
iface_desc = interface->cur_altsetting; iface_desc = interface->cur_altsetting;
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { retval = usb_find_common_endpoints(iface_desc,
endpoint = &iface_desc->endpoint[i].desc; &bulk_in, &bulk_out, NULL, NULL);
if (!ftdi->bulk_in_endpointAddr && if (retval) {
usb_endpoint_is_bulk_in(endpoint)) { dev_err(&ftdi->udev->dev, "Could not find both bulk-in and bulk-out endpoints\n");
buffer_size = usb_endpoint_maxp(endpoint);
ftdi->bulk_in_size = buffer_size;
ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress;
ftdi->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
if (!ftdi->bulk_in_buffer) {
retval = -ENOMEM;
goto error; goto error;
} }
}
if (!ftdi->bulk_out_endpointAddr && ftdi->bulk_in_size = usb_endpoint_maxp(bulk_in);
usb_endpoint_is_bulk_out(endpoint)) { ftdi->bulk_in_endpointAddr = bulk_in->bEndpointAddress;
ftdi->bulk_out_endpointAddr = ftdi->bulk_in_buffer = kmalloc(ftdi->bulk_in_size, GFP_KERNEL);
endpoint->bEndpointAddress; if (!ftdi->bulk_in_buffer) {
} retval = -ENOMEM;
}
if (!(ftdi->bulk_in_endpointAddr && ftdi->bulk_out_endpointAddr)) {
dev_err(&ftdi->udev->dev, "Could not find both bulk-in and bulk-out endpoints\n");
retval = -ENODEV;
goto error; goto error;
} }
ftdi->bulk_out_endpointAddr = bulk_out->bEndpointAddress;
dev_info(&ftdi->udev->dev, "interface %d has I=%02X O=%02X\n", dev_info(&ftdi->udev->dev, "interface %d has I=%02X O=%02X\n",
iface_desc->desc.bInterfaceNumber, ftdi->bulk_in_endpointAddr, iface_desc->desc.bInterfaceNumber, ftdi->bulk_in_endpointAddr,
ftdi->bulk_out_endpointAddr); ftdi->bulk_out_endpointAddr);
......
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