From: Greg KH <gregkh@linuxfoundation.org>
To: Petko Manolov <petkan@nucleusys.com>
Cc: linux-usb@vger.kernel.org, oneukum@suse.com,
Petko Manolov <petko.manolov@konsulko.com>
Subject: Re: [PATCH 1/2] net: pegasus: convert control messages to the new send/recv scheme.
Date: Sat, 26 Sep 2020 07:44:57 +0200 [thread overview]
Message-ID: <20200926054457.GC631346@kroah.com> (raw)
In-Reply-To: <20200925160200.4364-2-petkan@nucleusys.com>
On Fri, Sep 25, 2020 at 07:01:59PM +0300, Petko Manolov wrote:
> From: Petko Manolov <petko.manolov@konsulko.com>
>
> Move all control transfers to safer usb_control_msg_send/recv() API.
This says _what_ the patch does, but we can see that from the diff. You
should describe _why_ we are doing what we are doing, so that everyone
understands the need for the change.
Also, can you add something like:
This fixes a number of issues where short reads were not
properly handled by the driver.
Take a look at "The canonical patch format" in the kernel file,
Documentation/SubmittingPatches for a description of how to write good
changelogs that we can understand 5 years in the future when we have to
look back at the files.
> Signed-off-by: Petko Manolov <petko.manolov@konsulko.com>
> ---
> drivers/net/usb/pegasus.c | 56 +++++++--------------------------------
> 1 file changed, 9 insertions(+), 47 deletions(-)
>
> diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
> index e92cb51a2c77..0ecc1eb2e71b 100644
> --- a/drivers/net/usb/pegasus.c
> +++ b/drivers/net/usb/pegasus.c
> @@ -124,62 +124,24 @@ static void async_ctrl_callback(struct urb *urb)
>
> static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data)
> {
> - u8 *buf;
> - int ret;
> -
> - buf = kmalloc(size, GFP_NOIO);
> - if (!buf)
> - return -ENOMEM;
> -
> - ret = usb_control_msg(pegasus->usb, usb_rcvctrlpipe(pegasus->usb, 0),
> - PEGASUS_REQ_GET_REGS, PEGASUS_REQT_READ, 0,
> - indx, buf, size, 1000);
> - if (ret < 0)
> - netif_dbg(pegasus, drv, pegasus->net,
> - "%s returned %d\n", __func__, ret);
> - else if (ret <= size)
> - memcpy(data, buf, ret);
> - kfree(buf);
> - return ret;
> + return usb_control_msg_recv(pegasus->usb, 0, PEGASUS_REQ_GET_REGS,
> + PEGASUS_REQT_READ, 0, indx, data, size,
> + 1000, GFP_NOIO);
> }
>
> static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size,
> const void *data)
> {
> - u8 *buf;
> - int ret;
> -
> - buf = kmemdup(data, size, GFP_NOIO);
> - if (!buf)
> - return -ENOMEM;
> -
> - ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0),
> - PEGASUS_REQ_SET_REGS, PEGASUS_REQT_WRITE, 0,
> - indx, buf, size, 100);
> - if (ret < 0)
> - netif_dbg(pegasus, drv, pegasus->net,
> - "%s returned %d\n", __func__, ret);
> - kfree(buf);
> - return ret;
> + return usb_control_msg_send(pegasus->usb, 0, PEGASUS_REQ_SET_REGS,
> + PEGASUS_REQT_WRITE, 0, indx, data, size, 1000,
> + GFP_NOIO);
> }
>
> static int set_register(pegasus_t *pegasus, __u16 indx, __u8 data)
> {
> - u8 *buf;
> - int ret;
> -
> - buf = kmemdup(&data, 1, GFP_NOIO);
> - if (!buf)
> - return -ENOMEM;
> -
> - ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0),
> - PEGASUS_REQ_SET_REG, PEGASUS_REQT_WRITE, data,
> - indx, buf, 1, 1000);
> - if (ret < 0)
> - netif_dbg(pegasus, drv, pegasus->net,
> - "%s returned %d\n", __func__, ret);
> - kfree(buf);
> - return ret;
> + return usb_control_msg_send(pegasus->usb, 0, PEGASUS_REQ_SET_REG,
> + PEGASUS_REQT_WRITE, data, indx, &data, 1,
> + 1000, GFP_NOIO);
> }
Again, why isn't set_register() now rewritten to just be:
static int set_register(pegasus_t *pegasus, __u16 indx, __u8 data)
{
return set_registers(pegasus, indx, 1, data);
}
Much easier to show that it's all converted properly :)
thanks,
greg k-h
next prev parent reply other threads:[~2020-09-26 5:45 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-23 13:43 [RFC] change the new message to provide for memory allocations Oliver Neukum
2020-09-23 13:43 ` [RFC 01/14] Revert "USB: core: hub.c: use usb_control_msg_send() in a few places" Oliver Neukum
2020-09-23 13:43 ` [RFC 02/14] Revert "Bluetooth: ath3k: use usb_control_msg_send() and usb_control_msg_recv()" Oliver Neukum
2020-09-23 13:43 ` [RFC 03/14] Revert "sound: hiface: move to use usb_control_msg_send()" Oliver Neukum
2020-09-23 13:43 ` [RFC 04/14] Revert "sound: line6: move to use usb_control_msg_send() and usb_control_msg_recv()" Oliver Neukum
2020-09-23 13:43 ` [RFC 05/14] Revert "sound: 6fire: " Oliver Neukum
2020-09-23 13:43 ` [RFC 06/14] Revert "sound: usx2y: move to use usb_control_msg_send()" Oliver Neukum
2020-09-23 13:43 ` [RFC 07/14] Revert "USB: legousbtower: use usb_control_msg_recv()" Oliver Neukum
2020-09-23 13:43 ` [RFC 08/14] USB: correct API of usb_control_msg_send/recv Oliver Neukum
2020-09-25 9:31 ` [PATCH 0/2] [usb] Petko Manolov
2020-09-25 9:31 ` [PATCH 1/2] net: pegasus: convert control messages to the new send/recv scheme Petko Manolov
2020-09-25 14:37 ` Greg KH
2020-09-25 16:01 ` [PATCH 0/2] [patch v2] utilize the new control message send and receive API Petko Manolov
2020-09-25 16:01 ` [PATCH 1/2] net: pegasus: convert control messages to the new send/recv scheme Petko Manolov
2020-09-26 5:44 ` Greg KH [this message]
2020-09-26 8:21 ` Petko Manolov
2020-09-26 12:45 ` Greg KH
2020-09-25 16:02 ` [PATCH 2/2] net: rtl8150: " Petko Manolov
2020-09-25 20:14 ` kernel test robot
2020-09-25 16:05 ` [PATCH 1/2] net: pegasus: " Petko Manolov
2020-09-26 5:45 ` Greg KH
2020-09-25 9:31 ` [PATCH 2/2] net: rtl8150: " Petko Manolov
2020-09-25 14:37 ` Greg KH
2020-09-26 9:13 ` [PATCH v3 0/2] Use the new usb control message API Petko Manolov
2020-09-26 9:13 ` [PATCH v3 1/2] net: pegasus: " Petko Manolov
2020-09-26 9:13 ` [PATCH v3 2/2] net: rtl8150: " Petko Manolov
2020-09-27 10:16 ` [PATCH v3 0/2] " Greg KH
2020-09-27 12:56 ` Petko Manolov
2020-09-27 12:49 ` [PATCH RESEND " Petko Manolov
2020-09-27 12:49 ` [PATCH RESEND v3 1/2] net: pegasus: " Petko Manolov
2020-09-27 12:49 ` [PATCH RESEND v3 2/2] net: rtl8150: " Petko Manolov
2020-09-28 23:00 ` [PATCH RESEND v3 0/2] " David Miller
2020-09-29 4:59 ` Petko Manolov
2020-09-29 19:58 ` David Miller
2020-09-30 6:23 ` Greg KH
2020-09-23 13:43 ` [RFC 09/14] sound: usx2y: move to use usb_control_msg_send() Oliver Neukum
2020-09-25 14:32 ` Greg KH
2020-09-23 13:43 ` [RFC 10/14] sound: 6fire: move to use usb_control_msg_send() and usb_control_msg_recv() Oliver Neukum
2020-09-23 13:43 ` [RFC 11/14] USB: legousbtower: use usb_control_msg_recv() Oliver Neukum
2020-09-23 13:43 ` [RFC 12/14] sound: line6: move to use usb_control_msg_send() and usb_control_msg_recv() Oliver Neukum
2020-09-23 13:43 ` [RFC 13/14] sound: hiface: move to use usb_control_msg_send() Oliver Neukum
2020-09-23 13:43 ` [RFC 14/14] Bluetooth: ath3k: use usb_control_msg_send() and usb_control_msg_recv() Oliver Neukum
2020-09-23 17:21 ` [RFC] change the new message to provide for memory allocations Greg KH
2020-09-23 17:32 ` Oliver Neukum
2020-09-23 17:46 ` Greg KH
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=20200926054457.GC631346@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=petkan@nucleusys.com \
--cc=petko.manolov@konsulko.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).