Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932172AbbKCM52 (ORCPT ); Tue, 3 Nov 2015 07:57:28 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:40959 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754225AbbKCMzH (ORCPT ); Tue, 3 Nov 2015 07:55:07 -0500 X-AuditID: cbfee61b-f79d56d0000048c5-a0-5638aeaadf0b 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 17/23] usb: gadget: composite: add usb_get_interface_id() function Date: Tue, 03 Nov 2015 13:53:56 +0100 Message-id: <1446555242-3733-18-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+t9jQd1V6yzCDCYfULSY9bKdxWLjjPWs Fgfv11s0L17PZnF51xw2i0XLWpkt1h65y27x4PBOdgcOj/1z17B79G1Zxehx/MZ2Jo/Pm+QC WKK4bFJSczLLUov07RK4Mhb+b2UqOMhfMf3QCsYGxp88XYycHBICJhJ9t1rYIGwxiQv31gPZ XBxCArMYJV5u+gHl/GSUONg4gRGkik1AR2LLdwhbREBAYv2LS+wgRcwC5xglHt5pA0sIC4RI rN28AWwsi4CqRPux1SwgNq+Aq8Sf05NYINbJSZw8Npm1i5GDgxMofumdMogpJOAicXw7zwRG 3gWMDKsYJVILkguKk9JzjfJSy/WKE3OLS/PS9ZLzczcxggPrmfQOxsO73A8xCnAwKvHwLlhi HibEmlhWXJl7iFGCg1lJhHf3XIswId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rz6nkZhQgLpiSWp 2ampBalFMFkmDk6pBkau93dX35h+4Fvl+R8CUysXHloQ/2S2v8qUbVd5UyY68bc8dzt5cKmu gQVb3RvlssoXHdoaPH0Ou35eXNP771tYgZWo4dkD6tNy7ha68RlfXm323Kgw9m71OrZn10z6 DO/e+qi1q219VGBptfrqQs6t+pfPR01ZyLno1crl8+qKA3dvSZ7XZuuuxFKckWioxVxUnAgA shhuYCgCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2172 Lines: 63 Introduce function returning id of interface at given index in function. The id value is equal bInterfaceNumber field in interface descriptor. This value can be useful during preparation of class or vendor specific descriptors in prep_vendor_descs() callback. It can be also necessary to handle some class or vendor specific setup requests. Signed-off-by: Robert Baldyga --- drivers/usb/gadget/composite.c | 19 +++++++++++++++++++ include/linux/usb/composite.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 0e264c5..9db8924 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -671,6 +671,25 @@ static int usb_interface_id_to_index(struct usb_function *f, u8 id) } /** + * usb_get_interface_id - get id number of interface at given index in + * USB function + * @f: USB function + * @i: index of interface in function + * + * Returns interface id on success, else negative errno. + */ +int usb_get_interface_id(struct usb_function *f, int i) +{ + if (!f->descs) + return -ENODEV; + if (f->descs->intfs_num <= i) + return -ENODEV; + + return f->descs->intfs[i]->id; +} +EXPORT_SYMBOL_GPL(usb_get_interface_id); + +/** * usb_function_get_ep - obtains endpoint of given index from active * altsetting of given interface * @f: USB function diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index e12921c..b6f5447 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); +int usb_get_interface_id(struct usb_function *f, int i); + 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 *); -- 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/