Index: sanei/sanei_usb.c |
diff --git a/sanei/sanei_usb.c b/sanei/sanei_usb.c |
index aad77918bc70bf1dc89c63884853d0005548f4af..609e3bb7ac216cbe0a799fe41c39ec3c1e497ca5 100644 |
--- a/sanei/sanei_usb.c |
+++ b/sanei/sanei_usb.c |
@@ -1104,6 +1104,39 @@ sanei_usb_find_devices (SANE_Int vendor, SANE_Int product, |
return SANE_STATUS_GOOD; |
} |
+void |
+sanei_usb_set_endpoint (SANE_Int dn, SANE_Int ep_type, SANE_Int ep) |
+{ |
+ DBG (5, "sanei_usb_set_endpoint: Setting endpoint of type %02x to %02x\n", ep_type, ep); |
+ switch (ep_type) |
+ { |
+ case USB_DIR_IN|USB_ENDPOINT_TYPE_BULK: |
+ devices[dn].bulk_in_ep = ep; |
+ break; |
+ case USB_DIR_OUT|USB_ENDPOINT_TYPE_BULK: |
+ devices[dn].bulk_out_ep = ep; |
+ break; |
+ case USB_DIR_IN|USB_ENDPOINT_TYPE_ISOCHRONOUS: |
+ devices[dn].iso_in_ep = ep; |
+ break; |
+ case USB_DIR_OUT|USB_ENDPOINT_TYPE_ISOCHRONOUS: |
+ devices[dn].iso_out_ep = ep; |
+ break; |
+ case USB_DIR_IN|USB_ENDPOINT_TYPE_INTERRUPT: |
+ devices[dn].int_in_ep = ep; |
+ break; |
+ case USB_DIR_OUT|USB_ENDPOINT_TYPE_INTERRUPT: |
+ devices[dn].int_out_ep = ep; |
+ break; |
+ case USB_DIR_IN|USB_ENDPOINT_TYPE_CONTROL: |
+ devices[dn].control_in_ep = ep; |
+ break; |
+ case USB_DIR_OUT|USB_ENDPOINT_TYPE_CONTROL: |
+ devices[dn].control_out_ep = ep; |
+ break; |
+ } |
+} |
+ |
SANE_Status |
sanei_usb_open (SANE_String_Const devname, SANE_Int * dn) |
{ |
@@ -1977,6 +2010,12 @@ sanei_usb_clear_halt (SANE_Int dn) |
#ifdef HAVE_LIBUSB |
int ret; |
+ if (dn >= device_number || dn < 0) |
+ { |
+ DBG (1, "sanei_usb_clear_halt: dn >= device number || dn < 0\n"); |
+ return SANE_STATUS_INVAL; |
+ } |
+ |
ret = usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_in_ep); |
if (ret){ |
DBG (1, "sanei_usb_clear_halt: BULK_IN ret=%d\n", ret); |
@@ -1996,6 +2035,12 @@ sanei_usb_clear_halt (SANE_Int dn) |
#elif defined(HAVE_LIBUSB_1_0) |
int ret; |
+ if (dn >= device_number || dn < 0) |
+ { |
+ DBG (1, "sanei_usb_clear_halt: dn >= device number || dn < 0\n"); |
+ return SANE_STATUS_INVAL; |
+ } |
+ |
ret = libusb_clear_halt (devices[dn].lu_handle, devices[dn].bulk_in_ep); |
if (ret){ |
DBG (1, "sanei_usb_clear_halt: BULK_IN ret=%d\n", ret); |
@@ -2290,7 +2335,8 @@ sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size) |
if (devices[dn].bulk_out_ep){ |
rc = UsbBulkWrite (dh, devices[dn].bulk_out_ep, devices[dn].interface_nr, |
ulToWrite, (char*) buffer, usbcalls_timeout); |
- DBG (1, "sanei_usb_write_bulk: rc = %d\n",rc);} |
+ DBG (1, "sanei_usb_write_bulk: rc = %d\n",rc); |
+ } |
else |
{ |
DBG (1, "sanei_usb_write_bulk: can't read without a bulk-out endpoint\n"); |