Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755416AbbLKLeh (ORCPT ); Fri, 11 Dec 2015 06:34:37 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:42144 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752720AbbLKL0V (ORCPT ); Fri, 11 Dec 2015 06:26:21 -0500 X-AuditID: cbfee61a-f79266d000003652-f5-566ab2dc71db 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 v3 17/36] usb: gadget: composite: add usb_get_interface_id() function Date: Fri, 11 Dec 2015 12:24:56 +0100 Message-id: <1449833115-24065-18-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1449833115-24065-1-git-send-email-r.baldyga@samsung.com> References: <1449833115-24065-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOLMWRmVeSWpSXmKPExsVy+t9jQd07m7LCDGa90LSY9bKdxWLjjPWs Fgfv11s0L17PZnF51xw2i0XLWpkt1h65y27x4PBOdgcOj/1z17B79G1Zxehx/MZ2Jo/Pm+QC WKK4bFJSczLLUov07RK4Mr7dO8dUcJC/YurH94wNjD95uhg5OSQETCQ6z7xkhbDFJC7cW8/W xcjFISQwi1Hi4Kr1zBDOT0aJ7QtbmECq2AR0JLZ8n8AIYosICEisf3GJHaSIWeAco8TDO21g CWGBcIkTi6ezgdgsAqoSu3cfALN5BdwkOtY3sECsk5M4eWwy2GpOoPjkk5eYQWwhAVeJN6/X MU5g5F3AyLCKUSK1ILmgOCk91zAvtVyvODG3uDQvXS85P3cTIzi4nkntYDy4y/0QowAHoxIP 7wKOrDAh1sSy4srcQ4wSHMxKIry/NgCFeFMSK6tSi/Lji0pzUosPMUpzsCiJ89ZeigwTEkhP LEnNTk0tSC2CyTJxcEo1MO5ccKr1K5fta+Wof7fm/lt56eQ/oX1H1ywsMLH6HbVfLVBs4YPK /KufH5lkm7QufLspsEB411HtHz98brEezPV6ssN2+STDEwY3woKMrDX8mCUuf1/S8VGv4VWy vsHnd2FJBzmruuQtdVpcJtxP3LnxWw2rRinjYW2tkHUZZzysI+p31HLpMyqxFGckGmoxFxUn AgAfuMUKKgIAAA== 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 d7e7d0b..261023b 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -674,6 +674,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/