From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751888AbbJHHby (ORCPT ); Thu, 8 Oct 2015 03:31:54 -0400 Received: from canardo.mork.no ([148.122.252.1]:52862 "EHLO canardo.mork.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750760AbbJHHbw convert rfc822-to-8bit (ORCPT ); Thu, 8 Oct 2015 03:31:52 -0400 From: =?utf-8?Q?Bj=C3=B8rn_Mork?= To: Konstantin Shkolnyy 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 Organization: m References: <1444261132-5001-1-git-send-email-konstantin.shkolnyy@gmail.com> Date: Thu, 08 Oct 2015 09:31:37 +0200 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") Message-ID: <87fv1lstnq.fsf@nemi.mork.no> User-Agent: Gnus/5.130013 (Ma Gnus v0.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Konstantin Shkolnyy 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