usb: Claim and set interface alt-setting only for used lines

If a line is not auto-created, there is no point on claiming the
matching interface and even less point setting the alt setting that
will try to use USB isoc bandwith.

With this you can no use only line 1 and not line 0 of a ice1usb
for instance. While previously it would still "enable" line 0 and
then line 1 would fail because on BW issues most of the case.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Iea5d72272f11875e7a32c78b60c188590deda831
This commit is contained in:
Sylvain Munaut 2022-10-12 22:18:02 +02:00
parent 6005fb3ea8
commit 56a79f60e1
1 changed files with 16 additions and 15 deletions

View File

@ -904,21 +904,6 @@ _e1_usb_open_device(struct e1_daemon *e1d, struct libusb_device *dev)
}
}
/* Get interface and set it up */
ret = libusb_claim_interface(devh, id->bInterfaceNumber);
if (ret) {
LOGP(DE1D, LOGL_ERROR, "Failed to claim interface %d:%s\n", id->bInterfaceNumber,
libusb_strerror(ret));
goto next_interface;
}
ret = libusb_set_interface_alt_setting(devh, id->bInterfaceNumber, 1);
if (ret) {
LOGP(DE1D, LOGL_ERROR, "Failed to set interface %d altsetting:%s\n", id->bInterfaceNumber,
libusb_strerror(ret));
goto next_interface;
}
/* Setup driver data and find endpoints */
line_data = talloc_zero(e1d->ctx, struct e1_usb_line_data);
@ -965,6 +950,22 @@ _e1_usb_open_device(struct e1_daemon *e1d, struct libusb_device *dev)
line->drv_data = line_data;
}
/* Get interface and set it up */
ret = libusb_claim_interface(devh, id->bInterfaceNumber);
if (ret) {
LOGP(DE1D, LOGL_ERROR, "Failed to claim interface %d:%s\n", id->bInterfaceNumber,
libusb_strerror(ret));
goto next_interface;
}
ret = libusb_set_interface_alt_setting(devh, id->bInterfaceNumber, 1);
if (ret) {
LOGP(DE1D, LOGL_ERROR, "Failed to set interface %d altsetting:%s\n", id->bInterfaceNumber,
libusb_strerror(ret));
goto next_interface;
}
/* Create data flows and start the line */
line_data->flow_in = e1uf_create(line, e1_usb_xfer_in, line_data->ep_in, 4, line_data->pkt_size, 4);
line_data->flow_out = e1uf_create(line, e1_usb_xfer_out, line_data->ep_out, 4, line_data->pkt_size, 4);
line_data->flow_fb = e1uf_create(line, e1_usb_xfer_fb, line_data->ep_fb, 2, 3, 1);