ChangeSet 1.971.1.11, 2003/01/15 12:51:27-08:00, henning@meier-geinitz.de [PATCH] scanner.c: endpoint detection cleanup This patch makes endpoint detection more generic. Basically, only one bulk-in endpoint is required, everything else is optional. The patch is on top of the PV8630 removal patch. diff -Nru a/drivers/usb/scanner.c b/drivers/usb/scanner.c --- a/drivers/usb/scanner.c Thu Jan 16 10:51:53 2003 +++ b/drivers/usb/scanner.c Thu Jan 16 10:51:53 2003 @@ -335,9 +335,10 @@ * - Print information about user-supplied ids only once at startup instead * of everytime any USB device is plugged in. * - Removed PV8630 ioctls. Use the standard ioctls instead. + * - Made endpoint detection more generic. Basically, only one bulk-in + * endpoint is required, everything else is optional. * * TODO - * - Remove the 2/3 endpoint limitation * - Performance * - Select/poll methods * - More testing @@ -868,38 +869,45 @@ endpoint = interface[0].endpoint; /* - * Start checking for one or two bulk endpoints and an optional - * interrupt endpoint. If we have an interrupt endpoint go ahead and + * Start checking for bulk and interrupt endpoints. We are only using the first + * one of each type of endpoint. If we have an interrupt endpoint go ahead and * setup the handler. FIXME: This is a future enhancement... */ dbg("probe_scanner: Number of Endpoints:%d", (int) interface->bNumEndpoints); - if ((interface->bNumEndpoints < 1) || (interface->bNumEndpoints > 3)) { - info("probe_scanner: Only 1, 2, or 3 endpoints supported."); - return NULL; - } - ep_cnt = have_bulk_in = have_bulk_out = have_intr = 0; while (ep_cnt < interface->bNumEndpoints) { - if (!have_bulk_in && IS_EP_BULK_IN(endpoint[ep_cnt])) { + if (IS_EP_BULK_IN(endpoint[ep_cnt])) { ep_cnt++; + if (have_bulk_in) { + info ("probe_scanner: ignoring additional bulk_in_ep:%d", ep_cnt); + continue; + } have_bulk_in = ep_cnt; dbg("probe_scanner: bulk_in_ep:%d", have_bulk_in); continue; } - if (!have_bulk_out && IS_EP_BULK_OUT(endpoint[ep_cnt])) { + if (IS_EP_BULK_OUT(endpoint[ep_cnt])) { ep_cnt++; + if (have_bulk_out) { + info ("probe_scanner: ignoring additional bulk_out_ep:%d", ep_cnt); + continue; + } have_bulk_out = ep_cnt; dbg("probe_scanner: bulk_out_ep:%d", have_bulk_out); continue; } - if (!have_intr && IS_EP_INTR(endpoint[ep_cnt])) { + if (IS_EP_INTR(endpoint[ep_cnt])) { ep_cnt++; + if (have_intr) { + info ("probe_scanner: ignoring additional intr_ep:%d", ep_cnt); + continue; + } have_intr = ep_cnt; dbg("probe_scanner: intr_ep:%d", have_intr); continue; @@ -913,28 +921,8 @@ * Perform a quick check to make sure that everything worked as it * should have. */ - - switch(interface->bNumEndpoints) { - case 1: - if (!have_bulk_in) { - info("probe_scanner: One bulk-in endpoint required."); - return NULL; - } - break; - case 2: - if (!have_bulk_in || !have_bulk_out) { - info("probe_scanner: Two bulk endpoints required."); - return NULL; - } - break; - case 3: - if (!have_bulk_in || !have_bulk_out || !have_intr) { - info("probe_scanner: Two bulk endpoints and one interrupt endpoint required."); - return NULL; - } - break; - default: - info("probe_scanner: Endpoint determination failed -- consult Documentation/usb/scanner.txt"); + if (!have_bulk_in) { + err("probe_scanner: One bulk-in endpoint required."); return NULL; } @@ -1015,7 +1003,6 @@ break; case 0x055f: /* Mustek */ case 0x0400: /* Another Mustek */ - case 0x0ff5: /* And yet another Mustek */ scn->rd_nak_timeout = HZ * 1; default: scn->rd_nak_timeout = RD_NAK_TIMEOUT;