public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/26] usb: gadget: encapsulate ep enable/disable
@ 2015-09-15 14:26 Robert Baldyga
  2015-09-15 14:26 ` [PATCH 01/26] usb: gadget: fix few outdated comments Robert Baldyga
                   ` (25 more replies)
  0 siblings, 26 replies; 35+ messages in thread
From: Robert Baldyga @ 2015-09-15 14:26 UTC (permalink / raw)
  To: balbi
  Cc: gregkh, linux-usb, linux-kernel, b.zolnierkie, m.szyprowski,
	andrzej.p, Robert Baldyga

Hi Felipe,

There is my next patches series containing few fixes and slightly
reworking USB gadget function API. It introduces ep->enabled flag which
indicates whether endpointis enabled or not, and encapsulates its checking
and setting into usb_ep_enable() and usb_ep_disable() functions. So now
these functions can be used more safely.

Why is that needed?

For example, it's very common pattern in USB functions to re-enable
endpoints in set_alt(). Usually it looks like:

 usb_ep_disable()
 config_ep_by_speed()
 usb_ep_enable()

So far to avoid disabling endpoint which was already disabled there was
need to remember somehow which endpoints are enabled. Unfortunately for
this purpose no new flag in struct usb_ep was introduced, but instead
ep->driver_data was set and cleared to mark endpoints as enabled/disabled.
This made code a little messy considering that the same ep->driver_data
was used before in bind() to claim endpoints obtained from autoconfig,
and moreover many functions use the same ep->driver_data to save some
private pointer, accessible for example in complete() callback (what is,
I believe, driver_data was designed for).

So as now we have ep->claimed flag for marking claimed endpoints, and
ep->enabled flag to remember its enabled/disabled state, we can finally
use ep->driver_data to only contain pointer to private data.

To achieve this, this patch set modifies all USB functions where abuse
ep->driver_data had place, and leaves them in form, where internal endpoint
state is handled by gadget framework functions, and ep->driver_data has
no additional purpose over containing driver data pointer.

Best regards,
Robert Baldyga

