Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755276AbbLKL02 (ORCPT ); Fri, 11 Dec 2015 06:26:28 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:38275 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755262AbbLKL0Z (ORCPT ); Fri, 11 Dec 2015 06:26:25 -0500 X-AuditID: cbfee61a-f79266d000003652-f8-566ab2dfa1bb 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 18/36] usb: gadget: composite: enable adding USB functions using new API Date: Fri, 11 Dec 2015 12:24:57 +0100 Message-id: <1449833115-24065-19-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+t9jQd37m7LCDPZfVbWY9bKdxWLjjPWs Fgfv11s0L17PZnF51xw2i0XLWpkt1h65y27x4PBOdgcOj/1z17B79G1Zxehx/MZ2Jo/Pm+QC WKK4bFJSczLLUov07RK4MqY8+sBW0CFSceVAE3sD41yBLkZODgkBE4n1/V/ZIGwxiQv31gPZ XBxCArMYJS7/WMAK4fxklJiw/gwjSBWbgI7Elu8TwGwRAQGJ9S8usYMUMQucY5R4eKcNLCEs ECux/ct8VhCbRUBVYuPsO2A2r4CbROvavawQ6+QkTh6bDGZzAsUnn7zEDGILCbhKvHm9jnEC I+8CRoZVjBKpBckFxUnpuYZ5qeV6xYm5xaV56XrJ+bmbGMHB9UxqB+PBXe6HGAU4GJV4eBdw ZIUJsSaWFVfmHmKU4GBWEuH9tQEoxJuSWFmVWpQfX1Sak1p8iFGag0VJnLf2UmSYkEB6Yklq dmpqQWoRTJaJg1OqgTFe/9tCBp/Lz/lvzmFo530x3fnSBZfiB3mhdz2WZMS7V398xtqnft1e YN5in0X3VCUi55odfDV15t1XC7KFI68LH5Ko2ZjJcaj/aVCp4/r5Tb6W0mc98yrXpoaI7D7X EKZWf2vlpp9CGtLLrR4eVIq+v+F5dfLpSSwnuqqcn5oovSkNqeEunavEUpyRaKjFXFScCACP lQq3KgIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2716 Lines: 102 Enable adding USB functions which use new API. Check if all necessary function ops are supplied and call prep_descs() to allow function register it's entity descriptors. Notice that bind() function is not called for USB functions using new API, as now bind procedure is handled for them in composite framework. Signed-off-by: Robert Baldyga --- drivers/usb/gadget/composite.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 261023b..bdd7a2c 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -181,6 +181,8 @@ ep_found: } EXPORT_SYMBOL_GPL(config_ep_by_speed); +static inline bool usb_function_is_new_api(struct usb_function *f); + /** * usb_add_function() - add a function to a configuration * @config: the configuration @@ -198,15 +200,12 @@ EXPORT_SYMBOL_GPL(config_ep_by_speed); int usb_add_function(struct usb_configuration *config, struct usb_function *function) { - int value = -EINVAL; + int value; DBG(config->cdev, "adding '%s'/%p to config '%s'/%p\n", function->name, function, config->label, config); - if (!function->set_alt || !function->disable) - goto done; - function->config = config; list_add_tail(&function->list, &config->functions); @@ -216,13 +215,22 @@ int usb_add_function(struct usb_configuration *config, goto done; } + value = -EINVAL; + + if (!function->set_alt) + goto done; + + if (usb_function_is_new_api(function)) + goto new_api; + + if (!function->disable) + goto done; + /* REVISIT *require* function->bind? */ if (function->bind) { value = function->bind(config, function); - if (value < 0) { - list_del(&function->list); - function->config = NULL; - } + if (value < 0) + goto done; } else value = 0; @@ -238,10 +246,24 @@ int usb_add_function(struct usb_configuration *config, if (!config->superspeed && function->ss_descriptors) config->superspeed = true; + goto done; + +new_api: + if (!function->prep_descs) + goto done; + + if (!function->clear_alt) + goto done; + + value = function->prep_descs(function); + done: - if (value) + if (value) { + list_del(&function->list); + function->config = NULL; DBG(config->cdev, "adding '%s'/%p --> %d\n", function->name, function, value); + } return value; } EXPORT_SYMBOL_GPL(usb_add_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/