* Fix hp5590 backend on big-endian platforms

Little Endian (working)
  =======================
  [hp5590] hp5590_init_scanner
  [hp5590] hp5590_cmd: USB-in-USB: command : 0012
  [hp5590] hp5590_control_msg: USB-in-USB: core data: no
  [hp5590] hp5590_control_msg: USB-in-USB: sending control msg
  [sanei_usb] sanei_usb_control_msg: rtype = 0x40, req = 4, value = 143, index = 0, len = 8
  [sanei_usb] 0000: C0 04 00 12 00 00 32 00

  Big Endian (not working)
  ========================
  [hp5590] hp5590_init_scanner
  [hp5590] hp5590_cmd: USB-in-USB: command : 0012
  [hp5590] hp5590_control_msg: USB-in-USB: core data: no
  [hp5590] hp5590_control_msg: USB-in-USB: sending control msg
  [sanei_usb] sanei_usb_control_msg: rtype = 0x40, req = 4, value = 143, index = 0, len = 8
  [sanei_usb] 000 C0 04 00 12 00 00 00 32

  USB field wLength should always be treated little-endian, last command value during
  verification is received as little-endian as well.

  Thanks to Nhan Ngo Dinh for identifying the issue and providing the patch.

  Signed-off-by: Ilia Sotnikov <hostcc@gmail.com
merge-requests/1/head
Nhan Ngo Dinh 2012-07-15 10:47:21 +03:00 zatwierdzone przez Ilia Sotnikov
rodzic 0cfd138d92
commit 8932359312
2 zmienionych plików z 9 dodań i 7 usunięć

Wyświetl plik

@ -73,7 +73,7 @@
}
/* #define HAS_WORKING_COLOR_48 */
#define BUILD 6
#define BUILD 7
#define USB_TIMEOUT 30 * 1000
static SANE_Word

Wyświetl plik

@ -82,7 +82,7 @@ struct usb_in_usb_bulk_setup
uint8_t bRequest;
uint8_t bEndpoint;
uint16_t unknown;
uint16_t wLength;
uint16_t wLength; /* MSB first */
uint8_t pad;
} __attribute__ ((packed));
@ -90,9 +90,9 @@ struct usb_in_usb_bulk_setup
struct usb_in_usb_ctrl_setup {
uint8_t bRequestType;
uint8_t bRequest;
uint16_t wValue;
uint16_t wIndex;
uint16_t wLength;
uint16_t wValue; /* MSB first */
uint16_t wIndex; /* MSB first */
uint16_t wLength; /* LSB first */
} __attribute__ ((packed));
/* CORE status flag - ready or not */
@ -255,7 +255,7 @@ hp5590_control_msg (SANE_Int dn,
ctrl.bRequest = request;
ctrl.wValue = htons (value);
ctrl.wIndex = htons (index);
ctrl.wLength = size;
ctrl.wLength = htole16 (size);
DBG (DBG_usb, "%s: USB-in-USB: sending control msg\n", __FUNCTION__);
/* Send USB-in-USB control message */
@ -325,7 +325,7 @@ hp5590_control_msg (SANE_Int dn,
ctrl.bRequest = request;
ctrl.wValue = htons (value);
ctrl.wIndex = htons (index);
ctrl.wLength = size;
ctrl.wLength = htole16 (size);
DBG (DBG_usb, "%s: USB-in-USB: sending control msg\n", __FUNCTION__);
/* Send USB-in-USB control message */
@ -477,6 +477,8 @@ hp5590_verify_last_cmd (SANE_Int dn,
if (ret != SANE_STATUS_GOOD)
return ret;
verify_cmd = le16toh (verify_cmd); /* Response is LSB first */
/* Last command - minor byte */
last_cmd = verify_cmd & 0xff;
/* CORE status - major byte */