Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932212AbbKCM6T (ORCPT ); Tue, 3 Nov 2015 07:58:19 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:60984 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754061AbbKCMy7 (ORCPT ); Tue, 3 Nov 2015 07:54:59 -0500 X-AuditID: cbfee61a-f79a06d000005c6f-cc-5638aea16395 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 14/23] usb: gadget: composite: introduce clear_alt() operation Date: Tue, 03 Nov 2015 13:53:53 +0100 Message-id: <1446555242-3733-15-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+NgFprCLMWRmVeSWpSXmKPExsVy+t9jQd2F6yzCDF516VrMetnOYrFxxnpW i4P36y2aF69ns7i8aw6bxaJlrcwWa4/cZbd4cHgnuwOHx/65a9g9+rasYvQ4fmM7k8fnTXIB LFFcNimpOZllqUX6dglcGa97lrEWLBGp+NYyi6mB8ZhAFyMnh4SAicTRC48ZIWwxiQv31rN1 MXJxCAnMYpTYPPMOI4Tzk1FiQVMPG0gVm4COxJbvE8A6RAQEJNa/uMQOUsQscI5R4uGdNrCE sICfxO1Z11lBbBYBVYl5vz+xdDFycPAKuEp8WVkAsU1O4uSxyawgYU6g8KV3yiCmkICLxPHt PBMYeRcwMqxilEgtSC4oTkrPNcxLLdcrTswtLs1L10vOz93ECA6rZ1I7GA/ucj/EKMDBqMTD u2CJeZgQa2JZcWXuIUYJDmYlEd7dcy3ChHhTEiurUovy44tKc1KLDzFKc7AoifPqexqFCQmk J5akZqemFqQWwWSZODilGhhb7DOfrC0W+PuAw+G+5+tL0U5zsll2Xyx/wvRn0/Ot/jHxHp9S uJV28X35vf5w+PPypqzNbMf12Nn+7n36jOHvodp+xeSU99cPixlN/6bpkZXx3ymTb2ZCyQv1 22qqgRtvLI8X6t0l5NDhW1MlalESpSzq/mBP1r5rxfKF8RquB9elfdTdkKXEUpyRaKjFXFSc CADjSESAJwIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2768 Lines: 78 Introduce clear_alt() callback, which is called when prevoiusly set altsetting is cleared. This can take place in two situations: - when another altsetting is selected, - during function disable. Thanks to symetry to set_alt(), clear_alt() simplifies managing of resources allocated in set_alt(). It also takes over the function of disable() opetarion, so it can be removed after converting all USB functions to new API. Signed-off-by: Robert Baldyga --- drivers/usb/gadget/composite.c | 12 ++++++++---- include/linux/usb/composite.h | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 439beca..5ce95d2 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -982,6 +982,9 @@ static void disable_interface(struct usb_function *f, unsigned i) for (e = 0; e < alt->eps_num; ++e) usb_ep_disable(alt->eps[e]->ep); + if (f->clear_alt) + f->clear_alt(f, i, intf->cur_altset); + intf->cur_altset = -1; } @@ -993,12 +996,13 @@ static void disable_function(struct usb_function *f) { int i; - if (usb_function_is_new_api(f)) + if (usb_function_is_new_api(f)) { for (i = 0; i < f->descs->intfs_num; ++i) disable_interface(f, i); - - if (f->disable) - f->disable(f); + } else { + if (f->disable) + f->disable(f); + } bitmap_zero(f->endpoints, 32); } diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 7cef8c0..3838eb6 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -301,6 +301,8 @@ struct usb_os_desc_table { * initialize usb_ep.driver data at this time (when it is used). * Note that setting an interface to its current altsetting resets * interface state, and that all interfaces have a disabled state. + * @clear_alt: (REQUIRED) Clears altsetting, frees all ep requiests and other + * resources allocated by set_alt. * @get_alt: Returns the active altsetting. If this is not provided, * then only altsetting zero is supported. * @disable: (REQUIRED) Indicates the function should be disabled. Reasons @@ -373,6 +375,8 @@ struct usb_function { /* runtime state management */ int (*set_alt)(struct usb_function *, unsigned interface, unsigned alt); + void (*clear_alt)(struct usb_function *, + unsigned interface, unsigned alt); int (*get_alt)(struct usb_function *, unsigned interface); void (*disable)(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/