[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <1446555242-3733-15-git-send-email-r.baldyga@samsung.com>
Date: Tue, 03 Nov 2015 13:53:53 +0100
From: Robert Baldyga <r.baldyga@...sung.com>
To: balbi@...com
Cc: gregkh@...uxfoundation.org, andrzej.p@...sung.com,
m.szyprowski@...sung.com, b.zolnierkie@...sung.com,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
Robert Baldyga <r.baldyga@...sung.com>
Subject: [PATCH 14/23] usb: gadget: composite: introduce clear_alt() operation
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 <r.baldyga@...sung.com>
---
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists