From: Thilo Schulz Date: Mon, 12 Oct 2015 17:07:23 +0000 (+0200) Subject: Fix useless use_usb_version config file option is useless due to incorrect checking... X-Git-Tag: v1.3rc1~15 X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=commitdiff_plain;h=3986243d4e7f366001276d7246e7b9822f7e39c4 Fix useless use_usb_version config file option is useless due to incorrect checking of boolean flag Hi, currently the use_usb_version configuration option for ftdi_eeprom is not honoured. Config file adds boolean option as 0x00 or 0x01, but the check in libftdi is for the actual bitnumber for USE_USB_VERSION_BIT which is not 0x01. Signed-off-by: Thilo Schulz --- diff --git a/src/ftdi.c b/src/ftdi.c index 6ef656b..1b29468 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -2779,7 +2779,7 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi) case TYPE_BM: output[0x0C] = eeprom->usb_version & 0xff; output[0x0D] = (eeprom->usb_version>>8) & 0xff; - if (eeprom->use_usb_version == USE_USB_VERSION_BIT) + if (eeprom->use_usb_version) output[0x0A] |= USE_USB_VERSION_BIT; else output[0x0A] &= ~USE_USB_VERSION_BIT; @@ -2821,7 +2821,7 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi) output[0x0A] |= 0x4; else output[0x0A] &= ~0x4; - if (eeprom->use_usb_version == USE_USB_VERSION_BIT) + if (eeprom->use_usb_version) output[0x0A] |= USE_USB_VERSION_BIT; else output[0x0A] &= ~USE_USB_VERSION_BIT; @@ -3205,8 +3205,8 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) eeprom->in_is_isochronous = buf[0x0A]&0x01; eeprom->out_is_isochronous = buf[0x0A]&0x02; eeprom->suspend_pull_downs = buf[0x0A]&0x04; - eeprom->use_serial = (buf[0x0A] & USE_SERIAL_NUM)?1:0; - eeprom->use_usb_version = buf[0x0A] & USE_USB_VERSION_BIT; + eeprom->use_serial = !!(buf[0x0A] & USE_SERIAL_NUM); + eeprom->use_usb_version = !!(buf[0x0A] & USE_USB_VERSION_BIT); // Addr 0C: USB version low byte when 0x0A // Addr 0D: USB version high byte when 0x0A @@ -3470,7 +3470,7 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) (eeprom->channel_b_driver)?" VCP":"", (eeprom->high_current_b)?" High Current IO":""); if (((ftdi->type == TYPE_BM) || (ftdi->type == TYPE_2232C)) && - eeprom->use_usb_version == USE_USB_VERSION_BIT) + eeprom->use_usb_version) fprintf(stdout,"Use explicit USB Version %04x\n",eeprom->usb_version); if ((ftdi->type == TYPE_2232H) || (ftdi->type == TYPE_4232H))