libftdi Archives

Subject: [PATCH] Fix useless use_usb_version config file option is useless due to incorrect checking of boolean flag

From: Thilo Schulz <thilo@xxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 12 Oct 2015 19:05:07 +0200
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 <thilo@xxxxxxx>
---
 src/ftdi.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

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))
-- 
2.1.4


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread