USB: usblp: refactor endpoint retrieval
Use the new endpoint helpers to lookup the required bulk-out endpoint and the depending on protocol likewise required bulk-in endpoint. Cc: Pete Zaitcev <zaitcev@redhat.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>hifive-unleashed-5.1
parent
80070a408c
commit
5370860a1f
|
@ -1239,8 +1239,9 @@ static int usblp_select_alts(struct usblp *usblp)
|
||||||
{
|
{
|
||||||
struct usb_interface *if_alt;
|
struct usb_interface *if_alt;
|
||||||
struct usb_host_interface *ifd;
|
struct usb_host_interface *ifd;
|
||||||
struct usb_endpoint_descriptor *epd, *epwrite, *epread;
|
struct usb_endpoint_descriptor *epwrite, *epread;
|
||||||
int p, i, e;
|
int p, i;
|
||||||
|
int res;
|
||||||
|
|
||||||
if_alt = usblp->intf;
|
if_alt = usblp->intf;
|
||||||
|
|
||||||
|
@ -1260,31 +1261,21 @@ static int usblp_select_alts(struct usblp *usblp)
|
||||||
ifd->desc.bInterfaceProtocol > USBLP_LAST_PROTOCOL)
|
ifd->desc.bInterfaceProtocol > USBLP_LAST_PROTOCOL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Look for bulk OUT and IN endpoints. */
|
/* Look for the expected bulk endpoints. */
|
||||||
epwrite = epread = NULL;
|
if (ifd->desc.bInterfaceProtocol > 1) {
|
||||||
for (e = 0; e < ifd->desc.bNumEndpoints; e++) {
|
res = usb_find_common_endpoints(ifd,
|
||||||
epd = &ifd->endpoint[e].desc;
|
&epread, &epwrite, NULL, NULL);
|
||||||
|
} else {
|
||||||
if (usb_endpoint_is_bulk_out(epd))
|
epread = NULL;
|
||||||
if (!epwrite)
|
res = usb_find_bulk_out_endpoint(ifd, &epwrite);
|
||||||
epwrite = epd;
|
|
||||||
|
|
||||||
if (usb_endpoint_is_bulk_in(epd))
|
|
||||||
if (!epread)
|
|
||||||
epread = epd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ignore buggy hardware without the right endpoints. */
|
/* Ignore buggy hardware without the right endpoints. */
|
||||||
if (!epwrite || (ifd->desc.bInterfaceProtocol > 1 && !epread))
|
if (res)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/* Turn off reads for buggy bidirectional printers. */
|
||||||
* Turn off reads for USB_CLASS_PRINTER/1/1 (unidirectional)
|
if (usblp->quirks & USBLP_QUIRK_BIDIR) {
|
||||||
* interfaces and buggy bidirectional printers.
|
|
||||||
*/
|
|
||||||
if (ifd->desc.bInterfaceProtocol == 1) {
|
|
||||||
epread = NULL;
|
|
||||||
} else if (usblp->quirks & USBLP_QUIRK_BIDIR) {
|
|
||||||
printk(KERN_INFO "usblp%d: Disabling reads from "
|
printk(KERN_INFO "usblp%d: Disabling reads from "
|
||||||
"problematic bidirectional printer\n",
|
"problematic bidirectional printer\n",
|
||||||
usblp->minor);
|
usblp->minor);
|
||||||
|
|
Loading…
Reference in New Issue