Robert Baldyga (26):
  usb: gadget: fix few outdated comments
  usb: gadget: f_ncm: obtain cdev from function instead of driver_data
  usb: gadget: epautoconf: add usb_ep_autoconfig_release() function
  usb: gadget: introduce 'enabled' flag in struct usb_ep
  usb: gadget: f_ecm: eliminate abuse of ep->driver data
  usb: gadget: f_acm: eliminate abuse of ep->driver data
  usb: gadget: f_eem: eliminate abuse of ep->driver data
  usb: gadget: f_hid: eliminate abuse of ep->driver data
  usb: gadget: f_loopback: eliminate abuse of ep->driver data
  usb: gadget: f_mass_storage: eliminate abuse of ep->driver data
  usb: gadget: f_midi: eliminate abuse of ep->driver data
  usb: gadget: f_ncm: eliminate abuse of ep->driver data
  usb: gadget: f_obex: eliminate abuse of ep->driver data
  usb: gadget: f_phonet: eliminate abuse of ep->driver data
  usb: gadget: f_printer: eliminate abuse of ep->driver data
  usb: gadget: f_rndis: eliminate abuse of ep->driver data
  usb: gadget: f_serial: eliminate abuse of ep->driver data
  usb: gadget: f_sourcesink: eliminate abuse of ep->driver data
  usb: gadget: f_subset: eliminate abuse of ep->driver data
  usb: gadget: f_uac1: eliminate abuse of ep->driver data
  usb: gadget: f_uac2: eliminate abuse of ep->driver data
  usb: gadget: f_uvc: eliminate abuse of ep->driver data
  usb: gadget: u_ether: eliminate abuse of ep->driver data
  usb: gadget: u_serial: eliminate abuse of ep->driver data
  usb: gadget: legacy: dbgp: eliminate abuse of ep->driver data
  usb: gadget: legacy: tcm: eliminate abuse of ep->driver data

 drivers/usb/gadget/composite.c               |  4 +--
 drivers/usb/gadget/epautoconf.c              | 25 ++++++++++++++---
 drivers/usb/gadget/function/f_acm.c          | 23 +++------------
 drivers/usb/gadget/function/f_ecm.c          | 31 +++++---------------
 drivers/usb/gadget/function/f_eem.c          | 16 ++---------
 drivers/usb/gadget/function/f_hid.c          | 12 ++------
 drivers/usb/gadget/function/f_loopback.c     |  5 +---
 drivers/usb/gadget/function/f_mass_storage.c |  4 ---
 drivers/usb/gadget/function/f_midi.c         | 14 ++--------
 drivers/usb/gadget/function/f_ncm.c          | 29 +++++--------------
 drivers/usb/gadget/function/f_obex.c         | 10 +------
 drivers/usb/gadget/function/f_phonet.c       |  8 +-----
 drivers/usb/gadget/function/f_printer.c      |  2 --
 drivers/usb/gadget/function/f_rndis.c        | 24 ++++------------
 drivers/usb/gadget/function/f_serial.c       | 10 +------
 drivers/usb/gadget/function/f_sourcesink.c   | 29 +++++--------------
 drivers/usb/gadget/function/f_subset.c       | 10 +------
 drivers/usb/gadget/function/f_uac1.c         |  4 ---
 drivers/usb/gadget/function/f_uac2.c         | 11 --------
 drivers/usb/gadget/function/f_uvc.c          | 42 ++++++----------------------
 drivers/usb/gadget/function/u_ether.c        |  2 --
 drivers/usb/gadget/function/u_serial.c       |  5 ----
 drivers/usb/gadget/legacy/dbgp.c             | 18 ++----------
 drivers/usb/gadget/legacy/tcm_usb_gadget.c   | 18 ------------
 include/linux/usb/gadget.h                   | 23 +++++++++++++--
 25 files changed, 95 insertions(+), 284 deletions(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2015-09-16  9:49 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-15 14:26 [PATCH 00/26] usb: gadget: encapsulate ep enable/disable Robert Baldyga
2015-09-15 14:26 ` [PATCH 01/26] usb: gadget: fix few outdated comments Robert Baldyga
2015-09-15 14:26 ` [PATCH 02/26] usb: gadget: f_ncm: obtain cdev from function instead of driver_data Robert Baldyga
2015-09-15 14:26 ` [PATCH 03/26] usb: gadget: epautoconf: add usb_ep_autoconfig_release() function Robert Baldyga
2015-09-15 14:26 ` [PATCH 04/26] usb: gadget: introduce 'enabled' flag in struct usb_ep Robert Baldyga
2015-09-15 15:37   ` Krzysztof Opasiak
2015-09-15 15:43     ` Felipe Balbi
2015-09-15 15:57       ` Robert Baldyga
2015-09-15 16:01         ` Felipe Balbi
2015-09-15 16:15       ` Krzysztof Opasiak
2015-09-15 16:30         ` Felipe Balbi
2015-09-15 14:26 ` [PATCH 05/26] usb: gadget: f_ecm: eliminate abuse of ep->driver data Robert Baldyga
2015-09-15 15:45   ` Krzysztof Opasiak
2015-09-16  9:49     ` Robert Baldyga
2015-09-15 14:26 ` [PATCH 06/26] usb: gadget: f_acm: " Robert Baldyga
2015-09-15 14:26 ` [PATCH 07/26] usb: gadget: f_eem: " Robert Baldyga
2015-09-15 14:26 ` [PATCH 08/26] usb: gadget: f_hid: " Robert Baldyga
2015-09-15 14:26 ` [PATCH 09/26] usb: gadget: f_loopback: " Robert Baldyga
2015-09-15 14:26 ` [PATCH 10/26] usb: gadget: f_mass_storage: " Robert Baldyga
2015-09-15 14:26 ` [PATCH 11/26] usb: gadget: f_midi: " Robert Baldyga
2015-09-15 14:26 ` [PATCH 12/26] usb: gadget: f_ncm: " Robert Baldyga
2015-09-15 14:26 ` [PATCH 13/26] usb: gadget: f_obex: " Robert Baldyga
2015-09-15 14:26 ` [PATCH 14/26] usb: gadget: f_phonet: " Robert Baldyga
2015-09-15 14:26 ` [PATCH 15/26] usb: gadget: f_printer: " Robert Baldyga
2015-09-15 14:26 ` [PATCH 16/26] usb: gadget: f_rndis: " Robert Baldyga
2015-09-15 14:27 ` [PATCH 17/26] usb: gadget: f_serial: " Robert Baldyga
2015-09-15 14:27 ` [PATCH 18/26] usb: gadget: f_sourcesink: " Robert Baldyga
2015-09-15 14:27 ` [PATCH 19/26] usb: gadget: f_subset: " Robert Baldyga
2015-09-15 14:27 ` [PATCH 20/26] usb: gadget: f_uac1: " Robert Baldyga
2015-09-15 14:27 ` [PATCH 21/26] usb: gadget: f_uac2: " Robert Baldyga
2015-09-15 14:27 ` [PATCH 22/26] usb: gadget: f_uvc: " Robert Baldyga
2015-09-15 14:27 ` [PATCH 23/26] usb: gadget: u_ether: " Robert Baldyga
2015-09-15 14:27 ` [PATCH 24/26] usb: gadget: u_serial: " Robert Baldyga
2015-09-15 14:27 ` [PATCH 25/26] usb: gadget: legacy: dbgp: " Robert Baldyga
2015-09-15 14:27 ` [PATCH 26/26] usb: gadget: legacy: tcm: " Robert Baldyga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox