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


Groups > linux.kernel > #1261479

[PATCH 15/23] usb: gadget: composite: handle get_alt() automatically

From Robert Baldyga <r.baldyga@samsung.com>
Newsgroups linux.kernel
Subject [PATCH 15/23] usb: gadget: composite: handle get_alt() automatically
Date 2015-11-03 14:00 +0100
Message-ID <qqJlW-2OU-53@gated-at.bofh.it> (permalink)
References <qqJlU-2OU-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


As now we store current altsetting number for each interface, we can
handle USB_REQ_GET_INTERFACE automatically.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
 drivers/usb/gadget/composite.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 5ce95d2..21f8c51 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -2075,7 +2075,13 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
 		if (!f)
 			break;
 		/* lots of interfaces only need altsetting zero... */
-		value = f->get_alt ? f->get_alt(f, w_index) : 0;
+		if (usb_function_is_new_api(f)) {
+			value = usb_interface_id_to_index(f, intf);
+			if (value >= 0)
+				value = f->descs->intfs[value]->cur_altset;
+		} else {
+			value = f->get_alt ? f->get_alt(f, w_index) : 0;
+		}
 		if (value < 0)
 			break;
 		*((u8 *)req->buf) = value;
-- 
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 00/23] usb: gadget: composite: introduce new function API Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
  [PATCH 21/23] usb: gadget: f_sourcesink: convert to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
  [PATCH 09/23] usb: gadget: composite: handle function bind Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
  [PATCH 22/23] usb: gadget: f_ecm: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
  [PATCH 19/23] usb: gadget: configfs: add new composite API support Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
  [PATCH 15/23] usb: gadget: composite: handle get_alt() automatically Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
  [PATCH 01/23] usb: gadget: f_sourcesink: make ISO altset  user-selectable Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
    Re: [PATCH 01/23] usb: gadget: f_sourcesink: make ISO altset  user-selectable Robert Baldyga <r.baldyga@samsung.com> - 2015-11-06 08:30 +0100
  [PATCH 03/23] usb: gadget: f_sourcesink: free requests in  sourcesink_disable() Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:00 +0100
    Re: [PATCH 03/23] usb: gadget: f_sourcesink: free requests in  sourcesink_disable() Robert Baldyga <r.baldyga@samsung.com> - 2015-11-06 10:00 +0100
      Re: [PATCH 03/23] usb: gadget: f_sourcesink: free requests in  sourcesink_disable() Krzysztof Opasiak <k.opasiak@samsung.com> - 2015-11-06 11:00 +0100
  [PATCH 06/23] usb: gadget: composite: introduce new descriptors format Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:10 +0100
  [PATCH 10/23] usb: gadget: composite: handle vendor descs Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:10 +0100
  [PATCH 05/23] usb: gadget: configfs: fix error path Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:10 +0100
    Re: [PATCH 05/23] usb: gadget: configfs: fix error path Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-11-03 14:50 +0100
  [PATCH 11/23] usb: gadget: composite: generate old descs for  compatibility Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:10 +0100
  [PATCH 02/23] usb: gadget: f_sourcesink: compute req size once Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:10 +0100
  [PATCH 07/23] usb: gadget: composite: add functions for descriptors  handling Robert Baldyga <r.baldyga@samsung.com> - 2015-11-03 14:10 +0100

csiph-web