Re: [PATCH 2/6] USB: serial: ftdi_sio: detect BM chip with iSerialNumber bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 28, 2017 at 12:51:24PM +0000, Ian Abbott wrote:
> If a BM type chip has iSerialNumber set to 0 in its EEPROM, an incorrect
> value is read from the bcdDevice field of the USB descriptor, making it
> look like an AM type chip.  Attempt to correct this in
> ftdi_determine_type() by attempting to read the latency timer for an AM
> type chip.  If that succeeds, assume it is a BM type chip.
> 
> Currently, read_latency_timer() bails out without reading the latency
> timer for an AM type chip, so factor out the guts of
> read_latency_timer() into a new function _read_latency_timer() that
> attempts to read the latency timer regardless of chip type, and returns
> either the latency timer value or a negative error number.
> 
> Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
> ---
>  drivers/usb/serial/ftdi_sio.c | 38 ++++++++++++++++++++++++++++++--------
>  1 file changed, 30 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
> index 72314734dfd0..a1b90f4184a7 100644
> --- a/drivers/usb/serial/ftdi_sio.c
> +++ b/drivers/usb/serial/ftdi_sio.c

> @@ -1609,9 +1623,17 @@ static void ftdi_determine_type(struct usb_serial_port *port)
>  		priv->baud_base = 12000000 / 16;
>  	} else if (version < 0x400) {
>  		/* Assume it's an FT8U232AM (or FT8U245AM) */
> -		/* (It might be a BM because of the iSerialNumber bug,
> -		 * but it will still work as an AM device.) */
>  		priv->chip_type = FT8U232AM;
> +		/*
> +		 * It might be a BM type because of the iSerialNumber bug.
> +		 * If the latency timer is readable, assume it is BM type.
> +		 */
> +		if (_read_latency_timer(port) >= 0) {

Would it be possible to only try to read the latency timer when
iSerialNumber is 0?

> +			dev_dbg(&port->dev,
> +				"%s: has latency timer so not an AM type\n",
> +				__func__);
> +			priv->chip_type = FT232BM;
> +		}
>  	} else if (version < 0x600) {
>  		/* Assume it's an FT232BM (or FT245BM) */
>  		priv->chip_type = FT232BM;

Thanks,
Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux