From: Robert Baldyga <r.baldyga@samsung.com>
To: "Felipe F. Tonello" <eu@felipetonello.com>, linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Felipe Balbi <balbi@ti.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Clemens Ladisch <clemens@ladisch.de>
Subject: Re: [PATCH v5 3/7] usb: gadget: define free_ep_req as universal function
Date: Fri, 13 Nov 2015 09:11:11 +0100 [thread overview]
Message-ID: <56459B1F.9050303@samsung.com> (raw)
In-Reply-To: <1447177929-22252-4-git-send-email-eu@felipetonello.com>
On 11/10/2015 06:52 PM, Felipe F. Tonello wrote:
> This function is shared between gadget functions, so this avoid unnecessary
> duplicated code and potentially avoid memory leaks.
>
> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
Reviewed-by: Robert Baldyga <r.baldyga@samsung.com>
> ---
> drivers/usb/gadget/function/f_midi.c | 6 ------
> drivers/usb/gadget/function/f_sourcesink.c | 6 ------
> drivers/usb/gadget/function/g_zero.h | 1 -
> drivers/usb/gadget/u_f.c | 1 -
> drivers/usb/gadget/u_f.h | 10 ++++++++--
> 5 files changed, 8 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c
> index 488111d..f36db2d 100644
> --- a/drivers/usb/gadget/function/f_midi.c
> +++ b/drivers/usb/gadget/function/f_midi.c
> @@ -201,12 +201,6 @@ static inline struct usb_request *midi_alloc_ep_req(struct usb_ep *ep,
> return alloc_ep_req(ep, length, length);
> }
>
> -static void free_ep_req(struct usb_ep *ep, struct usb_request *req)
> -{
> - kfree(req->buf);
> - usb_ep_free_request(ep, req);
> -}
> -
> static const uint8_t f_midi_cin_length[] = {
> 0, 0, 2, 3, 3, 1, 2, 3, 3, 3, 3, 3, 2, 2, 3, 1
> };
> diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
> index d7646d3..74f95b1 100644
> --- a/drivers/usb/gadget/function/f_sourcesink.c
> +++ b/drivers/usb/gadget/function/f_sourcesink.c
> @@ -303,12 +303,6 @@ static inline struct usb_request *ss_alloc_ep_req(struct usb_ep *ep, int len)
> return alloc_ep_req(ep, len, ss->buflen);
> }
>
> -void free_ep_req(struct usb_ep *ep, struct usb_request *req)
> -{
> - kfree(req->buf);
> - usb_ep_free_request(ep, req);
> -}
> -
> static void disable_ep(struct usb_composite_dev *cdev, struct usb_ep *ep)
> {
> int value;
> diff --git a/drivers/usb/gadget/function/g_zero.h b/drivers/usb/gadget/function/g_zero.h
> index 15f1809..5ed90b4 100644
> --- a/drivers/usb/gadget/function/g_zero.h
> +++ b/drivers/usb/gadget/function/g_zero.h
> @@ -59,7 +59,6 @@ void lb_modexit(void);
> int lb_modinit(void);
>
> /* common utilities */
> -void free_ep_req(struct usb_ep *ep, struct usb_request *req);
> void disable_endpoints(struct usb_composite_dev *cdev,
> struct usb_ep *in, struct usb_ep *out,
> struct usb_ep *iso_in, struct usb_ep *iso_out);
> diff --git a/drivers/usb/gadget/u_f.c b/drivers/usb/gadget/u_f.c
> index c6276f0..4bc7eea 100644
> --- a/drivers/usb/gadget/u_f.c
> +++ b/drivers/usb/gadget/u_f.c
> @@ -11,7 +11,6 @@
> * published by the Free Software Foundation.
> */
>
> -#include <linux/usb/gadget.h>
> #include "u_f.h"
>
> struct usb_request *alloc_ep_req(struct usb_ep *ep, int len, int default_len)
> diff --git a/drivers/usb/gadget/u_f.h b/drivers/usb/gadget/u_f.h
> index 1d5f0eb..4247cc0 100644
> --- a/drivers/usb/gadget/u_f.h
> +++ b/drivers/usb/gadget/u_f.h
> @@ -16,6 +16,8 @@
> #ifndef __U_F_H__
> #define __U_F_H__
>
> +#include <linux/usb/gadget.h>
> +
> /* Variable Length Array Macros **********************************************/
> #define vla_group(groupname) size_t groupname##__next = 0
> #define vla_group_size(groupname) groupname##__next
> @@ -45,8 +47,12 @@
> struct usb_ep;
> struct usb_request;
>
> +/* Requests allocated via alloc_ep_req() must be freed by free_ep_req(). */
> struct usb_request *alloc_ep_req(struct usb_ep *ep, int len, int default_len);
> +static inline void free_ep_req(struct usb_ep *ep, struct usb_request *req)
> +{
> + kfree(req->buf);
> + usb_ep_free_request(ep, req);
> +}
>
> #endif /* __U_F_H__ */
> -
> -
>
next prev parent reply other threads:[~2015-11-13 8:11 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 17:52 [PATCH v5 0/7] USB MIDI Gadget improvements and bug fixes Felipe F. Tonello
2015-11-10 17:52 ` [PATCH v5 1/7] usb: gadget: f_midi: Transmit data only when IN ep is enabled Felipe F. Tonello
2015-11-13 8:08 ` Robert Baldyga
2015-11-10 17:52 ` [PATCH v5 2/7] usb: gadget: f_midi: remove duplicated code Felipe F. Tonello
2015-11-13 8:09 ` Robert Baldyga
2015-11-10 17:52 ` [PATCH v5 3/7] usb: gadget: define free_ep_req as universal function Felipe F. Tonello
2015-11-13 8:11 ` Robert Baldyga [this message]
2015-11-10 17:52 ` [PATCH v5 4/7] usb: gadget: f_midi: fix leak on failed to enqueue out requests Felipe F. Tonello
2015-11-13 8:31 ` Robert Baldyga
2015-11-16 11:08 ` Felipe Ferreri Tonello
2015-11-16 11:43 ` Robert Baldyga
2015-11-25 13:02 ` Felipe Ferreri Tonello
2015-11-10 17:52 ` [PATCH v5 5/7] usb: gadget: gmidi: Cleanup legacy code Felipe F. Tonello
2015-11-13 8:34 ` Robert Baldyga
2015-11-10 17:52 ` [PATCH v5 6/7] usb: gadget: f_midi: set altsettings only for MIDIStreaming interface Felipe F. Tonello
2015-11-10 18:43 ` Sergei Shtylyov
2015-11-11 9:38 ` Felipe Ferreri Tonello
2015-11-11 18:02 ` Sergei Shtylyov
2015-11-13 8:11 ` Clemens Ladisch
2015-11-16 11:41 ` Felipe Ferreri Tonello
2015-11-13 8:14 ` Clemens Ladisch
2015-11-10 17:52 ` [PATCH v5 7/7] usb: gadget: f_midi: pre-allocate IN requests Felipe F. Tonello
2015-11-13 8:55 ` Clemens Ladisch
2015-11-25 17:22 ` Felipe Ferreri Tonello
2015-11-27 9:05 ` Clemens Ladisch
2015-11-27 18:03 ` Felipe Ferreri Tonello
2015-11-27 19:52 ` Clemens Ladisch
2015-11-13 12:38 ` Robert Baldyga
2015-11-25 16:54 ` Felipe Ferreri Tonello
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=56459B1F.9050303@samsung.com \
--to=r.baldyga@samsung.com \
--cc=balbi@ti.com \
--cc=clemens@ladisch.de \
--cc=eu@felipetonello.com \
--cc=gregkh@linuxfoundation.org \
--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
Powered by JetHome