From: Johan Hovold <johan@kernel.org>
To: Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>
Cc: johan@kernel.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/4 RESEND] USB: serial: cp210x: New register access functions.
Date: Mon, 18 Jan 2016 18:32:36 +0100 [thread overview]
Message-ID: <20160118173236.GF3169@localhost> (raw)
In-Reply-To: <1452973584-18284-1-git-send-email-konstantin.shkolnyy@gmail.com>
On Sat, Jan 16, 2016 at 01:46:24PM -0600, Konstantin Shkolnyy wrote:
> cp210x_get_config and cp210x_set_config are cumbersome to use. This change
> introduces new register access functions to replace them. New functions
> are not yet called - the switch is done gradually in following changes.
>
> Signed-off-by: Konstantin Shkolnyy <konstantin.shkolnyy@gmail.com>
> ---
> change in v3: Presented new function addition as a separate patch #1,
> to simplify code review.
Thanks for the v3.
You should not be adding (static) functions before they have a caller as
this generates compiler warnings.
Please define the new helper functions when converting their call
sites. You can split the 8, 16 and 32-bit helpers in separate patches and
possibly also separate read and write if that makes sense in order to
keep the diffs smaller.
> drivers/usb/serial/cp210x.c | 166 ++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 166 insertions(+)
>
> diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
> index fd67958..324eb7e 100644
> --- a/drivers/usb/serial/cp210x.c
> +++ b/drivers/usb/serial/cp210x.c
> @@ -323,6 +323,172 @@ struct cp210x_comm_status {
> #define PURGE_ALL 0x000f
>
> /*
> + * Reads a variable-sized block of CP210X_ registers, identified by req.
> + * Returns data into buf in native USB byte order.
> + */
> +static int cp210x_read_reg_block(struct usb_serial_port *port, u8 req,
> + void *buf, int bufsize)
> +{
> + 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);
Instead of adding these FIXMEs and possibly risk introducing regressions
(these functions used to leave the previous values unchanged on errors),
how about adding the missing error handling first?
> + return -ENOMEM;
> + }
Thanks,
Johan
next prev parent reply other threads:[~2016-01-18 17:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-16 19:46 [PATCH v3 1/4 RESEND] USB: serial: cp210x: New register access functions Konstantin Shkolnyy
2016-01-18 17:32 ` Johan Hovold [this message]
2016-01-18 19:59 ` Konstantin Shkolnyy
2016-01-18 20:08 ` Johan Hovold
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=20160118173236.GF3169@localhost \
--to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.