Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932192AbbKCM54 (ORCPT ); Tue, 3 Nov 2015 07:57:56 -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 S1753999AbbKCMzF (ORCPT ); Tue, 3 Nov 2015 07:55:05 -0500 X-AuditID: cbfee61a-f79a06d000005c6f-d2-5638aea7f6c8 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 16/23] usb: gadget: composite: add usb_function_get_ep() function Date: Tue, 03 Nov 2015 13:53:55 +0100 Message-id: <1446555242-3733-17-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+NgFprKLMWRmVeSWpSXmKPExsVy+t9jQd3l6yzCDP5dVrGY9bKdxWLjjPWs Fgfv11s0L17PZnF51xw2i0XLWpkt1h65y27x4PBOdgcOj/1z17B79G1Zxehx/MZ2Jo/Pm+QC WKK4bFJSczLLUov07RK4MqZ8aGMq+ClUsazxInsD4yv+LkZODgkBE4l705cyQ9hiEhfurWfr YuTiEBKYxSgxZfl/VgjnJ6NE96bLjCBVbAI6Elu+TwCzRQQEJNa/uMQOUsQscI5R4uGdNrCE sECwxO/N68HGsgioSvT2fWYDsXkFXCUeN09iglgnJ3Hy2GSgDRwcnEDxS++UQUwhAReJ49t5 JjDyLmBkWMUokVqQXFCclJ5rmJdarlecmFtcmpeul5yfu4kRHFjPpHYwHtzlfohRgINRiYd3 wRLzMCHWxLLiytxDjBIczEoivLvnWoQJ8aYkVlalFuXHF5XmpBYfYpTmYFES59X3NAoTEkhP LEnNTk0tSC2CyTJxcEo1MGoo2152m/eUzdPknkSurmfbqX31N+dopLkuDdy38a3ELvnFlR1/ OeuPtl6p9NXwsJke+f6kc/9XE/FbE/XEeCJ5D/f2nki4+qlhyX7Fzmvn43TkRdceKhBjm2mo efvj49stsTe1b1qr/GlRzGDx9OLastvIvVSU49ThLVc3/LojMIm9+ts9cSWW4oxEQy3mouJE ANixxSQoAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2600 Lines: 75 Introduce function returning endpoint of given index in active altsetting of specified interface. It's intended to be used in set_alt() callback to obtain endpoints of currently selected altsetting. Signed-off-by: Robert Baldyga --- drivers/usb/gadget/composite.c | 33 +++++++++++++++++++++++++++++++++ include/linux/usb/composite.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 21f8c51..0e264c5 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -671,6 +671,39 @@ static int usb_interface_id_to_index(struct usb_function *f, u8 id) } /** + * usb_function_get_ep - obtains endpoint of given index from active + * altsetting of given interface + * @f: USB function + * @i: index of interface in given function + * @e: index of endpoint in active altsetting of given interface + * + * This function is designed to be used in set_alt() callback, when + * new altsetting is selected. It allows to obtain endpoints assigned + * to altsetting during autoconfig process. + * + * Returns pointer to endpoint on success or NULL on failure. + */ +struct usb_ep *usb_function_get_ep(struct usb_function *f, int i, int e) +{ + struct usb_composite_altset *altset; + int selected_altset; + + if (!f->descs) + return NULL; + if (i >= f->descs->intfs_num) + return NULL; + + selected_altset = f->descs->intfs[i]->cur_altset; + altset = f->descs->intfs[i]->altsets[selected_altset]; + + if (e >= altset->eps_num) + return NULL; + + return altset->eps[e]->ep; +} +EXPORT_SYMBOL_GPL(usb_function_get_ep); + +/** * usb_interface_id() - allocate an unused interface ID * @config: configuration associated with the interface * @function: function handling the interface diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 3838eb6..e12921c 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -418,6 +418,8 @@ int usb_ep_add_vendor_desc(struct usb_function *f, int i, int a, int e, struct usb_descriptor_header *desc); +struct usb_ep *usb_function_get_ep(struct usb_function *f, int intf, int ep); + int usb_interface_id(struct usb_configuration *, struct usb_function *); int config_ep_by_speed(struct usb_gadget *g, struct usb_function *f, -- 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/