lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 03 Feb 2016 13:39:27 +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 v4 19/43] usb: gadget: composite: enable adding USB functions
 using new API

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 <r.baldyga@...sung.com>
---
 drivers/usb/gadget/composite.c | 49 ++++++++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 417e2f9..0afb54c 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,33 @@ int usb_add_function(struct usb_configuration *config,
 	if (!config->superspeed && function->ss_descriptors)
 		config->superspeed = true;
 
-done:
+	goto done;
+
+new_api:
+	if (!function->prep_descs)
+		goto done;
+
+	if (!function->clear_alt)
+		goto done;
+
+	value = function->prep_descs(function);
 	if (value)
+		goto done;
+
+	if (!config->fullspeed && function->descs->fullspeed)
+		config->fullspeed = true;
+	if (!config->highspeed && function->descs->highspeed)
+		config->highspeed = true;
+	if (!config->superspeed && function->descs->superspeed)
+		config->superspeed = true;
+
+done:
+	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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