Re: [V2 PATCH 04/10] added media agnostic (MA) USB packet handling

2014-11-12 Thread Oliver Neukum
On Mon, 2014-11-10 at 18:09 -0800, Stephanie Wallick wrote:
 +/**
 + * Compares 2 request IDs. Returns true if a is less than b. Handles
 request id
 + * wraparound.
 + */
 +bool mausb_req_id_lt(u8 a, u8 b)

Unify such functions. It's just silly to have so many of them.

 +/**
 + * Calculates the total length of data contained in an ms_pkt (in
 bytes).
 + * Returns the length of the kvec, or 0 on an error.
 + */
 +static int mausb_ms_data_length(struct ms_pkt *pkt)
 +{
 +   int i;
 +   int total_length;
 +   struct kvec *current_kvec;
 +
 +   for (i = 0; i  pkt-nents; ++i) {
 +   current_kvec = pkt-kvec[i];
 +   if (NULL == current_kvec)
 +   return -EINVAL;
 +   else
 +   total_length += current_kvec-iov_len;
 +   }
 +
 +   return total_length;
 +}
 +

Regards
Oliver

-- 
Oliver Neukum oneu...@suse.de

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[V2 PATCH 04/10] added media agnostic (MA) USB packet handling

2014-11-10 Thread Stephanie Wallick
This is where we handle MA USB packets. The structure and types of MA USB
packets are defined in the MA USB specification. When an MA USB driver
receives a USB packet, it translates it into a MA USB packet (or packets
if urb exceeds maximum USB packet size). When an MA USB packet is received,
the data from that packet is given to the waiting USB packet and the USB
packet is released.

Signed-off-by: Sean O. Stalley sean.stal...@intel.com
Signed-off-by: Stephanie Wallick stephanie.s.wall...@intel.com
---
 drivers/staging/mausb/drivers/mausb_pkt.c | 1038 +
 drivers/staging/mausb/drivers/mausb_pkt.h |  914 +
 2 files changed, 1952 insertions(+)
 create mode 100644 drivers/staging/mausb/drivers/mausb_pkt.c
 create mode 100644 drivers/staging/mausb/drivers/mausb_pkt.h

