Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755232AbbLKL0R (ORCPT ); Fri, 11 Dec 2015 06:26:17 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:57037 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755145AbbLKL0N (ORCPT ); Fri, 11 Dec 2015 06:26:13 -0500 X-AuditID: cbfee61b-f793c6d00000236c-af-566ab2d3060b 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 14/36] usb: gadget: composite: introduce clear_alt() operation Date: Fri, 11 Dec 2015 12:24:53 +0100 Message-id: <1449833115-24065-15-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+t9jQd3Lm7LCDC7917KY9bKdxWLjjPWs Fgfv11s0L17PZnF51xw2i0XLWpkt1h65y27x4PBOdgcOj/1z17B79G1Zxehx/MZ2Jo/Pm+QC WKK4bFJSczLLUov07RK4Mt4ve8ZasESkYuvuP+wNjMcEuhg5OSQETCSO3LzACGGLSVy4t56t i5GLQ0hgFqPE6t8r2SGcn4wSbbemg1WxCehIbPk+AcwWERCQWP/iElgRs8A5RomHd9rAEsIC wRJb709jA7FZBFQlOnY8ZwexeQXcJLpvvWKHWCcncfLYZFYQmxMoPvnkJWYQW0jAVeLN63WM Exh5FzAyrGKUSC1ILihOSs81ykst1ytOzC0uzUvXS87P3cQIDq5n0jsYD+9yP8QowMGoxMO7 gCMrTIg1say4MvcQowQHs5II768NQCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8+y5FhgkJpCeW pGanphakFsFkmTg4pRoYQ2ZYlTZcyA9weOKw6LmLiotJ67vnfxfPvPm60GrWhRzZ/VoXltU0 syj65+frea6u3mb5f/OV9t1it3nvWa1iVuk8dv3Z1+1+xXd0k+9yOJjmOjnIdE6yfMg4l89W tniCpMnJqN3iG1eGveHLlU/87VFgmjPL6vCxdcXLs74uufEihddMNF5eiaU4I9FQi7moOBEA u0J3sCoCAAA= 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 34721ef..48af787 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -985,6 +985,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; } @@ -996,12 +999,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/