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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Thilo Schulz
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 <[hidden email]>
---
 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 [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Thomas Jarosch
Hi Thilo,

On Monday, 12. October 2015 19:05:07 Thilo Schulz wrote:
> 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.

thanks, I've applied your patches.

I double checked the changes involving USE_USB_VERSION_BIT because of
possible BC issues, so far I didn't spot any.

Cheers,
Thomas


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Thilo Schulz
Hi,

#On Friday 16 October 2015 13:37:44 Thomas Jarosch wrote:
> thanks, I've applied your patches.

Thank you. Especially the include directive is very useful, as I want to
program many FT232RLs in a similar manner, but with slight variations in
serial and name strings.

I have decided to forego the user area and store all information in the
manufacturer/serial strings. This way, I can start services associated with
the respective FTDI chip directly from udev/systemd. Kind of a plug'n'play
solution, and it does work really well.

--
Best regards,
Thilo Schulz

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Loading...