libftdi Archives

Subject: Re: Decode/Encode use_usb_version on BM and 2232C

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 4 Oct 2010 12:07:38 +0200
On Monday, 4. October 2010 11:42:36 Uwe Bonnes wrote:
> So you mean
> 
> > +        if (eeprom->use_usb_version != 0)
> > +            output[0x0A] |= USE_USB_VERSION_BIT;
> > +        else
> > +            output[0x0A] &= ~USE_USB_VERSION_BIT;
> > +
> 
> Where a value is a single bit, I decided to set the appropriate bit in
> the decoded structure. I think, this is some protection against nonsense
> values, set unintentionally. But I can change back to a test for
> non-zero or one if you think this is better.

Yes, exactly. I'd prefer that as you don't have to extra document
the value of the "use_xyz" field. If you need to protect against
bogus values, what about doing the check like this:

-------------------------
if (eeprom->use_usb_version == 1)
    output[0x0A] |= USE_USB_VERSION_BIT;
else
    output[0x0A] &= ~USE_USB_VERSION_BIT;
-------------------------


btw: I'll try to review/apply the other get()/set() patch in the evening.

Cheers,
Thomas

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

Current Thread