Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1201528 > unrolled thread
| Started by | Robert Baldyga <r.baldyga@samsung.com> |
|---|---|
| First post | 2015-08-06 10:00 +0200 |
| Last post | 2015-08-06 10:10 +0200 |
| Articles | 11 — 2 participants |
Back to article view | Back to linux.kernel
[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
| From | Robert Baldyga <r.baldyga@samsung.com> |
|---|---|
| Date | 2015-08-06 10:00 +0200 |
| Subject | [PATCH v7 0/8] usb: gadget: rework ep matching and claiming mechanism |
| Message-ID | <pUofL-2xG-1@gated-at.bofh.it> |
Hi Felipe,
These are remaining patches of my series plus one which remained from
series [1].
In this version of this patch set I have changed gadget_find_ep_by_name()
to exported symbol, as Alan suggested.
[1] usb: gadget: get rid of UDC name-based quirks
https://lkml.org/lkml/2015/7/28/29
Best regards,
Robert Baldyga
Changelog:
v7:
- make gadget_find_ep_by_name() exported symbol instead of static inline
as Alan Stern suggested
v6: https://lkml.org/lkml/2015/8/5/312
- fix regression in ep_matches() function
v5: https://lkml.org/lkml/2015/7/31/402
- made code more grepable according to Felipe's suggestion
v4: https://lkml.org/lkml/2015/7/27/181
- addressed comments from Krzysztof Opasiak and Felipe Balbi
v3: https://lkml.org/lkml/2015/7/15/68
- addressed comments from Sergei Shtylyov
v2: https://lkml.org/lkml/2015/7/14/172
- remove PXA quirk from ep_matches() function without behaviour change
using ep capabilities flags
- separate ep and desc configuration code from ep_match() function
- add 'ep_match' to usb_gadget_ops and move chip-specific endpoint
matching algorithms from generic code to UDC controller drivers
v1: https://lkml.org/lkml/2015/7/8/436
Robert Baldyga (8):
usb: gadget: epautoconf: rework ep_matches() function
usb: gadget: add 'ep_match' callback to usb_gadget_ops
usb: gadget: move ep_matches() from epautoconf to udc-core
usb: gadget: move find_ep() from epautoconf to udc-core
usb: gadget: net2280: add net2280_match_ep() function
usb: gadget: goku_udc: add goku_match_ep() function
usb: musb: gadget: add musb_match_ep() function
usb: gadget: remove gadget_chips.h
drivers/usb/gadget/epautoconf.c | 166 +--------------------------
drivers/usb/gadget/function/f_acm.c | 1 -
drivers/usb/gadget/function/f_mass_storage.c | 1 -
drivers/usb/gadget/function/f_obex.c | 1 -
drivers/usb/gadget/function/f_serial.c | 1 -
drivers/usb/gadget/function/f_sourcesink.c | 1 -
drivers/usb/gadget/function/u_ether.h | 2 -
drivers/usb/gadget/function/u_uac1.h | 2 -
drivers/usb/gadget/legacy/audio.c | 1 -
drivers/usb/gadget/legacy/gmidi.c | 2 -
drivers/usb/gadget/legacy/hid.c | 1 -
drivers/usb/gadget/legacy/nokia.c | 1 -
drivers/usb/gadget/legacy/printer.c | 2 -
drivers/usb/gadget/legacy/serial.c | 1 -
drivers/usb/gadget/udc/gadget_chips.h | 55 ---------
drivers/usb/gadget/udc/goku_udc.c | 25 ++++
drivers/usb/gadget/udc/net2280.c | 31 +++++
drivers/usb/gadget/udc/udc-core.c | 90 +++++++++++++++
drivers/usb/musb/musb_gadget.c | 34 ++++++
include/linux/usb/gadget.h | 19 ++-
20 files changed, 202 insertions(+), 235 deletions(-)
delete mode 100644 drivers/usb/gadget/udc/gadget_chips.h
--
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/
[toc] | [next] | [standalone]
| From | Robert Baldyga <r.baldyga@samsung.com> |
|---|---|
| Date | 2015-08-06 10:00 +0200 |
| Subject | [PATCH v7 1/8] usb: gadget: epautoconf: rework ep_matches() function |
| Message-ID | <pUofL-2xG-7@gated-at.bofh.it> |
| In reply to | #1201528 |
Rework ep_matches() function to make it shorter and more readable.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
drivers/usb/gadget/epautoconf.c | 81 ++++++++++++++++-------------------------
1 file changed, 32 insertions(+), 49 deletions(-)
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 52658fe..95e1275 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -32,7 +32,6 @@ ep_matches (
{
u8 type;
u16 max;
-
int num_req_streams = 0;
/* endpoint already claimed? */
@@ -40,6 +39,20 @@ ep_matches (
return 0;
type = usb_endpoint_type(desc);
+ max = 0x7ff & usb_endpoint_maxp(desc);
+
+ if (usb_endpoint_dir_in(desc) && !ep->caps.dir_in)
+ return 0;
+ if (usb_endpoint_dir_out(desc) && !ep->caps.dir_out)
+ return 0;
+
+ if (max > ep->maxpacket_limit)
+ return 0;
+
+ /* "high bandwidth" works only at high speed */
+ if (!gadget_is_dualspeed(gadget) && usb_endpoint_maxp(desc) & (3<<11))
+ return 0;
+
switch (type) {
case USB_ENDPOINT_XFER_CONTROL:
/* only support ep0 for portable CONTROL traffic */
@@ -47,66 +60,36 @@ ep_matches (
case USB_ENDPOINT_XFER_ISOC:
if (!ep->caps.type_iso)
return 0;
+ /* ISO: limit 1023 bytes full speed,
+ * 1024 high/super speed
+ */
+ if (!gadget_is_dualspeed(gadget) && max > 1023)
+ return 0;
break;
case USB_ENDPOINT_XFER_BULK:
if (!ep->caps.type_bulk)
return 0;
+ if (ep_comp && gadget_is_superspeed(gadget)) {
+ /* Get the number of required streams from the
+ * EP companion descriptor and see if the EP
+ * matches it
+ */
+ num_req_streams = ep_comp->bmAttributes & 0x1f;
+ if (num_req_streams > ep->max_streams)
+ return 0;
+ }
break;
case USB_ENDPOINT_XFER_INT:
- /* bulk endpoints handle interrupt transfers,
+ /* Bulk endpoints handle interrupt transfers,
* except the toggle-quirky iso-synch kind
*/
if (!ep->caps.type_int && !ep->caps.type_bulk)
return 0;
- break;
- }
-
- if (usb_endpoint_dir_in(desc)) {
- if (!ep->caps.dir_in)
- return 0;
- } else {
- if (!ep->caps.dir_out)
- return 0;
- }
-
- /*
- * Get the number of required streams from the EP companion
- * descriptor and see if the EP matches it
- */
- if (usb_endpoint_xfer_bulk(desc)) {
- if (ep_comp && gadget->max_speed >= USB_SPEED_SUPER) {
- num_req_streams = ep_comp->bmAttributes & 0x1f;
- if (num_req_streams > ep->max_streams)
- return 0;
- }
-
- }
-
- /* endpoint maxpacket size is an input parameter, except for bulk
- * where it's an output parameter representing the full speed limit.
- * the usb spec fixes high speed bulk maxpacket at 512 bytes.
- */
- max = 0x7ff & usb_endpoint_maxp(desc);
- switch (type) {
- case USB_ENDPOINT_XFER_INT:
- /* INT: limit 64 bytes full speed, 1024 high/super speed */
+ /* INT: limit 64 bytes full speed,
+ * 1024 high/super speed
+ */
if (!gadget_is_dualspeed(gadget) && max > 64)
return 0;
- /* FALLTHROUGH */
-
- case USB_ENDPOINT_XFER_ISOC:
- /* ISO: limit 1023 bytes full speed, 1024 high/super speed */
- if (ep->maxpacket_limit < max)
- return 0;
- if (!gadget_is_dualspeed(gadget) && max > 1023)
- return 0;
-
- /* BOTH: "high bandwidth" works only at high speed */
- if ((desc->wMaxPacketSize & cpu_to_le16(3<<11))) {
- if (!gadget_is_dualspeed(gadget))
- return 0;
- /* configure your hardware with enough buffering!! */
- }
break;
}
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Robert Baldyga <r.baldyga@samsung.com> |
|---|---|
| Date | 2015-08-06 10:00 +0200 |
| Subject | [PATCH v7 8/8] usb: gadget: remove gadget_chips.h |
| Message-ID | <pUofM-2xG-9@gated-at.bofh.it> |
| In reply to | #1201528 |
This header file contains helpers for quirks based on UDC controller name.
Since we have generic quirk bitfields in usb_gadget structure for all of
these quirks we don't need to have this header any longer.
This patch removes gadget_chips.h file and makes sure that it's no longer
included anywhere in kernel sources.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
drivers/usb/gadget/epautoconf.c | 2 -
drivers/usb/gadget/function/f_acm.c | 1 -
drivers/usb/gadget/function/f_mass_storage.c | 1 -
drivers/usb/gadget/function/f_obex.c | 1 -
drivers/usb/gadget/function/f_serial.c | 1 -
drivers/usb/gadget/function/f_sourcesink.c | 1 -
drivers/usb/gadget/function/u_ether.h | 2 -
drivers/usb/gadget/function/u_uac1.h | 2 -
drivers/usb/gadget/legacy/audio.c | 1 -
drivers/usb/gadget/legacy/gmidi.c | 2 -
drivers/usb/gadget/legacy/hid.c | 1 -
drivers/usb/gadget/legacy/nokia.c | 1 -
drivers/usb/gadget/legacy/printer.c | 2 -
drivers/usb/gadget/legacy/serial.c | 1 -
drivers/usb/gadget/udc/gadget_chips.h | 55 ----------------------------
15 files changed, 74 deletions(-)
delete mode 100644 drivers/usb/gadget/udc/gadget_chips.h
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 16c1cc9..978435a 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -20,8 +20,6 @@
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
-#include "gadget_chips.h"
-
/**
* usb_ep_autoconfig_ss() - choose an endpoint matching the ep
* descriptor and ep companion descriptor
diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c
index aad8165..be9df09 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -21,7 +21,6 @@
#include <linux/err.h>
#include "u_serial.h"
-#include "gadget_chips.h"
/*
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index 04c3bb6..11a7f5a 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -219,7 +219,6 @@
#include <linux/usb/gadget.h>
#include <linux/usb/composite.h>
-#include "gadget_chips.h"
#include "configfs.h"
diff --git a/drivers/usb/gadget/function/f_obex.c b/drivers/usb/gadget/function/f_obex.c
index 2682d59..5460426 100644
--- a/drivers/usb/gadget/function/f_obex.c
+++ b/drivers/usb/gadget/function/f_obex.c
@@ -20,7 +20,6 @@
#include <linux/module.h>
#include "u_serial.h"
-#include "gadget_chips.h"
/*
diff --git a/drivers/usb/gadget/function/f_serial.c b/drivers/usb/gadget/function/f_serial.c
index 2e02dfa..1d162e2 100644
--- a/drivers/usb/gadget/function/f_serial.c
+++ b/drivers/usb/gadget/function/f_serial.c
@@ -16,7 +16,6 @@
#include <linux/device.h>
#include "u_serial.h"
-#include "gadget_chips.h"
/*
diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c
index e6af171..cbfaf86 100644
--- a/drivers/usb/gadget/function/f_sourcesink.c
+++ b/drivers/usb/gadget/function/f_sourcesink.c
@@ -20,7 +20,6 @@
#include <linux/err.h>
#include "g_zero.h"
-#include "gadget_chips.h"
#include "u_f.h"
/*
diff --git a/drivers/usb/gadget/function/u_ether.h b/drivers/usb/gadget/function/u_ether.h
index 1384f00..c77145b 100644
--- a/drivers/usb/gadget/function/u_ether.h
+++ b/drivers/usb/gadget/function/u_ether.h
@@ -20,8 +20,6 @@
#include <linux/usb/cdc.h>
#include <linux/netdevice.h>
-#include "gadget_chips.h"
-
#define QMULT_DEFAULT 5
/*
diff --git a/drivers/usb/gadget/function/u_uac1.h b/drivers/usb/gadget/function/u_uac1.h
index fe386df..5c2ac8e 100644
--- a/drivers/usb/gadget/function/u_uac1.h
+++ b/drivers/usb/gadget/function/u_uac1.h
@@ -21,8 +21,6 @@
#include <sound/pcm.h>
#include <sound/pcm_params.h>
-#include "gadget_chips.h"
-
#define FILE_PCM_PLAYBACK "/dev/snd/pcmC0D0p"
#define FILE_PCM_CAPTURE "/dev/snd/pcmC0D0c"
#define FILE_CONTROL "/dev/snd/controlC0"
diff --git a/drivers/usb/gadget/legacy/audio.c b/drivers/usb/gadget/legacy/audio.c
index 9b2c1c6..685cf3b 100644
--- a/drivers/usb/gadget/legacy/audio.c
+++ b/drivers/usb/gadget/legacy/audio.c
@@ -15,7 +15,6 @@
#include <linux/module.h>
#include <linux/usb/composite.h>
-#include "gadget_chips.h"
#define DRIVER_DESC "Linux USB Audio Gadget"
#define DRIVER_VERSION "Feb 2, 2012"
diff --git a/drivers/usb/gadget/legacy/gmidi.c b/drivers/usb/gadget/legacy/gmidi.c
index 650568d..8a18348 100644
--- a/drivers/usb/gadget/legacy/gmidi.c
+++ b/drivers/usb/gadget/legacy/gmidi.c
@@ -35,8 +35,6 @@
#include <linux/usb/audio.h>
#include <linux/usb/midi.h>
-#include "gadget_chips.h"
-
#include "u_midi.h"
/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c
index e4874d3..7e5d2c4 100644
--- a/drivers/usb/gadget/legacy/hid.c
+++ b/drivers/usb/gadget/legacy/hid.c
@@ -19,7 +19,6 @@
#include <linux/usb/composite.h>
#include <linux/usb/g_hid.h>
-#include "gadget_chips.h"
#define DRIVER_DESC "HID Gadget"
#define DRIVER_VERSION "2010/03/16"
diff --git a/drivers/usb/gadget/legacy/nokia.c b/drivers/usb/gadget/legacy/nokia.c
index c20f3b5..8b3f6fb 100644
--- a/drivers/usb/gadget/legacy/nokia.c
+++ b/drivers/usb/gadget/legacy/nokia.c
@@ -23,7 +23,6 @@
#include "u_ether.h"
#include "u_phonet.h"
#include "u_ecm.h"
-#include "gadget_chips.h"
#include "f_mass_storage.h"
/* Defines */
diff --git a/drivers/usb/gadget/legacy/printer.c b/drivers/usb/gadget/legacy/printer.c
index 0c1fc06..a22d30a 100644
--- a/drivers/usb/gadget/legacy/printer.c
+++ b/drivers/usb/gadget/legacy/printer.c
@@ -19,8 +19,6 @@
#include <linux/usb/gadget.h>
#include <linux/usb/g_printer.h>
-#include "gadget_chips.h"
-
USB_GADGET_COMPOSITE_OPTIONS();
#define DRIVER_DESC "Printer Gadget"
diff --git a/drivers/usb/gadget/legacy/serial.c b/drivers/usb/gadget/legacy/serial.c
index 9836d16..c5d42e0 100644
--- a/drivers/usb/gadget/legacy/serial.c
+++ b/drivers/usb/gadget/legacy/serial.c
@@ -17,7 +17,6 @@
#include <linux/tty_flip.h>
#include "u_serial.h"
-#include "gadget_chips.h"
/* Defines */
diff --git a/drivers/usb/gadget/udc/gadget_chips.h b/drivers/usb/gadget/udc/gadget_chips.h
deleted file mode 100644
index bcd04bc..0000000
--- a/drivers/usb/gadget/udc/gadget_chips.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * USB device controllers have lots of quirks. Use these macros in
- * gadget drivers or other code that needs to deal with them, and which
- * autoconfigures instead of using early binding to the hardware.
- *
- * This SHOULD eventually work like the ARM mach_is_*() stuff, driven by
- * some config file that gets updated as new hardware is supported.
- * (And avoiding all runtime comparisons in typical one-choice configs!)
- *
- * NOTE: some of these controller drivers may not be available yet.
- * Some are available on 2.4 kernels; several are available, but not
- * yet pushed in the 2.6 mainline tree.
- */
-
-#ifndef __GADGET_CHIPS_H
-#define __GADGET_CHIPS_H
-
-#include <linux/usb/gadget.h>
-
-/*
- * NOTICE: the entries below are alphabetical and should be kept
- * that way.
- *
- * Always be sure to add new entries to the correct position or
- * accept the bashing later.
- *
- * If you have forgotten the alphabetical order let VIM/EMACS
- * do that for you.
- */
-#define gadget_is_at91(g) (!strcmp("at91_udc", (g)->name))
-#define gadget_is_goku(g) (!strcmp("goku_udc", (g)->name))
-#define gadget_is_musbhdrc(g) (!strcmp("musb-hdrc", (g)->name))
-#define gadget_is_net2280(g) (!strcmp("net2280", (g)->name))
-#define gadget_is_pxa(g) (!strcmp("pxa25x_udc", (g)->name))
-#define gadget_is_pxa27x(g) (!strcmp("pxa27x_udc", (g)->name))
-
-/**
- * gadget_supports_altsettings - return true if altsettings work
- * @gadget: the gadget in question
- */
-static inline bool gadget_supports_altsettings(struct usb_gadget *gadget)
-{
- /* PXA 21x/25x/26x has no altsettings at all */
- if (gadget_is_pxa(gadget))
- return false;
-
- /* PXA 27x and 3xx have *broken* altsetting support */
- if (gadget_is_pxa27x(gadget))
- return false;
-
- /* Everything else is *presumably* fine ... */
- return true;
-}
-
-#endif /* __GADGET_CHIPS_H */
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Robert Baldyga <r.baldyga@samsung.com> |
|---|---|
| Date | 2015-08-06 10:00 +0200 |
| Subject | [PATCH v7 5/8] usb: gadget: net2280: add net2280_match_ep() function |
| Message-ID | <pUofM-2xG-15@gated-at.bofh.it> |
| In reply to | #1201528 |
Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching
process. Function does the same that was done by chip-specific code inside
of epautoconf. Now this code can be removed from there to separate generic code
from platform specific logic.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
drivers/usb/gadget/epautoconf.c | 23 +----------------------
drivers/usb/gadget/udc/net2280.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index a39ca03..0ff5134 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -86,28 +86,7 @@ struct usb_ep *usb_ep_autoconfig_ss(
/* First, apply chip-specific "best usage" knowledge.
* This might make a good usb_gadget_ops hook ...
*/
- if (gadget_is_net2280(gadget)) {
- char name[8];
-
- if (type == USB_ENDPOINT_XFER_INT) {
- /* ep-e, ep-f are PIO with only 64 byte fifos */
- ep = gadget_find_ep_by_name(gadget, "ep-e");
- if (ep && usb_gadget_ep_match_desc(gadget,
- ep, desc, ep_comp))
- goto found_ep;
- ep = gadget_find_ep_by_name(gadget, "ep-f");
- if (ep && usb_gadget_ep_match_desc(gadget,
- ep, desc, ep_comp))
- goto found_ep;
- }
-
- /* USB3380: use same address for usb and hardware endpoints */
- snprintf(name, sizeof(name), "ep%d%s", usb_endpoint_num(desc),
- usb_endpoint_dir_in(desc) ? "in" : "out");
- ep = gadget_find_ep_by_name(gadget, name);
- if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
- goto found_ep;
- } else if (gadget_is_goku (gadget)) {
+ if (gadget_is_goku(gadget)) {
if (USB_ENDPOINT_XFER_INT == type) {
/* single buffering is enough */
ep = gadget_find_ep_by_name(gadget, "ep3-bulk");
diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 872ca25..9d7eac1 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -1550,6 +1550,36 @@ static int net2280_pullup(struct usb_gadget *_gadget, int is_on)
return 0;
}
+static struct usb_ep *net2280_match_ep(struct usb_gadget *_gadget,
+ struct usb_endpoint_descriptor *desc,
+ struct usb_ss_ep_comp_descriptor *ep_comp)
+{
+ char name[8];
+ struct usb_ep *ep;
+ u8 type;
+
+ type = usb_endpoint_type(desc);
+
+ if (type == USB_ENDPOINT_XFER_INT) {
+ /* ep-e, ep-f are PIO with only 64 byte fifos */
+ ep = gadget_find_ep_by_name(_gadget, "ep-e");
+ if (ep && usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp))
+ return ep;
+ ep = gadget_find_ep_by_name(_gadget, "ep-f");
+ if (ep && usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp))
+ return ep;
+ }
+
+ /* USB3380: use same address for usb and hardware endpoints */
+ snprintf(name, sizeof(name), "ep%d%s", usb_endpoint_num(desc),
+ usb_endpoint_dir_in(desc) ? "in" : "out");
+ ep = gadget_find_ep_by_name(_gadget, name);
+ if (ep && usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp))
+ return ep;
+
+ return NULL;
+}
+
static int net2280_start(struct usb_gadget *_gadget,
struct usb_gadget_driver *driver);
static int net2280_stop(struct usb_gadget *_gadget);
@@ -1561,6 +1591,7 @@ static const struct usb_gadget_ops net2280_ops = {
.pullup = net2280_pullup,
.udc_start = net2280_start,
.udc_stop = net2280_stop,
+ .match_ep = net2280_match_ep,
};
/*-------------------------------------------------------------------------*/
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Robert Baldyga <r.baldyga@samsung.com> |
|---|---|
| Date | 2015-08-06 10:00 +0200 |
| Subject | [PATCH v7 3/8] usb: gadget: move ep_matches() from epautoconf to udc-core |
| Message-ID | <pUofM-2xG-17@gated-at.bofh.it> |
| In reply to | #1201528 |
Move ep_matches() function to udc-core and rename it to
usb_gadget_ep_match_desc(). This function can be used by UDC drivers
in 'match_ep' callback to avoid writing lots of repetitive code.
Replace all calls of ep_matches() with usb_gadget_ep_match_desc().
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
drivers/usb/gadget/epautoconf.c | 95 +++++----------------------------------
drivers/usb/gadget/udc/udc-core.c | 69 ++++++++++++++++++++++++++++
include/linux/usb/gadget.h | 8 ++++
3 files changed, 88 insertions(+), 84 deletions(-)
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index f000c73..d49af4f 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -22,82 +22,6 @@
#include "gadget_chips.h"
-static int
-ep_matches (
- struct usb_gadget *gadget,
- struct usb_ep *ep,
- struct usb_endpoint_descriptor *desc,
- struct usb_ss_ep_comp_descriptor *ep_comp
-)
-{
- u8 type;
- u16 max;
- int num_req_streams = 0;
-
- /* endpoint already claimed? */
- if (ep->claimed)
- return 0;
-
- type = usb_endpoint_type(desc);
- max = 0x7ff & usb_endpoint_maxp(desc);
-
- if (usb_endpoint_dir_in(desc) && !ep->caps.dir_in)
- return 0;
- if (usb_endpoint_dir_out(desc) && !ep->caps.dir_out)
- return 0;
-
- if (max > ep->maxpacket_limit)
- return 0;
-
- /* "high bandwidth" works only at high speed */
- if (!gadget_is_dualspeed(gadget) && usb_endpoint_maxp(desc) & (3<<11))
- return 0;
-
- switch (type) {
- case USB_ENDPOINT_XFER_CONTROL:
- /* only support ep0 for portable CONTROL traffic */
- return 0;
- case USB_ENDPOINT_XFER_ISOC:
- if (!ep->caps.type_iso)
- return 0;
- /* ISO: limit 1023 bytes full speed,
- * 1024 high/super speed
- */
- if (!gadget_is_dualspeed(gadget) && max > 1023)
- return 0;
- break;
- case USB_ENDPOINT_XFER_BULK:
- if (!ep->caps.type_bulk)
- return 0;
- if (ep_comp && gadget_is_superspeed(gadget)) {
- /* Get the number of required streams from the
- * EP companion descriptor and see if the EP
- * matches it
- */
- num_req_streams = ep_comp->bmAttributes & 0x1f;
- if (num_req_streams > ep->max_streams)
- return 0;
- }
- break;
- case USB_ENDPOINT_XFER_INT:
- /* Bulk endpoints handle interrupt transfers,
- * except the toggle-quirky iso-synch kind
- */
- if (!ep->caps.type_int && !ep->caps.type_bulk)
- return 0;
- /* INT: limit 64 bytes full speed,
- * 1024 high/super speed
- */
- if (!gadget_is_dualspeed(gadget) && max > 64)
- return 0;
- break;
- }
-
- /* MATCH!! */
-
- return 1;
-}
-
static struct usb_ep *
find_ep (struct usb_gadget *gadget, const char *name)
{
@@ -180,10 +104,12 @@ struct usb_ep *usb_ep_autoconfig_ss(
if (type == USB_ENDPOINT_XFER_INT) {
/* ep-e, ep-f are PIO with only 64 byte fifos */
ep = find_ep(gadget, "ep-e");
- if (ep && ep_matches(gadget, ep, desc, ep_comp))
+ if (ep && usb_gadget_ep_match_desc(gadget,
+ ep, desc, ep_comp))
goto found_ep;
ep = find_ep(gadget, "ep-f");
- if (ep && ep_matches(gadget, ep, desc, ep_comp))
+ if (ep && usb_gadget_ep_match_desc(gadget,
+ ep, desc, ep_comp))
goto found_ep;
}
@@ -191,20 +117,21 @@ struct usb_ep *usb_ep_autoconfig_ss(
snprintf(name, sizeof(name), "ep%d%s", usb_endpoint_num(desc),
usb_endpoint_dir_in(desc) ? "in" : "out");
ep = find_ep(gadget, name);
- if (ep && ep_matches(gadget, ep, desc, ep_comp))
+ if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
goto found_ep;
} else if (gadget_is_goku (gadget)) {
if (USB_ENDPOINT_XFER_INT == type) {
/* single buffering is enough */
ep = find_ep(gadget, "ep3-bulk");
- if (ep && ep_matches(gadget, ep, desc, ep_comp))
+ if (ep && usb_gadget_ep_match_desc(gadget,
+ ep, desc, ep_comp))
goto found_ep;
} else if (USB_ENDPOINT_XFER_BULK == type
&& (USB_DIR_IN & desc->bEndpointAddress)) {
/* DMA may be available */
ep = find_ep(gadget, "ep2-bulk");
- if (ep && ep_matches(gadget, ep, desc,
- ep_comp))
+ if (ep && usb_gadget_ep_match_desc(gadget,
+ ep, desc, ep_comp))
goto found_ep;
}
@@ -223,14 +150,14 @@ struct usb_ep *usb_ep_autoconfig_ss(
ep = find_ep(gadget, "ep2out");
} else
ep = NULL;
- if (ep && ep_matches(gadget, ep, desc, ep_comp))
+ if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
goto found_ep;
#endif
}
/* Second, look at endpoints until an unclaimed one looks usable */
list_for_each_entry (ep, &gadget->ep_list, ep_list) {
- if (ep_matches(gadget, ep, desc, ep_comp))
+ if (usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
goto found_ep;
}
diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
index 362ee8a..b6427d1 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -131,6 +131,75 @@ EXPORT_SYMBOL_GPL(usb_gadget_giveback_request);
/* ------------------------------------------------------------------------- */
+int usb_gadget_ep_match_desc(struct usb_gadget *gadget,
+ struct usb_ep *ep, struct usb_endpoint_descriptor *desc,
+ struct usb_ss_ep_comp_descriptor *ep_comp)
+{
+ u8 type;
+ u16 max;
+ int num_req_streams = 0;
+
+ /* endpoint already claimed? */
+ if (ep->claimed)
+ return 0;
+
+ type = usb_endpoint_type(desc);
+ max = 0x7ff & usb_endpoint_maxp(desc);
+
+ if (usb_endpoint_dir_in(desc) && !ep->caps.dir_in)
+ return 0;
+ if (usb_endpoint_dir_out(desc) && !ep->caps.dir_out)
+ return 0;
+
+ if (max > ep->maxpacket_limit)
+ return 0;
+
+ /* "high bandwidth" works only at high speed */
+ if (!gadget_is_dualspeed(gadget) && usb_endpoint_maxp(desc) & (3<<11))
+ return 0;
+
+ switch (type) {
+ case USB_ENDPOINT_XFER_CONTROL:
+ /* only support ep0 for portable CONTROL traffic */
+ return 0;
+ case USB_ENDPOINT_XFER_ISOC:
+ if (!ep->caps.type_iso)
+ return 0;
+ /* ISO: limit 1023 bytes full speed, 1024 high/super speed */
+ if (!gadget_is_dualspeed(gadget) && max > 1023)
+ return 0;
+ break;
+ case USB_ENDPOINT_XFER_BULK:
+ if (!ep->caps.type_bulk)
+ return 0;
+ if (ep_comp && gadget_is_superspeed(gadget)) {
+ /* Get the number of required streams from the
+ * EP companion descriptor and see if the EP
+ * matches it
+ */
+ num_req_streams = ep_comp->bmAttributes & 0x1f;
+ if (num_req_streams > ep->max_streams)
+ return 0;
+ }
+ break;
+ case USB_ENDPOINT_XFER_INT:
+ /* Bulk endpoints handle interrupt transfers,
+ * except the toggle-quirky iso-synch kind
+ */
+ if (!ep->caps.type_int && !ep->caps.type_bulk)
+ return 0;
+ /* INT: limit 64 bytes full speed, 1024 high/super speed */
+ if (!gadget_is_dualspeed(gadget) && max > 64)
+ return 0;
+ break;
+ }
+
+ return 1;
+}
+EXPORT_SYMBOL_GPL(usb_gadget_ep_match_desc);
+
+/* ------------------------------------------------------------------------- */
+
static void usb_gadget_state_work(struct work_struct *work)
{
struct usb_gadget *gadget = work_to_gadget(work);
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 303214b..e04fd63 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -1204,6 +1204,14 @@ extern void usb_gadget_giveback_request(struct usb_ep *ep,
/*-------------------------------------------------------------------------*/
+/* utility to check if endpoint caps match descriptor needs */
+
+extern int usb_gadget_ep_match_desc(struct usb_gadget *gadget,
+ struct usb_ep *ep, struct usb_endpoint_descriptor *desc,
+ struct usb_ss_ep_comp_descriptor *ep_comp);
+
+/*-------------------------------------------------------------------------*/
+
/* utility to update vbus status for udc core, it may be scheduled */
extern void usb_udc_vbus_handler(struct usb_gadget *gadget, bool status);
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Robert Baldyga <r.baldyga@samsung.com> |
|---|---|
| Date | 2015-08-06 10:00 +0200 |
| Subject | [PATCH v7 7/8] usb: musb: gadget: add musb_match_ep() function |
| Message-ID | <pUofN-2xG-19@gated-at.bofh.it> |
| In reply to | #1201528 |
Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching
process. Function does the same that was done by chip-specific code inside
of epautoconf. Now this code can be removed from there to separate generic code
from platform specific logic.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
drivers/usb/gadget/epautoconf.c | 23 -----------------------
drivers/usb/musb/musb_gadget.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 574b6a4..16c1cc9 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -83,29 +83,6 @@ struct usb_ep *usb_ep_autoconfig_ss(
goto found_ep;
}
- /* First, apply chip-specific "best usage" knowledge.
- * This might make a good usb_gadget_ops hook ...
- */
-#ifdef CONFIG_BLACKFIN
- if (gadget_is_musbhdrc(gadget)) {
- if ((USB_ENDPOINT_XFER_BULK == type) ||
- (USB_ENDPOINT_XFER_ISOC == type)) {
- if (USB_DIR_IN & desc->bEndpointAddress)
- ep = gadget_find_ep_by_name(gadget, "ep5in");
- else
- ep = gadget_find_ep_by_name(gadget, "ep6out");
- } else if (USB_ENDPOINT_XFER_INT == type) {
- if (USB_DIR_IN & desc->bEndpointAddress)
- ep = gadget_find_ep_by_name(gadget, "ep1in");
- else
- ep = gadget_find_ep_by_name(gadget, "ep2out");
- } else
- ep = NULL;
- if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
- goto found_ep;
- }
-#endif
-
/* Second, look at endpoints until an unclaimed one looks usable */
list_for_each_entry (ep, &gadget->ep_list, ep_list) {
if (usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 4150baf..ac2f188 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1684,6 +1684,39 @@ static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on)
return 0;
}
+#ifdef CONFIG_BLACKFIN
+static struct usb_ep *musb_match_ep(struct usb_gadget *g,
+ struct usb_endpoint_descriptor *desc,
+ struct usb_ss_ep_comp_descriptor *ep_comp)
+{
+ struct usb_ep *ep = NULL;
+ u8 type = usb_endpoint_type(desc);
+
+ switch (type) {
+ case USB_ENDPOINT_XFER_ISOC:
+ case USB_ENDPOINT_XFER_BULK:
+ if (usb_endpoint_dir_in(desc))
+ ep = gadget_find_ep_by_name(g, "ep5in");
+ else
+ ep = gadget_find_ep_by_name(g, "ep6out");
+ break;
+ case USB_ENDPOINT_XFER_INT:
+ if (usb_endpoint_dir_in(desc))
+ ep = gadget_find_ep_by_name(g, "ep1in");
+ else
+ ep = gadget_find_ep_by_name(g, "ep2out");
+ default:
+ }
+
+ if (ep && usb_gadget_ep_match_desc(g, ep, desc, ep_comp))
+ return ep;
+
+ return NULL;
+}
+#else
+#define musb_match_ep NULL
+#endif
+
static int musb_gadget_start(struct usb_gadget *g,
struct usb_gadget_driver *driver);
static int musb_gadget_stop(struct usb_gadget *g);
@@ -1697,6 +1730,7 @@ static const struct usb_gadget_ops musb_gadget_operations = {
.pullup = musb_gadget_pullup,
.udc_start = musb_gadget_start,
.udc_stop = musb_gadget_stop,
+ .match_ep = musb_match_ep,
};
/* ----------------------------------------------------------------------- */
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> |
|---|---|
| Date | 2015-08-06 13:20 +0200 |
| Subject | Re: [PATCH v7 7/8] usb: musb: gadget: add musb_match_ep() function |
| Message-ID | <pUrnj-7jc-5@gated-at.bofh.it> |
| In reply to | #1201535 |
On 8/6/2015 10:58 AM, Robert Baldyga wrote:
> Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching
> process. Function does the same that was done by chip-specific code inside
> of epautoconf. Now this code can be removed from there to separate generic code
> from platform specific logic.
> Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
> ---
> drivers/usb/gadget/epautoconf.c | 23 -----------------------
> drivers/usb/musb/musb_gadget.c | 34 ++++++++++++++++++++++++++++++++++
> 2 files changed, 34 insertions(+), 23 deletions(-)
[...]
> diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
> index 4150baf..ac2f188 100644
> --- a/drivers/usb/musb/musb_gadget.c
> +++ b/drivers/usb/musb/musb_gadget.c
> @@ -1684,6 +1684,39 @@ static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on)
> return 0;
> }
>
> +#ifdef CONFIG_BLACKFIN
> +static struct usb_ep *musb_match_ep(struct usb_gadget *g,
> + struct usb_endpoint_descriptor *desc,
> + struct usb_ss_ep_comp_descriptor *ep_comp)
> +{
> + struct usb_ep *ep = NULL;
> + u8 type = usb_endpoint_type(desc);
You hardly need this variable.
> +
> + switch (type) {
> + case USB_ENDPOINT_XFER_ISOC:
> + case USB_ENDPOINT_XFER_BULK:
> + if (usb_endpoint_dir_in(desc))
> + ep = gadget_find_ep_by_name(g, "ep5in");
> + else
> + ep = gadget_find_ep_by_name(g, "ep6out");
> + break;
> + case USB_ENDPOINT_XFER_INT:
> + if (usb_endpoint_dir_in(desc))
> + ep = gadget_find_ep_by_name(g, "ep1in");
> + else
> + ep = gadget_find_ep_by_name(g, "ep2out");
> + default:
> + }
> +
> + if (ep && usb_gadget_ep_match_desc(g, ep, desc, ep_comp))
> + return ep;
> +
> + return NULL;
> +}
> +#else
> +#define musb_match_ep NULL
> +#endif
> +
> static int musb_gadget_start(struct usb_gadget *g,
> struct usb_gadget_driver *driver);
> static int musb_gadget_stop(struct usb_gadget *g);
[...]
MBR, Sergei
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Robert Baldyga <r.baldyga@samsung.com> |
|---|---|
| Date | 2015-08-06 10:10 +0200 |
| Subject | [PATCH v7 2/8] usb: gadget: add 'ep_match' callback to usb_gadget_ops |
| Message-ID | <pUopt-2Ym-27@gated-at.bofh.it> |
| In reply to | #1201528 |
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/
[toc] | [prev] | [next] | [standalone]
| From | Robert Baldyga <r.baldyga@samsung.com> |
|---|---|
| Date | 2015-08-06 10:10 +0200 |
| Subject | [PATCH v7 6/8] usb: gadget: goku_udc: add goku_match_ep() function |
| Message-ID | <pUopt-2Ym-31@gated-at.bofh.it> |
| In reply to | #1201528 |
Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching
process. Function does the same that was done by chip-specific code inside
of epautoconf. Now this code can be removed from there to separate generic code
from platform specific logic.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
drivers/usb/gadget/epautoconf.c | 20 ++------------------
drivers/usb/gadget/udc/goku_udc.c | 25 +++++++++++++++++++++++++
2 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 0ff5134..574b6a4 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -86,24 +86,8 @@ struct usb_ep *usb_ep_autoconfig_ss(
/* First, apply chip-specific "best usage" knowledge.
* This might make a good usb_gadget_ops hook ...
*/
- if (gadget_is_goku(gadget)) {
- if (USB_ENDPOINT_XFER_INT == type) {
- /* single buffering is enough */
- ep = gadget_find_ep_by_name(gadget, "ep3-bulk");
- if (ep && usb_gadget_ep_match_desc(gadget,
- ep, desc, ep_comp))
- goto found_ep;
- } else if (USB_ENDPOINT_XFER_BULK == type
- && (USB_DIR_IN & desc->bEndpointAddress)) {
- /* DMA may be available */
- ep = gadget_find_ep_by_name(gadget, "ep2-bulk");
- if (ep && usb_gadget_ep_match_desc(gadget,
- ep, desc, ep_comp))
- goto found_ep;
- }
-
#ifdef CONFIG_BLACKFIN
- } else if (gadget_is_musbhdrc(gadget)) {
+ if (gadget_is_musbhdrc(gadget)) {
if ((USB_ENDPOINT_XFER_BULK == type) ||
(USB_ENDPOINT_XFER_ISOC == type)) {
if (USB_DIR_IN & desc->bEndpointAddress)
@@ -119,8 +103,8 @@ struct usb_ep *usb_ep_autoconfig_ss(
ep = NULL;
if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
goto found_ep;
-#endif
}
+#endif
/* Second, look at endpoints until an unclaimed one looks usable */
list_for_each_entry (ep, &gadget->ep_list, ep_list) {
diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c
index 46b8d14..d5a93ea 100644
--- a/drivers/usb/gadget/udc/goku_udc.c
+++ b/drivers/usb/gadget/udc/goku_udc.c
@@ -990,6 +990,30 @@ static int goku_get_frame(struct usb_gadget *_gadget)
return -EOPNOTSUPP;
}
+static struct usb_ep *goku_match_ep(struct usb_gadget *g,
+ struct usb_endpoint_descriptor *desc,
+ struct usb_ss_ep_comp_descriptor *ep_comp)
+{
+ struct goku_udc *dev = to_goku_udc(g);
+ struct usb_ep *ep;
+ u8 type = usb_endpoint_type(desc);
+
+ if (type == USB_ENDPOINT_XFER_INT) {
+ /* single buffering is enough */
+ ep = &dev->ep[3].ep;
+ if (ep && usb_gadget_ep_match_desc(g, ep, desc, ep_comp))
+ return ep;
+ } else if (type == USB_ENDPOINT_XFER_BULK
+ && usb_endpoint_dir_in(desc)) {
+ /* DMA may be available */
+ ep = &dev->ep[2].ep;
+ if (ep && usb_gadget_ep_match_desc(g, ep, desc, ep_comp))
+ return ep;
+ }
+
+ return NULL;
+}
+
static int goku_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver);
static int goku_udc_stop(struct usb_gadget *g);
@@ -998,6 +1022,7 @@ static const struct usb_gadget_ops goku_ops = {
.get_frame = goku_get_frame,
.udc_start = goku_udc_start,
.udc_stop = goku_udc_stop,
+ .match_ep = goku_match_ep,
// no remote wakeup
// not selfpowered
};
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> |
|---|---|
| Date | 2015-08-06 13:20 +0200 |
| Subject | Re: [PATCH v7 6/8] usb: gadget: goku_udc: add goku_match_ep() function |
| Message-ID | <pUrnk-7jc-17@gated-at.bofh.it> |
| In reply to | #1201543 |
Hello.
On 8/6/2015 10:58 AM, Robert Baldyga wrote:
> Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching
> process. Function does the same that was done by chip-specific code inside
> of epautoconf. Now this code can be removed from there to separate generic code
> from platform specific logic.
> Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
> ---
> drivers/usb/gadget/epautoconf.c | 20 ++------------------
> drivers/usb/gadget/udc/goku_udc.c | 25 +++++++++++++++++++++++++
> 2 files changed, 27 insertions(+), 18 deletions(-)
> diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
> index 0ff5134..574b6a4 100644
> --- a/drivers/usb/gadget/epautoconf.c
> +++ b/drivers/usb/gadget/epautoconf.c
> @@ -86,24 +86,8 @@ struct usb_ep *usb_ep_autoconfig_ss(
> /* First, apply chip-specific "best usage" knowledge.
> * This might make a good usb_gadget_ops hook ...
> */
> - if (gadget_is_goku(gadget)) {
> - if (USB_ENDPOINT_XFER_INT == type) {
> - /* single buffering is enough */
> - ep = gadget_find_ep_by_name(gadget, "ep3-bulk");
> - if (ep && usb_gadget_ep_match_desc(gadget,
> - ep, desc, ep_comp))
> - goto found_ep;
> - } else if (USB_ENDPOINT_XFER_BULK == type
> - && (USB_DIR_IN & desc->bEndpointAddress)) {
> - /* DMA may be available */
> - ep = gadget_find_ep_by_name(gadget, "ep2-bulk");
> - if (ep && usb_gadget_ep_match_desc(gadget,
> - ep, desc, ep_comp))
> - goto found_ep;
> - }
> -
> #ifdef CONFIG_BLACKFIN
> - } else if (gadget_is_musbhdrc(gadget)) {
> + if (gadget_is_musbhdrc(gadget)) {
> if ((USB_ENDPOINT_XFER_BULK == type) ||
> (USB_ENDPOINT_XFER_ISOC == type)) {
> if (USB_DIR_IN & desc->bEndpointAddress)
> @@ -119,8 +103,8 @@ struct usb_ep *usb_ep_autoconfig_ss(
> ep = NULL;
> if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
> goto found_ep;
> -#endif
> }
> +#endif
>
> /* Second, look at endpoints until an unclaimed one looks usable */
> list_for_each_entry (ep, &gadget->ep_list, ep_list) {
> diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c
> index 46b8d14..d5a93ea 100644
> --- a/drivers/usb/gadget/udc/goku_udc.c
> +++ b/drivers/usb/gadget/udc/goku_udc.c
> @@ -990,6 +990,30 @@ static int goku_get_frame(struct usb_gadget *_gadget)
> return -EOPNOTSUPP;
> }
>
> +static struct usb_ep *goku_match_ep(struct usb_gadget *g,
> + struct usb_endpoint_descriptor *desc,
> + struct usb_ss_ep_comp_descriptor *ep_comp)
> +{
> + struct goku_udc *dev = to_goku_udc(g);
> + struct usb_ep *ep;
> + u8 type = usb_endpoint_type(desc);
> +
> + if (type == USB_ENDPOINT_XFER_INT) {
> + /* single buffering is enough */
> + ep = &dev->ep[3].ep;
> + if (ep && usb_gadget_ep_match_desc(g, ep, desc, ep_comp))
> + return ep;
> + } else if (type == USB_ENDPOINT_XFER_BULK
> + && usb_endpoint_dir_in(desc)) {
> + /* DMA may be available */
> + ep = &dev->ep[2].ep;
> + if (ep && usb_gadget_ep_match_desc(g, ep, desc, ep_comp))
> + return ep;
You used *switch* in the MUSB driver but not here, despite the above is
also asking for *switch*. Why? :-)
> + }
> +
> + return NULL;
> +}
> +
MBR, Sergei
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Robert Baldyga <r.baldyga@samsung.com> |
|---|---|
| Date | 2015-08-06 10:10 +0200 |
| Subject | [PATCH v7 4/8] usb: gadget: move find_ep() from epautoconf to udc-core |
| Message-ID | <pUopt-2Ym-29@gated-at.bofh.it> |
| In reply to | #1201528 |
Move find_ep() to udc-core and rename it to gadget_find_ep_by_name().
It can be used in UDC drivers, especially in 'match_ep' callback after
moving chip-specific endpoint matching logic from epautoconf to UDC
drivers.
Replace all calls of find_ep() function with gadget_find_ep_by_name().
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
drivers/usb/gadget/epautoconf.c | 30 +++++++++---------------------
drivers/usb/gadget/udc/udc-core.c | 21 +++++++++++++++++++++
include/linux/usb/gadget.h | 8 +++++++-
3 files changed, 37 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index d49af4f..a39ca03 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -22,18 +22,6 @@
#include "gadget_chips.h"
-static struct usb_ep *
-find_ep (struct usb_gadget *gadget, const char *name)
-{
- struct usb_ep *ep;
-
- list_for_each_entry (ep, &gadget->ep_list, ep_list) {
- if (0 == strcmp (ep->name, name))
- return ep;
- }
- return NULL;
-}
-
/**
* usb_ep_autoconfig_ss() - choose an endpoint matching the ep
* descriptor and ep companion descriptor
@@ -103,11 +91,11 @@ struct usb_ep *usb_ep_autoconfig_ss(
if (type == USB_ENDPOINT_XFER_INT) {
/* ep-e, ep-f are PIO with only 64 byte fifos */
- ep = find_ep(gadget, "ep-e");
+ ep = gadget_find_ep_by_name(gadget, "ep-e");
if (ep && usb_gadget_ep_match_desc(gadget,
ep, desc, ep_comp))
goto found_ep;
- ep = find_ep(gadget, "ep-f");
+ ep = gadget_find_ep_by_name(gadget, "ep-f");
if (ep && usb_gadget_ep_match_desc(gadget,
ep, desc, ep_comp))
goto found_ep;
@@ -116,20 +104,20 @@ struct usb_ep *usb_ep_autoconfig_ss(
/* USB3380: use same address for usb and hardware endpoints */
snprintf(name, sizeof(name), "ep%d%s", usb_endpoint_num(desc),
usb_endpoint_dir_in(desc) ? "in" : "out");
- ep = find_ep(gadget, name);
+ ep = gadget_find_ep_by_name(gadget, name);
if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
goto found_ep;
} else if (gadget_is_goku (gadget)) {
if (USB_ENDPOINT_XFER_INT == type) {
/* single buffering is enough */
- ep = find_ep(gadget, "ep3-bulk");
+ ep = gadget_find_ep_by_name(gadget, "ep3-bulk");
if (ep && usb_gadget_ep_match_desc(gadget,
ep, desc, ep_comp))
goto found_ep;
} else if (USB_ENDPOINT_XFER_BULK == type
&& (USB_DIR_IN & desc->bEndpointAddress)) {
/* DMA may be available */
- ep = find_ep(gadget, "ep2-bulk");
+ ep = gadget_find_ep_by_name(gadget, "ep2-bulk");
if (ep && usb_gadget_ep_match_desc(gadget,
ep, desc, ep_comp))
goto found_ep;
@@ -140,14 +128,14 @@ struct usb_ep *usb_ep_autoconfig_ss(
if ((USB_ENDPOINT_XFER_BULK == type) ||
(USB_ENDPOINT_XFER_ISOC == type)) {
if (USB_DIR_IN & desc->bEndpointAddress)
- ep = find_ep (gadget, "ep5in");
+ ep = gadget_find_ep_by_name(gadget, "ep5in");
else
- ep = find_ep (gadget, "ep6out");
+ ep = gadget_find_ep_by_name(gadget, "ep6out");
} else if (USB_ENDPOINT_XFER_INT == type) {
if (USB_DIR_IN & desc->bEndpointAddress)
- ep = find_ep(gadget, "ep1in");
+ ep = gadget_find_ep_by_name(gadget, "ep1in");
else
- ep = find_ep(gadget, "ep2out");
+ ep = gadget_find_ep_by_name(gadget, "ep2out");
} else
ep = NULL;
if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
index b6427d1..3c954b5 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -131,6 +131,27 @@ EXPORT_SYMBOL_GPL(usb_gadget_giveback_request);
/* ------------------------------------------------------------------------- */
+/**
+ * gadget_find_ep_by_name - returns ep whose name is the same as sting passed
+ * in second parameter or NULL if searched endpoint not found
+ * @g: controller to check for quirk
+ * @name: name of searched endpoint
+ */
+struct usb_ep *gadget_find_ep_by_name(struct usb_gadget *g, const char *name)
+{
+ struct usb_ep *ep;
+
+ gadget_for_each_ep(ep, g) {
+ if (!strcmp(ep->name, name))
+ return ep;
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(gadget_find_ep_by_name);
+
+/* ------------------------------------------------------------------------- */
+
int usb_gadget_ep_match_desc(struct usb_gadget *gadget,
struct usb_ep *ep, struct usb_endpoint_descriptor *desc,
struct usb_ss_ep_comp_descriptor *ep_comp)
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index e04fd63..c14a69b3 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -639,7 +639,6 @@ static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev)
#define gadget_for_each_ep(tmp, gadget) \
list_for_each_entry(tmp, &(gadget)->ep_list, ep_list)
-
/**
* usb_ep_align_maybe - returns @len aligned to ep's maxpacketsize if gadget
* requires quirk_ep_out_aligned_size, otherwise reguens len.
@@ -1204,6 +1203,13 @@ extern void usb_gadget_giveback_request(struct usb_ep *ep,
/*-------------------------------------------------------------------------*/
+/* utility to find endpoint by name */
+
+extern struct usb_ep *gadget_find_ep_by_name(struct usb_gadget *g,
+ const char *name);
+
+/*-------------------------------------------------------------------------*/
+
/* utility to check if endpoint caps match descriptor needs */
extern int usb_gadget_ep_match_desc(struct usb_gadget *gadget,
--
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/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web