Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1201542

[PATCH v7 2/8] usb: gadget: add 'ep_match' callback to usb_gadget_ops

From Robert Baldyga <r.baldyga@samsung.com>
Newsgroups linux.kernel
Subject [PATCH v7 2/8] usb: gadget: add 'ep_match' callback to usb_gadget_ops
Date 2015-08-06 10:10 +0200
Message-ID <pUopt-2Ym-27@gated-at.bofh.it> (permalink)
References <pUofL-2xG-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Add callback that is called by epautoconf to allow UDC driver match the
best endpoint for specific descriptor. It's intended to supply mechanism
which allows to get rid of chip-specific endpoint matching code from
epautoconf.

If gadget has set 'ep_match' callback we prefer to call it first, and
if it fails to find matching endpoint, then we try to use default matching
algorithm.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
 drivers/usb/gadget/epautoconf.c | 6 ++++++
 include/linux/usb/gadget.h      | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 95e1275..f000c73 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -165,6 +165,12 @@ struct usb_ep *usb_ep_autoconfig_ss(
 
 	type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
 
+	if (gadget->ops->match_ep) {
+		ep = gadget->ops->match_ep(gadget, desc, ep_comp);
+		if (ep)
+			goto found_ep;
+	}
+
 	/* First, apply chip-specific "best usage" knowledge.
 	 * This might make a good usb_gadget_ops hook ...
 	 */
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 82b5bcb..303214b 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -534,6 +534,9 @@ struct usb_gadget_ops {
 	int	(*udc_start)(struct usb_gadget *,
 			struct usb_gadget_driver *);
 	int	(*udc_stop)(struct usb_gadget *);
+	struct usb_ep *(*match_ep)(struct usb_gadget *,
+			struct usb_endpoint_descriptor *,
+			struct usb_ss_ep_comp_descriptor *);
 };
 
 /**
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v7 0/8] usb: gadget: rework ep matching and claiming mechanism Robert Baldyga <r.baldyga@samsung.com> - 2015-08-06 10:00 +0200
  [PATCH v7 1/8] usb: gadget: epautoconf: rework ep_matches() function Robert Baldyga <r.baldyga@samsung.com> - 2015-08-06 10:00 +0200
  [PATCH v7 8/8] usb: gadget: remove gadget_chips.h Robert Baldyga <r.baldyga@samsung.com> - 2015-08-06 10:00 +0200
  [PATCH v7 5/8] usb: gadget: net2280: add net2280_match_ep() function Robert Baldyga <r.baldyga@samsung.com> - 2015-08-06 10:00 +0200
  [PATCH v7 3/8] usb: gadget: move ep_matches() from epautoconf to  udc-core Robert Baldyga <r.baldyga@samsung.com> - 2015-08-06 10:00 +0200
  [PATCH v7 7/8] usb: musb: gadget: add musb_match_ep() function Robert Baldyga <r.baldyga@samsung.com> - 2015-08-06 10:00 +0200
    Re: [PATCH v7 7/8] usb: musb: gadget: add musb_match_ep() function Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-08-06 13:20 +0200
  [PATCH v7 2/8] usb: gadget: add 'ep_match' callback to usb_gadget_ops Robert Baldyga <r.baldyga@samsung.com> - 2015-08-06 10:10 +0200
  [PATCH v7 6/8] usb: gadget: goku_udc: add goku_match_ep() function Robert Baldyga <r.baldyga@samsung.com> - 2015-08-06 10:10 +0200
    Re: [PATCH v7 6/8] usb: gadget: goku_udc: add goku_match_ep()  function Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-08-06 13:20 +0200
  [PATCH v7 4/8] usb: gadget: move find_ep() from epautoconf to udc-core Robert Baldyga <r.baldyga@samsung.com> - 2015-08-06 10:10 +0200

csiph-web