diff --git a/drivers/staging/mausb/drivers/mausb_pkt.c 
b/drivers/staging/mausb/drivers/mausb_pkt.c
new file mode 100644
index 000..c78cfc2
--- /dev/null
+++ b/drivers/staging/mausb/drivers/mausb_pkt.c
@@ -0,0 +1,1038 @@
+/* name:   mausb_pkt.c
+ * description: MA USB packet helper functions
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * Contact Information:
+ * Sean Stalley, sean.stal...@intel.com
+ * Stephanie Wallick, stephanie.s.wall...@intel.com
+ * 2111 NE 25th Avenue
+ * Hillsboro, Oregon 97124
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+* Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+  notice, this list of conditions and the following disclaimer in
+  the documentation and/or other materials provided with the
+  distribution.
+* Neither the name of Intel Corporation nor the names of its
+  contributors may be used to endorse or promote products derived
+  from this software without specific prior written permission.
+
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include linux/slab.h
+#include linux/usb/ch9.h
+#include linux/usb.h
+
+#include mausb_mem.h
+#include mausb_pkt.h
+#include mausb_const.h
+
+/**
+ * Translates numerical packet type into corresponding string (for printing).
+ */
+const char *mausb_type_to_string(enum mausb_pkt_type type)
+{
+   switch (type) {
+   case CapReq:
+   return CapReq;
+   case CapResp:
+   return CapResp;
+   case USBDevHandleReq:
+   return USBDevHandleReq;
+   case USBDevHandleResp:
+   return USBDevHandleResp;
+   case EPHandleReq:
+   return EPHandleReq;
+   case EPHandleResp:
+   return EPHandleResp;
+   case EPActivateReq:
+   return EPActivateReq;
+   case EPActivateResp:
+   return EPActivateResp;
+   case EPInactivateReq:
+   return EPInactivateReq;
+   case EPInactivateResp:
+   return EPInactivateResp;
+   case EPResetReq:
+   return EPResetReq;
+   case EPResetResp:
+   return EPResetResp;
+   case EPClearTransferReq:
+   return EPClearTransferReq;
+   case EPClearTransferResp:
+   return EPClearTransferResp;
+   case EPHandleDeleteReq:
+   return EPHandleDeleteReq;
+   case EPHandleDeleteResp:
+   return EPHandleDeleteResp;
+   case 

[PATCH 04/10] added media agnostic (MA) USB packet handling

2014-11-03 Thread Stephanie Wallick
This is where we handle MA USB packets. The structure and types of MA USB
packets are defined in the MA USB specification. When an MA USB driver
receives a USB packet, it translates it into a MA USB packet (or packets
if urb exceeds maximum USB packet size). When an MA USB packet is received,
the data from that packet is given to the waiting USB packet and the USB
packet is released.

Signed-off-by: Sean O. Stalley sean.stal...@intel.com
Signed-off-by: Stephanie Wallick stephanie.s.wall...@intel.com
---
 drivers/staging/mausb/drivers/mausb_pkt.c | 1038 +
 drivers/staging/mausb/drivers/mausb_pkt.h |  914 +
 2 files changed, 1952 insertions(+)
 create mode 100644 drivers/staging/mausb/drivers/mausb_pkt.c
 create mode 100644 drivers/staging/mausb/drivers/mausb_pkt.h

diff --git a/drivers/staging/mausb/drivers/mausb_pkt.c 
b/drivers/staging/mausb/drivers/mausb_pkt.c
new file mode 100644
index 000..c78cfc2
--- /dev/null
+++ b/drivers/staging/mausb/drivers/mausb_pkt.c
@@ -0,0 +1,1038 @@
+/* name:   mausb_pkt.c
+ * description: MA USB packet helper functions
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * Contact Information:
+ * Sean Stalley, sean.stal...@intel.com
+ * Stephanie Wallick, stephanie.s.wall...@intel.com
+ * 2111 NE 25th Avenue
+ * Hillsboro, Oregon 97124
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2014 Intel Corporation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+* Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+  notice, this list of conditions and the following disclaimer in
+  the documentation and/or other materials provided with the
+  distribution.
+* Neither the name of Intel Corporation nor the names of its
+  contributors may be used to endorse or promote products derived
+  from this software without specific prior written permission.
+
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include linux/slab.h
+#include linux/usb/ch9.h
+#include linux/usb.h
+
+#include mausb_mem.h
+#include mausb_pkt.h
+#include mausb_const.h
+
+/**
+ * Translates numerical packet type into corresponding string (for printing).
+ */
+const char *mausb_type_to_string(enum mausb_pkt_type type)
+{
+   switch (type) {
+   case CapReq:
+   return CapReq;
+   case CapResp:
+   return CapResp;
+   case USBDevHandleReq:
+   return USBDevHandleReq;
+   case USBDevHandleResp:
+   return USBDevHandleResp;
+   case EPHandleReq:
+   return EPHandleReq;
+   case EPHandleResp:
+   return EPHandleResp;
+   case EPActivateReq:
+   return EPActivateReq;
+   case EPActivateResp:
+   return EPActivateResp;
+   case EPInactivateReq:
+   return EPInactivateReq;
+   case EPInactivateResp:
+   return EPInactivateResp;
+   case EPResetReq:
+   return EPResetReq;
+   case EPResetResp:
+   return EPResetResp;
+   case EPClearTransferReq:
+   return EPClearTransferReq;
+   case EPClearTransferResp:
+   return EPClearTransferResp;
+   case EPHandleDeleteReq:
+   return EPHandleDeleteReq;
+   case EPHandleDeleteResp:
+   return EPHandleDeleteResp;
+   case