libftdi Archives

Subject: Re: Please review: Streaming read for libftdi-1

From: Jie Zhang <jzhang918@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Thu, 29 Apr 2010 09:18:44 +0800
On Wed, Apr 28, 2010 at 1:18 AM, Uwe Bonnes
<bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hello,
>
> appended patch adds a streaming read for libftdi-1. It's mostly taken from
> Micah Dowty <micahjd@xxxxxxxxx> fastftdi.c|h.
>
It seems fastftdi uses X11 license, which is GPL compatible. X11
license is GPL compatible, i.e.

http://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses

and

http://www.gnu.org/licenses/gpl-faq.html#WhatDoesCompatMean

As I understanding of the "GPL compatible", it should be OK to have
some files licensed under X11 license in a GPL software. But I don't
know if it's OK to put some portion of X11 license code in a GPL
licensed source file. Since if you do that, you have to put X11
license in that source file as my understanding of the clauses of the
X11 license.


If license is not a problem. I think it would be better to change the
coding style as same as the existing source code of libftdi.

> @@ -477,6 +477,11 @@ int ftdi_usb_open_dev(struct ftdi_context *ftdi, 
> libusb_device *dev)
>     // set configuration (needed especially for windows)
>     // tolerate EBUSY: one device with one configuration, but two interfaces
>     //    and libftdi sessions to both interfaces (e.g. FT2232)
> +        if (libusb_set_configuration(ftdi->usb_dev, cfg0) < 0)
> +        {
> +            ftdi_usb_close_internal (ftdi);
> +            ftdi_error_return(-3, "unable to set usb configuration. Make 
> sure ftdi_sio is unloaded!");
> +        }
>     if (desc.bNumConfigurations > 0 && cfg != cfg0)
>     {
>         if (libusb_set_configuration(ftdi->usb_dev, cfg0) < 0)

Why do you need this change?


> @@ -1736,6 +1741,216 @@ int ftdi_read_data_get_chunksize(struct ftdi_context 
> *ftdi, unsigned int *chunks
>     return 0;
>  }
>
> +typedef struct {
> +   FTDIStreamCallback *callback;

ftdi_stream_callback

> +   void *userdata;
> +   int packetsize;
> +   int result;
> +   FTDIProgressInfo progress;

ftdi_progress_info

> +} FTDIStreamState;
> +
ftdi_stream_state

> +static void
> +ftdi_readstream_cb(struct libusb_transfer *transfer)
> +{
> +   FTDIStreamState *state = transfer->user_data;

Use 4 whitespace indent.

> +   int packet_size = state->packetsize;
> +
> +   if (state->result == 0) {

Put `{' on a new line.



Jie

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

Current Thread