Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1289483
| From | Robert Baldyga <r.baldyga@samsung.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v3 12/36] usb: gadget: composite: disable eps before calling disable() callback |
| Date | 2015-12-11 12:40 +0100 |
| Message-ID | <qEudl-3DB-43@gated-at.bofh.it> (permalink) |
| References | <qEu3E-3z9-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Changes meaning of disable() operation for functions using new API.
Before calling disable() callback composite automatically disables
endpoints of active altsettings of given USB function. This reduces
amount of boilerplate code in USB functions.
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
drivers/usb/gadget/composite.c | 51 ++++++++++++++++++++++++++++++++++++------
1 file changed, 44 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index fdd0cbe..3695b75 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -246,12 +246,12 @@ done:
}
EXPORT_SYMBOL_GPL(usb_add_function);
+static void disable_function(struct usb_function *f);
+
void usb_remove_function(struct usb_configuration *c, struct usb_function *f)
{
- if (f->disable)
- f->disable(f);
+ disable_function(f);
- bitmap_zero(f->endpoints, 32);
list_del(&f->list);
if (f->unbind)
f->unbind(c, f);
@@ -946,6 +946,46 @@ static void device_qual(struct usb_composite_dev *cdev)
/*-------------------------------------------------------------------------*/
+/**
+ * disable_interface - disable all endpoints in given interface
+ * @f: USB function
+ * @i: interface index in function
+ */
+static void disable_interface(struct usb_function *f, unsigned i)
+{
+ struct usb_composite_intf *intf;
+ struct usb_composite_altset *alt;
+ int e;
+
+ intf = f->descs->intfs[i];
+ if (intf->cur_altset < 0)
+ return;
+
+ alt = intf->altsets[intf->cur_altset];
+ for (e = 0; e < alt->eps_num; ++e)
+ usb_ep_disable(alt->eps[e]->ep);
+
+ intf->cur_altset = -1;
+}
+
+/**
+ * disable_function - disable all endpoints in given function
+ * @f: USB function
+ */
+static void disable_function(struct usb_function *f)
+{
+ int i;
+
+ 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);
+
+ bitmap_zero(f->endpoints, 32);
+}
+
static void reset_config(struct usb_composite_dev *cdev)
{
struct usb_function *f;
@@ -953,10 +993,7 @@ static void reset_config(struct usb_composite_dev *cdev)
DBG(cdev, "reset config\n");
list_for_each_entry(f, &cdev->config->functions, list) {
- if (f->disable)
- f->disable(f);
-
- bitmap_zero(f->endpoints, 32);
+ disable_function(f);
}
cdev->config = NULL;
cdev->delayed_status = 0;
--
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/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v3 00/36] usb: gadget: composite: introduce new function API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 06/36] usb: gadget: composite: introduce new descriptors format Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 23/36] usb: gadget: f_rndis: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 26/36] usb: gadget: f_acm: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 34/36] usb: gadget: f_uac1: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 18/36] usb: gadget: composite: enable adding USB functions using new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 04/36] usb: gadget: f_loopback: free requests in loopback_disable() Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 25/36] usb: gadget: f_hid: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 07/36] usb: gadget: composite: add functions for descriptors handling Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 35/36] usb: gadget: f_uac2: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 01/36] Documentation: usb: update usb-tools repository address Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
Re: [PATCH v3 01/36] Documentation: usb: update usb-tools repository address Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-12-11 13:40 +0100
[PATCH v3 33/36] usb: gadget: f_subset: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 21/36] usb: gadget: f_sourcesink: convert to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 19/36] usb: gadget: configfs: add new composite API support Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 10/36] usb: gadget: composite: handle vendor descs Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 14/36] usb: gadget: composite: introduce clear_alt() operation Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 32/36] usb: gadget: f_phonet: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 28/36] usb: gadget: f_ncm: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 36/36] usb: gadget: f_mass_storage: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:30 +0100
[PATCH v3 20/36] usb: gadget: f_loopback: convert to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 09/36] usb: gadget: composite: handle function bind Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 22/36] usb: gadget: f_ecm: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 24/36] usb: gadget: f_hid: handle requests lifetime properly Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 30/36] usb: gadget: f_serial: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 15/36] usb: gadget: composite: handle get_alt() automatically Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 17/36] usb: gadget: composite: add usb_get_interface_id() function Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 13/36] usb: gadget: composite: enable eps before calling set_alt() callback Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 27/36] usb: gadget: f_eem: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 11/36] usb: gadget: composite: generate old descs for compatibility Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 12/36] usb: gadget: composite: disable eps before calling disable() callback Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 31/36] usb: gadget: f_obex: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 29/36] usb: gadget: f_printer: conversion to new API Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 05/36] usb: gadget: configfs: fix error path Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 08/36] usb: gadget: composite: introduce new USB function ops Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:40 +0100
[PATCH v3 03/36] usb: gadget: f_sourcesink: free requests in sourcesink_disable() Robert Baldyga <r.baldyga@samsung.com> - 2015-12-11 12:50 +0100
csiph-web