| 2099 | */ |
| 2100 | |
| 2101 | static int /* O - 0 on success, < 0 on error */ |
| 2102 | soft_reset_printer( |
| 2103 | usb_printer_t *printer) /* I - Printer */ |
| 2104 | { |
| 2105 | struct libusb_config_descriptor *confptr = NULL; |
| 2106 | /* Pointer to current configuration */ |
| 2107 | int interface, /* Interface to reset */ |
| 2108 | errcode; /* Error code */ |
| 2109 | |
| 2110 | |
| 2111 | if (libusb_get_config_descriptor(printer->device, printer->conf, |
| 2112 | &confptr) < 0) |
| 2113 | interface = printer->iface; |
| 2114 | else |
| 2115 | interface = confptr->interface[printer->iface]. |
| 2116 | altsetting[printer->altset].bInterfaceNumber; |
| 2117 | |
| 2118 | libusb_free_config_descriptor(confptr); |
| 2119 | |
| 2120 | if ((errcode = libusb_control_transfer(printer->handle, |
| 2121 | LIBUSB_REQUEST_TYPE_CLASS | |
| 2122 | LIBUSB_ENDPOINT_OUT | |
| 2123 | LIBUSB_RECIPIENT_OTHER, |
| 2124 | 2, 0, interface, NULL, 0, 5000)) < 0) |
| 2125 | errcode = libusb_control_transfer(printer->handle, |
| 2126 | LIBUSB_REQUEST_TYPE_CLASS | |
| 2127 | LIBUSB_ENDPOINT_OUT | |
| 2128 | LIBUSB_RECIPIENT_INTERFACE, |
| 2129 | 2, 0, interface, NULL, 0, 5000); |
| 2130 | |
| 2131 | return (errcode); |
| 2132 | } |