[PATCH v2 00/26] usb: gadget: encapsulate ep enable/disable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

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

Changelog:

v2:
- simplify patch "introduce 'enabled' flag in struct usb_ep" according
  to Felipe's suggestion

v1: https://lkml.org/lkml/2015/9/15/571

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                   | 29 +++++++++++++++++--
 25 files changed, 101 insertions(+), 284 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux