From: Johan Hovold <johan@kernel.org>
To: Zheng Yongjun <zhengyongjun3@huawei.com>
Cc: johan@kernel.org, gregkh@linuxfoundation.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next] usb: serial: simplify the ark3116_write_reg()
Date: Wed, 9 Dec 2020 11:55:20 +0100 [thread overview]
Message-ID: <X9CtGBNfVIZV2eT6@localhost> (raw)
In-Reply-To: <20201209092917.20681-1-zhengyongjun3@huawei.com>
On Wed, Dec 09, 2020 at 05:29:17PM +0800, Zheng Yongjun wrote:
> Simplify the return expression.
>
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> ---
> drivers/usb/serial/ark3116.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
> index 71a9206ea1e2..0f9fa0e7c50e 100644
> --- a/drivers/usb/serial/ark3116.c
> +++ b/drivers/usb/serial/ark3116.c
> @@ -77,16 +77,11 @@ struct ark3116_private {
> static int ark3116_write_reg(struct usb_serial *serial,
> unsigned reg, __u8 val)
> {
> - int result;
> /* 0xfe 0x40 are magic values taken from original driver */
> - result = usb_control_msg(serial->dev,
> - usb_sndctrlpipe(serial->dev, 0),
> - 0xfe, 0x40, val, reg,
> - NULL, 0, ARK_TIMEOUT);
> - if (result)
> - return result;
Since none of the callers bother to check for errors, how about you add
a dev_err() here similar to the one in ark3116_read_reg() instead?
> -
> - return 0;
Keeping the explicit zero-return on success has the benefit of allowing
the casual developer to know what to expect when using this helper
without having to read the documentation (or implementation) of
usb_control_msg().
> + return usb_control_msg(serial->dev,
> + usb_sndctrlpipe(serial->dev, 0),
> + 0xfe, 0x40, val, reg,
> + NULL, 0, ARK_TIMEOUT);
> }
>
> static int ark3116_read_reg(struct usb_serial *serial,
Johan
prev parent reply other threads:[~2020-12-09 10:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-09 9:29 [PATCH -next] usb: serial: simplify the ark3116_write_reg() Zheng Yongjun
2020-12-09 10:55 ` Johan Hovold [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=X9CtGBNfVIZV2eT6@localhost \
--to=johan@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=zhengyongjun3@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).