public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>
Cc: johan@kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: serial: cp210x: Workaround for cp2108 failure due to GET_LINE_CTL bug
Date: Thu, 08 Oct 2015 09:31:37 +0200	[thread overview]
Message-ID: <87fv1lstnq.fsf@nemi.mork.no> (raw)
In-Reply-To: <1444261132-5001-1-git-send-email-konstantin.shkolnyy@gmail.com> (Konstantin Shkolnyy's message of "Wed, 7 Oct 2015 18:38:52 -0500")

Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com> 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

  reply	other threads:[~2015-10-08  7:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-07 23:38 [PATCH] USB: serial: cp210x: Workaround for cp2108 failure due to GET_LINE_CTL bug Konstantin Shkolnyy
2015-10-08  7:31 ` Bjørn Mork [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-10-08 20:53 Konstantin Shkolnyy
2015-10-15 22:06 Konstantin Shkolnyy
2015-10-19  9:14 ` Oliver Neukum
2015-10-19 13:20   ` Konstantin Shkolnyy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fv1lstnq.fsf@nemi.mork.no \
    --to=bjorn@mork.no \
    --cc=johan@kernel.org \
    --cc=konstantin.shkolnyy@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox