Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754271AbbKCMzI (ORCPT ); Tue, 3 Nov 2015 07:55:08 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:49096 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754219AbbKCMzC (ORCPT ); Tue, 3 Nov 2015 07:55:02 -0500 X-AuditID: cbfee61a-f79a06d000005c6f-ce-5638aea474cd From: Robert Baldyga To: balbi@ti.com Cc: gregkh@linuxfoundation.org, andrzej.p@samsung.com, m.szyprowski@samsung.com, b.zolnierkie@samsung.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Baldyga Subject: [PATCH 15/23] usb: gadget: composite: handle get_alt() automatically Date: Tue, 03 Nov 2015 13:53:54 +0100 Message-id: <1446555242-3733-16-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1446555242-3733-1-git-send-email-r.baldyga@samsung.com> References: <1446555242-3733-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMLMWRmVeSWpSXmKPExsVy+t9jQd0l6yzCDCY/VLWY9bKdxWLjjPWs Fgfv11s0L17PZnF51xw2i0XLWpkt1h65y27x4PBOdgcOj/1z17B79G1Zxehx/MZ2Jo/Pm+QC WKK4bFJSczLLUov07RK4MrqmvWMueMNesXp5aAPjRrYuRk4OCQETieb2S4wQtpjEhXvrweJC ArMYJZYscu1i5AKyfzJKbJi6gxUkwSagI7Hl+wSwBhEBAYn1Ly6xgxQxC5xjlHh4pw0sISzg K3F+/15mEJtFQFXiyudmFhCbV8BV4synY6wQ2+QkTh6bDGRzcHACxS+9UwYxhQRcJI5v55nA yLuAkWEVo0RqQXJBcVJ6rmFearlecWJucWleul5yfu4mRnBQPZPawXhwl/shRgEORiUe3gVL zMOEWBPLiitzDzFKcDArifDunmsRJsSbklhZlVqUH19UmpNafIhRmoNFSZxX39MoTEggPbEk NTs1tSC1CCbLxMEp1cC4O/2oXUrS8/SD8lPTPG5f1O947tb+SOlCCssM+acyYYe7uOfdrFFq P9qhubmJ596bL0+XN6sdcjQz7zqiJyMkbf3T4s30ucfttr6oc+O7cZnvgFEf+0SOxbMydSxd Eo548ur1xgddimbe0fv1gtXVk9/jWBbnT+BJWdbR0Hz5lJdYkdjyM6eUWIozEg21mIuKEwHu lgjZJgIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1219 Lines: 35 As now we store current altsetting number for each interface, we can handle USB_REQ_GET_INTERFACE automatically. Signed-off-by: Robert Baldyga --- 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/