Re: [PATCH] USB: serial: cp210x: Workaround for cp2108 failure due to GET_LINE_CTL bug

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

 



Konstantin Shkolnyy <konstantin.shkolnyy@xxxxxxxxx> writes:

> @@ -343,6 +344,28 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
>  		return result;
>  	}
>  
> +	/* Workaround for swapped bytes in 16-bit value from CP210X_GET_LINE_CTL */
> +	if (spriv->swap_get_line_ctl && request == CP210X_GET_LINE_CTL && size == 2) {
> +		union {
> +			struct {
> +				u8 byte0;
> +				u8 byte1;
> +				u8 byte2;
> +				u8 byte3;
> +			};
> +			u32 as_u32;
> +		} tmp_data;
> +		u8 old_byte0;
> +		u8 old_byte1;
> +
> +		tmp_data.as_u32  = data[0]; /* from caller's buffer */
> +		old_byte0        = tmp_data.byte0;
> +		old_byte1        = tmp_data.byte1;
> +		tmp_data.byte0   = old_byte1;
> +		tmp_data.byte1   = old_byte0;
> +		data[0]          = tmp_data.as_u32; /* to caller's buffer */
> +	}

That looks unnecessarily complicated...  How about:

	if (spriv->swap_get_line_ctl && request == CP210X_GET_LINE_CTL && size == 2)
                swab16s((u16 *)data);


Completely untested...



Bjørn
--
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