From: Martyn Welch <martyn.welch@collabora.co.uk>
To: Konstantin Shkolnyy <Konstantin.Shkolnyy@silabs.com>,
Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>,
"johan@kernel.org" <johan@kernel.org>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/3 RESEND] USB: serial: cp210x: New 16-bit register access functions.
Date: Thu, 14 Jan 2016 17:20:59 +0000 [thread overview]
Message-ID: <5697D8FB.7000709@collabora.co.uk> (raw)
In-Reply-To: <BLUPR0701MB157291CADDC78B642350C42291CC0@BLUPR0701MB1572.namprd07.prod.outlook.com>
On 14/01/16 17:10, Konstantin Shkolnyy wrote:
>> -----Original Message-----
>> From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-
>> owner@vger.kernel.org] On Behalf Of Martyn Welch
>> Sent: Thursday, January 14, 2016 10:31
>> To: Konstantin Shkolnyy; johan@kernel.org
>> Cc: linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org
>> Subject: Re: [PATCH v2 1/3 RESEND] USB: serial: cp210x: New 16-bit register
>> access functions.
>>
>> On 23/12/15 02:14, Konstantin Shkolnyy wrote:
>>> cp210x_get_config and cp210x_set_config are cumbersome to use. This
>> change
>>> introduces new register access functions for 16-bit values, instead of
>>> the above functions.
>>>
>>> Signed-off-by: Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>
>>> ---
>>> drivers/usb/serial/cp210x.c | 155
>> +++++++++++++++++++++++++++++++-------------
>>> 1 file changed, 111 insertions(+), 44 deletions(-)
>>>
>>> diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
>>> index fd67958..fd7c4f4 100644
>>> --- a/drivers/usb/serial/cp210x.c
>>> +++ b/drivers/usb/serial/cp210x.c
>>> @@ -422,14 +422,88 @@ static int cp210x_set_config(struct
>> usb_serial_port *port, u8 request,
>>> }
>>>
>>> /*
>>> - * cp210x_set_config_single
>>> - * Convenience function for calling cp210x_set_config on single data
>> values
>>> - * without requiring an integer pointer
>>> + * Reads a variable-sized block of CP210X_ registers, identified by req.
>>> + * Returns data into buf in native USB byte order.
>>> */
>>> -static inline int cp210x_set_config_single(struct usb_serial_port *port,
>>> - u8 request, unsigned int data)
>>> +static int cp210x_read_reg_block(struct usb_serial_port *port, u8 req,
>>> + void *buf, int bufsize)
>>> {
>>> - return cp210x_set_config(port, request, &data, 2);
>>> + struct usb_serial *serial = port->serial;
>>> + struct cp210x_port_private *port_priv =
>> usb_get_serial_port_data(port);
>>> + void *dmabuf;
>>> + int result;
>>> +
>>> + dmabuf = kmalloc(bufsize, GFP_KERNEL);
>>> + if (!dmabuf) {
>>> + /*
>>> + * FIXME Some callers don't bother to check for error,
>>> + * at least give them consistent junk until they are fixed
>>> + */
>>> + memset(buf, 0, bufsize);
>>> + return -ENOMEM;
>>> + }
>>> +
>>> + result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev,
>> 0),
>>> + req, REQTYPE_INTERFACE_TO_HOST, 0,
>>> + port_priv->bInterfaceNumber, dmabuf, bufsize,
>>> + USB_CTRL_SET_TIMEOUT);
>>> + if (result == bufsize) {
>>> + memcpy(buf, dmabuf, bufsize);
>>> + result = 0;
>>
>> I could be wrong, but isn't dmabuf a little-endian stream (hence the
>> byte order swapping in the existing set and get functions). Won't this
>> break on big endian systems due to the lack of byte swapping?
>
> This function is intended to not convert, as I tried to say in the header comment.
>
Ah, gotcha - conversion done in cp210x_read_u16_reg().
Martyn
prev parent reply other threads:[~2016-01-14 17:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-23 2:14 [PATCH v2 1/3 RESEND] USB: serial: cp210x: New 16-bit register access functions Konstantin Shkolnyy
2016-01-14 16:30 ` Martyn Welch
2016-01-14 17:10 ` Konstantin Shkolnyy
2016-01-14 17:20 ` Martyn Welch [this message]
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=5697D8FB.7000709@collabora.co.uk \
--to=martyn.welch@collabora.co.uk \
--cc=Konstantin.Shkolnyy@silabs.com \
--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