linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/12] SEP cleanups
@ 2010-11-24 19:23 Alan Cox
  2010-11-24 19:33 ` [PATCH 01/12] sep: minimal fix for wrong include Alan Cox
                   ` (12 more replies)
  0 siblings, 13 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 19:23 UTC (permalink / raw)
  To: greg, mark.a.allyn, linux-kernel

This is a rework from the bits I sent you a while back Mark (which I suspect
got eaten in the email) and some other cleanup. I've not beaten it up with
CodingStyle yet because most of the debug wants removing before that is done
so it is probably more productive to fix the logic and the inherited choice of
TRUELY_GIANT_DEFINE_NAMES_THAT_CAUSE_MUCH_WRAPPING before we worry about finer
points of style.

---

Alan Cox (12):
      sep: Fix crash if a device is not found
      sep: clean up a couple of spots missed in pass one
      sep: cant is an angular inclination
      sep: Make SEP consistent
      sep: Use kzalloc when needed
      sep: clean up some of the obvious sillies
      sep: Fix the kernel-doc in SEP
      sep: clean up caller_id function
      sep: netlink - what netlink
      sep: handle the memrar stuff in the headers
      sep: handle the rar definition stuff in the header
      sep: minimal fix for wrong include


 drivers/staging/memrar/memrar.h         |   19 
 drivers/staging/sep/sep_driver.c        | 2230 ++++++++++++-------------------
 drivers/staging/sep/sep_driver_config.h |  194 ---
 include/linux/rar_register.h            |   16 
 4 files changed, 902 insertions(+), 1557 deletions(-)

-- 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 01/12] sep: minimal fix for wrong include
  2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
@ 2010-11-24 19:33 ` Alan Cox
  2010-11-24 19:33 ` [PATCH 02/12] sep: handle the rar definition stuff in the header Alan Cox
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 19:33 UTC (permalink / raw)
  To: greg, mark.a.allyn, linux-kernel

From: Alan Cox <alan@linux.intel.com>

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/staging/sep/sep_driver_config.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/drivers/staging/sep/sep_driver_config.h b/drivers/staging/sep/sep_driver_config.h
index 686a353..68688cb 100644
--- a/drivers/staging/sep/sep_driver_config.h
+++ b/drivers/staging/sep/sep_driver_config.h
@@ -421,7 +421,7 @@ struct RAR_buffer {
 
 #else /* using real RAR_REGISTER */
 
-#include "../rar_register/rar_register.h"
+#include <linux/rar_register.h>
 
 #endif  /* CONFIG_RAR_REGISTER */
 


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 02/12] sep: handle the rar definition stuff in the header
  2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
  2010-11-24 19:33 ` [PATCH 01/12] sep: minimal fix for wrong include Alan Cox
@ 2010-11-24 19:33 ` Alan Cox
  2010-11-24 19:33 ` [PATCH 03/12] sep: handle the memrar stuff in the headers Alan Cox
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 19:33 UTC (permalink / raw)
  To: greg, mark.a.allyn, linux-kernel

From: Alan Cox <alan@linux.intel.com>

SEP isn't the only driver that may need to handle both cases easily

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/staging/sep/sep_driver.c        |    1 +
 drivers/staging/sep/sep_driver_config.h |   61 -------------------------------
 include/linux/rar_register.h            |   16 ++++++++
 3 files changed, 17 insertions(+), 61 deletions(-)


diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index ef36239..8a1ff86 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -53,6 +53,7 @@
 #include <asm/cacheflush.h>
 #include <linux/sched.h>
 #include <linux/delay.h>
+#include <linux/rar_register.h>
 
 #include <linux/netlink.h>
 #include <linux/connector.h>
diff --git a/drivers/staging/sep/sep_driver_config.h b/drivers/staging/sep/sep_driver_config.h
index 68688cb..cfda86f 100644
--- a/drivers/staging/sep/sep_driver_config.h
+++ b/drivers/staging/sep/sep_driver_config.h
@@ -236,15 +236,6 @@ held by the proccess (struct file) */
 /* This stub header is for non Moorestown driver only */
 
 /*
- * Constants that specify different kinds of RAR regions that could be
- * set up.
- */
-static __u32 const RAR_TYPE_VIDEO;  /* 0 */
-static __u32 const RAR_TYPE_AUDIO = 1;
-static __u32 const RAR_TYPE_IMAGE = 2;
-static __u32 const RAR_TYPE_DATA  = 3;
-
-/*
  * @struct RAR_stat
  *
  * @brief This structure is used for @c RAR_HANDLER_STAT ioctl and for
@@ -373,56 +364,4 @@ struct RAR_buffer {
 
 #endif  /* MEMRAR */
 
-/* rar_register */
-#ifndef CONFIG_RAR_REGISTER
-/* This stub header is for non Moorestown driver only */
-
-/* The register_rar function is to used by other device drivers
- * to ensure that this driver is ready. As we cannot be sure of
- * the compile/execute order of dirvers in ther kernel, it is
- * best to give this driver a callback function to call when
- * it is ready to give out addresses. The callback function
- * would have those steps that continue the initialization of
- * a driver that do require a valid RAR address. One of those
- * steps would be to call get_rar_address()
- * This function return 0 on success an -1 on failure.
- */
-#define register_rar(a, b, c) (-ENODEV)
-
-/* The get_rar_address function is used by other device drivers
- * to obtain RAR address information on a RAR. It takes two
- * parameter:
- *
- * int rar_index
- * The rar_index is an index to the rar for which you wish to retrieve
- * the address information.
- * Values can be 0,1, or 2.
- *
- * struct RAR_address_struct is a pointer to a place to which the function
- * can return the address structure for the RAR.
- *
- * The function returns a 0 upon success or a -1 if there is no RAR
- * facility on this system.
- */
-#define rar_get_address(a, b, c) (-ENODEV)
-
-/* The lock_rar function is ued by other device drivers to lock an RAR.
- * once an RAR is locked, it stays locked until the next system reboot.
- * The function takes one parameter:
- *
- * int rar_index
- * The rar_index is an index to the rar that you want to lock.
- * Values can be 0,1, or 2.
- *
- * The function returns a 0 upon success or a -1 if there is no RAR
- * facility on this system.
- */
-#define rar_lock(a) (-1)
-
-#else /* using real RAR_REGISTER */
-
-#include <linux/rar_register.h>
-
-#endif  /* CONFIG_RAR_REGISTER */
-
 #endif /* SEP DRIVER CONFIG */
diff --git a/include/linux/rar_register.h b/include/linux/rar_register.h
index ffa8057..5c61181 100644
--- a/include/linux/rar_register.h
+++ b/include/linux/rar_register.h
@@ -34,11 +34,27 @@
 
 struct rar_device;
 
+#if defined(CONFIG_RAR_REGISTER)
 int register_rar(int num,
 		int (*callback)(unsigned long data), unsigned long data);
 void unregister_rar(int num);
 int rar_get_address(int rar_index, dma_addr_t *start, dma_addr_t *end);
 int rar_lock(int rar_index);
+#else
+extern void unregister_rar(int num)  { }
+extern int rar_lock(int rar_index) { return -EIO; }
+
+extern inline int register_rar(int num,
+		int (*callback)(unsigned long data), unsigned long data)
+{
+	return -ENODEV;
+}
+
+extern int rar_get_address(int rar_index, dma_addr_t *start, dma_addr_t *end)
+{
+	return -ENODEV;
+}
+#endif	/* RAR_REGISTER */
 
 #endif  /* __KERNEL__ */
 #endif  /* _RAR_REGISTER_H */


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 03/12] sep: handle the memrar stuff in the headers
  2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
  2010-11-24 19:33 ` [PATCH 01/12] sep: minimal fix for wrong include Alan Cox
  2010-11-24 19:33 ` [PATCH 02/12] sep: handle the rar definition stuff in the header Alan Cox
@ 2010-11-24 19:33 ` Alan Cox
  2010-11-24 19:34 ` [PATCH 04/12] sep: netlink - what netlink Alan Cox
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 19:33 UTC (permalink / raw)
  To: greg, mark.a.allyn, linux-kernel

From: Alan Cox <alan@linux.intel.com>

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/staging/memrar/memrar.h         |   19 ++++
 drivers/staging/sep/sep_driver.c        |    2 
 drivers/staging/sep/sep_driver_config.h |  133 -------------------------------
 3 files changed, 21 insertions(+), 133 deletions(-)


diff --git a/drivers/staging/memrar/memrar.h b/drivers/staging/memrar/memrar.h
index 0b735b8..0feb73b 100644
--- a/drivers/staging/memrar/memrar.h
+++ b/drivers/staging/memrar/memrar.h
@@ -95,6 +95,7 @@ struct RAR_buffer {
 	dma_addr_t bus_address;
 };
 
+#if defined(CONFIG_MRST_RAR_HANDLER)
 /**
  * rar_reserve() - reserve RAR buffers
  * @buffers:	array of RAR_buffers where type and size of buffers to
@@ -149,7 +150,25 @@ extern size_t rar_release(struct RAR_buffer *buffers,
 extern size_t rar_handle_to_bus(struct RAR_buffer *buffers,
 				size_t count);
 
+#else
 
+extern inline size_t rar_reserve(struct RAR_buffer *buffers, size_t count)
+{
+	return 0;
+}
+
+extern inline size_t rar_release(struct RAR_buffer *buffers, size_t count)
+{
+	return 0;
+}
+
+extern inline size_t rar_handle_to_bus(struct RAR_buffer *buffers,
+				size_t count)
+{
+	return 0;
+}
+
+#endif  /* MRST_RAR_HANDLER */
 #endif  /* __KERNEL__ */
 
 #endif  /* _MEMRAR_H */
diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index 8a1ff86..b2cf553 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -59,6 +59,8 @@
 #include <linux/connector.h>
 #include <linux/cn_proc.h>
 
+#include "../memrar/memrar.h"
+
 #include "sep_driver_hw_defs.h"
 #include "sep_driver_config.h"
 #include "sep_driver_api.h"
diff --git a/drivers/staging/sep/sep_driver_config.h b/drivers/staging/sep/sep_driver_config.h
index cfda86f..b96045f 100644
--- a/drivers/staging/sep/sep_driver_config.h
+++ b/drivers/staging/sep/sep_driver_config.h
@@ -230,138 +230,5 @@ held by the proccess (struct file) */
 /* the token that defines the data pool pointers address */
 #define SEP_EXT_CACHE_ADDR_VAL_TOKEN                          0xBABABABA
 
-/* rar handler */
-#ifndef CONFIG_MRST_RAR_HANDLER
-
-/* This stub header is for non Moorestown driver only */
-
-/*
- * @struct RAR_stat
- *
- * @brief This structure is used for @c RAR_HANDLER_STAT ioctl and for
- *	@c RAR_get_stat() user space wrapper function.
- */
-struct RAR_stat {
-	/* Type of RAR memory (e.g., audio vs. video) */
-	__u32 type;
-
-	/*
-	* Total size of RAR memory region.
-	*/
-	__u32 capacity;
-
-	/* Size of the largest reservable block. */
-	__u32 largest_block_size;
-};
-
-
-/*
- * @struct RAR_block_info
- *
- * @brief The argument for the @c RAR_HANDLER_RESERVE @c ioctl.
- *
- */
-struct RAR_block_info {
-	/* Type of RAR memory (e.g., audio vs. video) */
-	__u32 type;
-
-	/* Requested size of a block to be reserved in RAR. */
-	__u32 size;
-
-	/* Handle that can be used to refer to reserved block. */
-	__u32 handle;
-};
-
-/*
- * @struct RAR_buffer
- *
- * Structure that contains all information related to a given block of
- * memory in RAR.  It is generally only used when retrieving bus
- * addresses.
- *
- * @note This structure is used only by RAR-enabled drivers, and is
- *	 not intended to be exposed to the user space.
- */
-struct RAR_buffer {
-	/* Structure containing base RAR buffer information */
-	struct RAR_block_info info;
-
-	/* Buffer bus address */
-	__u32 bus_address;
-};
-
-
-#define RAR_IOCTL_BASE 0xE0
-
-/* Reserve RAR block. */
-#define RAR_HANDLER_RESERVE _IOWR(RAR_IOCTL_BASE, 0x00, struct RAR_block_info)
-
-/* Release previously reserved RAR block. */
-#define RAR_HANDLER_RELEASE _IOW(RAR_IOCTL_BASE, 0x01, __u32)
-
-/* Get RAR stats. */
-#define RAR_HANDLER_STAT    _IOWR(RAR_IOCTL_BASE, 0x02, struct RAR_stat)
-
-
-/* -------------------------------------------------------------- */
-/*		 Kernel Side RAR Handler Interface		*/
-/* -------------------------------------------------------------- */
-
-/*
- * @function rar_reserve
- *
- * @brief Reserve RAR buffers.
- *
- * This function will reserve buffers in the restricted access regions
- * of given types.
- *
- * @return Number of successfully reserved buffers.
- *	 Successful buffer reservations will have the corresponding
- *	 @c bus_address field set to a non-zero value in the
- *	 given @a buffers vector.
- */
-#define rar_reserve(a, b) ((size_t)NULL)
-
-/*
- * @function rar_release
- *
- * @brief Release RAR buffers retrieved through call to
- *	@c rar_reserve() or @c rar_handle_to_bus().
- *
- * This function will release RAR buffers that were retrieved through
- * a call to @c rar_reserve() or @c rar_handle_to_bus() by
- * decrementing the reference count.  The RAR buffer will be reclaimed
- * when the reference count drops to zero.
- *
- * @return Number of successfully released buffers.
- *	 Successful releases will have their handle field set to
- *	 zero in the given @a buffers vector.
- */
-#define rar_release(a, b) ((size_t)NULL)
-
-/*
- * @function rar_handle_to_bus
- *
- * @brief Convert a vector of RAR handles to bus addresses.
- *
- * This function will retrieve the RAR buffer bus addresses, type and
- * size corresponding to the RAR handles provided in the @a buffers
- * vector.
- *
- * @return Number of successfully converted buffers.
- *	 The bus address will be set to @c 0 for unrecognized
- *	 handles.
- *
- * @note The reference count for each corresponding buffer in RAR will
- *	 be incremented.  Call @c rar_release() when done with the
- *	 buffers.
- */
-#define rar_handle_to_bus(a, b) ((size_t)NULL)
-
-#else /* using rear memrar */
-
-#include "../memrar/memrar.h"
-
-#endif  /* MEMRAR */
 
 #endif /* SEP DRIVER CONFIG */


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 04/12] sep: netlink - what netlink
  2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
                   ` (2 preceding siblings ...)
  2010-11-24 19:33 ` [PATCH 03/12] sep: handle the memrar stuff in the headers Alan Cox
@ 2010-11-24 19:34 ` Alan Cox
  2010-11-24 19:34 ` [PATCH 05/12] sep: clean up caller_id function Alan Cox
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 19:34 UTC (permalink / raw)
  To: greg, mark.a.allyn, linux-kernel

From: Alan Cox <alan@linux.intel.com>

Kill unused stuff

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/staging/sep/sep_driver.c |   24 +-----------------------
 1 files changed, 1 insertions(+), 23 deletions(-)


diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index b2cf553..38b2db4 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -55,10 +55,6 @@
 #include <linux/delay.h>
 #include <linux/rar_register.h>
 
-#include <linux/netlink.h>
-#include <linux/connector.h>
-#include <linux/cn_proc.h>
-
 #include "../memrar/memrar.h"
 
 #include "sep_driver_hw_defs.h"
@@ -943,23 +939,11 @@ static unsigned long sep_set_time(struct sep_device *sep)
  */
 static int sep_init_caller_id(struct sep_device *sep)
 {
-	/* return value */
-	int ret_val;
-
-	/* counter */
 	int counter;
 
-	struct cb_id caller_id;
-
 	dev_dbg(&sep->pdev->dev,
 		"sep_init_caller_id start\n");
 
-	ret_val = 0;
-
-	/* init cb_id struct */
-	caller_id.idx = CN_IDX_PROC;
-	caller_id.val = CN_VAL_PROC;
-
 	/**
 	 * init caller id table
 	 * note that locking is not needed here as this function is
@@ -975,16 +959,10 @@ static int sep_init_caller_id(struct sep_device *sep)
 	dev_dbg(&sep->pdev->dev,
 		"caller id table init finished\n");
 
-	/* register to netlink connector */
-
-	if (ret_val)
-		dev_warn(&sep->pdev->dev,
-			"cn_add_callback failed %x\n", ret_val);
-
 	dev_dbg(&sep->pdev->dev,
 		"sep_init_caller_id end\n");
 
-	return ret_val;
+	return 0;
 }
 
 /**


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 05/12] sep: clean up caller_id function
  2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
                   ` (3 preceding siblings ...)
  2010-11-24 19:34 ` [PATCH 04/12] sep: netlink - what netlink Alan Cox
@ 2010-11-24 19:34 ` Alan Cox
  2010-11-24 19:34 ` [PATCH 06/12] sep: Fix the kernel-doc in SEP Alan Cox
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 19:34 UTC (permalink / raw)
  To: greg, mark.a.allyn, linux-kernel

From: Alan Cox <alan@linux.intel.com>

This is called on a kmalloc/memset object. Remove everything that isn't a
set to zero

Oh look 8)

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/staging/sep/sep_driver.c |   42 --------------------------------------
 1 files changed, 0 insertions(+), 42 deletions(-)


diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index 38b2db4..c98cb9b 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -934,38 +934,6 @@ static unsigned long sep_set_time(struct sep_device *sep)
 }
 
 /**
- *	sep_init_caller_id - initializes the caller id functionality
- *	@sep: pointer to struct sep_device
- */
-static int sep_init_caller_id(struct sep_device *sep)
-{
-	int counter;
-
-	dev_dbg(&sep->pdev->dev,
-		"sep_init_caller_id start\n");
-
-	/**
-	 * init caller id table
-	 * note that locking is not needed here as this function is
-	 * called prior to registering the device file
-	 */
-	for (counter = 0; counter < SEP_CALLER_ID_TABLE_NUM_ENTRIES; counter++)
-		sep->caller_id_table[counter].pid = 0;
-
-
-	/* init access flag */
-	sep->singleton_access_flag = 0;
-
-	dev_dbg(&sep->pdev->dev,
-		"caller id table init finished\n");
-
-	dev_dbg(&sep->pdev->dev,
-		"sep_init_caller_id end\n");
-
-	return 0;
-}
-
-/**
  *	sep_set_caller_id_handler - inserts the data into the caller id table
  *      note that this function does fall under the ioctl lock
  *	@sep: sep device
@@ -4056,16 +4024,6 @@ static int __init sep_init(void)
 	mutex_init(&sep->sep_mutex);
 	mutex_init(&sep->ioctl_mutex);
 
-	if (sep->mrst == 0) {
-		ret_val = sep_init_caller_id(sep);
-		if (ret_val) {
-			dev_warn(&sep->pdev->dev,
-				"cant init caller id\n");
-			goto end_function_unregister_pci;
-		}
-
-	}
-
 	/* new chip requires share area reconfigure */
 	if (sep->pdev->revision == 4) { /* only for new chip */
 		ret_val = sep_reconfig_shared_area(sep);


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 06/12] sep: Fix the kernel-doc in SEP
  2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
                   ` (4 preceding siblings ...)
  2010-11-24 19:34 ` [PATCH 05/12] sep: clean up caller_id function Alan Cox
@ 2010-11-24 19:34 ` Alan Cox
  2010-11-24 19:38 ` [PATCH 07/12] sep: clean up some of the obvious sillies Alan Cox
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 19:34 UTC (permalink / raw)
  To: greg, mark.a.allyn, linux-kernel

From: Alan Cox <alan@linux.intel.com>

The long blurb goes at the end

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/staging/sep/sep_driver.c |  322 ++++++++++++++++++++++----------------
 1 files changed, 188 insertions(+), 134 deletions(-)


diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index c98cb9b..4a0bb43 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -78,9 +78,10 @@ static struct sep_device *sep_dev;
 
 /**
  *	sep_load_firmware - copy firmware cache/resident
+ *	@sep: pointer to struct sep_device we are loading
+ *
  *	This functions copies the cache and resident from their source
  *	location into destination shared memory.
- *	@sep: pointer to struct sep_device
  */
 
 static int sep_load_firmware(struct sep_device *sep)
@@ -228,10 +229,11 @@ static void sep_unmap_and_free_shared_area(struct sep_device *sep)
 
 /**
  *	sep_shared_bus_to_virt - convert bus/virt addresses
- *	Returns virtual address inside the shared area according
- *	to the bus address.
  *	@sep: pointer to struct sep_device
  *	@bus_address: address to convert
+ *
+ *	Returns virtual address inside the shared area according
+ *	to the bus address.
  */
 
 static void *sep_shared_bus_to_virt(struct sep_device *sep,
@@ -244,6 +246,8 @@ static void *sep_shared_bus_to_virt(struct sep_device *sep,
  *	open function for the singleton driver
  *	@inode_ptr struct inode *
  *	@file_ptr struct file *
+ *
+ *	Called when the user opens the singleton device interface
  */
 
 static int sep_singleton_open(struct inode *inode_ptr, struct file *file_ptr)
@@ -252,8 +256,8 @@ static int sep_singleton_open(struct inode *inode_ptr, struct file *file_ptr)
 
 	struct sep_device *sep;
 
-	/**
-	 * get the sep device structure and use it for the
+	/*
+	 * Get the sep device structure and use it for the
 	 * private_data field in filp for other methods
 	 */
 	sep = sep_dev;
@@ -282,8 +286,7 @@ end_function:
  *	@filp: file handle to sep device
  *
  *	Open method for the SEP device. Called when userspace opens
- *	the SEP device node. Must also release the memory data pool
- *	allocations.
+ *	the SEP device node. 
  *
  *	Returns zero on success otherwise an error code.
  */
@@ -292,8 +295,8 @@ static int sep_open(struct inode *inode, struct file *filp)
 {
 	struct sep_device *sep;
 
-	/**
-	 * get the sep device structure and use it for the
+	/*
+	 * Get the sep device structure and use it for the
 	 * private_data field in filp for other methods
 	 */
 	sep = sep_dev;
@@ -301,7 +304,7 @@ static int sep_open(struct inode *inode, struct file *filp)
 
 	dev_dbg(&sep->pdev->dev, "Open for pid %d\n", current->pid);
 
-	/* anyone can open; locking takes place at transaction level */
+	/* Anyone can open; locking takes place at transaction level */
 	return 0;
 }
 
@@ -333,8 +336,7 @@ static int sep_singleton_release(struct inode *inode, struct file *filp)
  *	@filp: file handle to sep device
  *
  *	Open method for the SEP request daemon. Called when
- *	request daemon in userspace opens
- *	the SEP device node.
+ *	request daemon in userspace opens the SEP device node.
  *
  *	Returns zero on success otherwise an error code.
  */
@@ -385,9 +387,11 @@ static int sep_request_daemon_release(struct inode *inode, struct file *filp)
 }
 
 /**
+ *	sep_req_daemon_send_reply_command_handler - poke the SEP
+ *	@sep: struct sep_device *
+ *
  *	This function raises interrupt to SEPm that signals that is has a
  *	new command from HOST
- *	@sep: struct sep_device *
  */
 static int sep_req_daemon_send_reply_command_handler(struct sep_device *sep)
 {
@@ -427,9 +431,10 @@ static int sep_req_daemon_send_reply_command_handler(struct sep_device *sep)
 
 
 /**
- *	sep_free_dma_table_data_handler - handles the request
- *	for freeing dma table for synhronic actions
+ *	sep_free_dma_table_data_handler - free DMA table
  *	@sep: pointere to struct sep_device
+ *
+ *	Handles the request to  free dma table for synchronic actions
  */
 
 static int sep_free_dma_table_data_handler(struct sep_device *sep)
@@ -531,10 +536,12 @@ static int sep_free_dma_table_data_handler(struct sep_device *sep)
 
 
 /**
- *	sep_request_daemon_mmap - maps the
- *	shared area to user space
+ *	sep_request_daemon_mmap - maps the shared area to user space
  *	@filp: pointer to struct file
  *	@vma: pointer to vm_area_struct
+ *
+ *	Called by the kernel when the daemon attempts an mmap() syscall
+ *	using our handle.
  */
 static int sep_request_daemon_mmap(struct file  *filp,
 	struct vm_area_struct  *vma)
@@ -577,10 +584,12 @@ end_function:
 }
 
 /**
- *	sep_request_daemon_poll -
+ *	sep_request_daemon_poll - poll implementation
  *	@sep: struct sep_device * for current sep device
  *	@filp: struct file * for open file
  *	@wait: poll_table * for poll
+ *
+ *	Called when our device is part of a poll() or select() syscall
  */
 static unsigned int sep_request_daemon_poll(struct file *filp,
 	poll_table  *wait)
@@ -689,6 +698,8 @@ static int sep_release(struct inode *inode, struct file *filp)
  *	sep_mmap -  maps the shared area to user space
  *	@filp: pointer to struct file
  *	@vma: pointer to vm_area_struct
+ *
+ *	Called on an mmap of our space via the normal sep device
  */
 static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
 {
@@ -776,9 +787,12 @@ end_function:
 }
 
 /**
- *	sep_poll -
+ *	sep_poll - poll handler
  *	@filp: pointer to struct file
  *	@wait: pointer to poll_table
+ *
+ *	Called by the OS when the kernel is asked to do a poll on
+ *	a SEP file handle.
  */
 static unsigned int sep_poll(struct file *filp, poll_table *wait)
 {
@@ -792,7 +806,7 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
 
 	dev_dbg(&sep->pdev->dev, "poll: start\n");
 
-	/* am I the process that own the transaction? */
+	/* Am I the process that owns the transaction? */
 	mutex_lock(&sep->sep_mutex);
 	if (current->pid != sep->pid_doing_transaction) {
 		dev_warn(&sep->pdev->dev, "poll; wrong pid\n");
@@ -934,10 +948,12 @@ static unsigned long sep_set_time(struct sep_device *sep)
 }
 
 /**
- *	sep_set_caller_id_handler - inserts the data into the caller id table
- *      note that this function does fall under the ioctl lock
+ *	sep_set_caller_id_handler - insert caller id entry
  *	@sep: sep device
  *	@arg: pointer to struct caller_id_struct
+ *
+ *	Inserts the data into the caller id table. Note that this function
+ *	falls under the ioctl lock
  */
 static int sep_set_caller_id_handler(struct sep_device *sep, u32 arg)
 {
@@ -1003,9 +1019,11 @@ end_function:
 }
 
 /**
- *	sep_set_current_caller_id - set the caller id (if exists) to the sep
- *      note that this function does fall under the ioctl lock
+ *	sep_set_current_caller_id - set the caller id
  *	@sep: pointer to struct_sep
+ *
+ *	Set the caller ID (if it exists) to the sep. Note that this
+ *	function falls under the ioctl lock
  */
 static int sep_set_current_caller_id(struct sep_device *sep)
 {
@@ -1040,10 +1058,12 @@ static int sep_set_current_caller_id(struct sep_device *sep)
 
 /**
  *	sep_send_command_handler - kick off a command
- *      note that this function does fall under the ioctl lock
+ *	@sep: sep being signalled
+ *
  *	This function raises interrupt to SEP that signals that is has a new
  *	command from the host
- *	@sep: sep being signalled
+ *
+ *      Note that this function does fall under the ioctl lock
  */
 
 static int sep_send_command_handler(struct sep_device *sep)
@@ -1085,14 +1105,15 @@ end_function:
 }
 
 /**
- *	sep_allocate_data_pool_memory_handler -
+ *	sep_allocate_data_pool_memory_handler -allocate pool memory
+ *	@sep: pointer to struct_sep
+ *	@arg: pointer to struct alloc_struct
+ *
  *	This function handles the allocate data pool memory request
  *	This function returns calculates the bus address of the
  *	allocated memory, and the offset of this area from the mapped address.
  *	Therefore, the FVOs in user space can calculate the exact virtual
  *	address of this allocated memory
- *	@sep: pointer to struct_sep
- *	@arg: pointer to struct alloc_struct
  */
 static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
 	unsigned long arg)
@@ -1100,7 +1121,7 @@ static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
 	int error = 0;
 	struct alloc_struct command_args;
 
-	/* holds the allocated buffer address in the system memory pool */
+	/* Holds the allocated buffer address in the system memory pool */
 	u32 *token_addr;
 
 	dev_dbg(&sep->pdev->dev,
@@ -1112,7 +1133,7 @@ static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
 		goto end_function;
 	}
 
-	/* allocate memory */
+	/* Allocate memory */
 	if ((sep->data_pool_bytes_allocated + command_args.num_bytes) >
 		SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES) {
 		error = -ENOMEM;
@@ -1123,14 +1144,14 @@ static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
 		"bytes_allocated: %x\n", (int)sep->data_pool_bytes_allocated);
 	dev_dbg(&sep->pdev->dev,
 		"offset: %x\n", SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES);
-	/* set the virtual and bus address */
+	/* Set the virtual and bus address */
 	command_args.offset = SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES +
 		sep->data_pool_bytes_allocated;
 
 	dev_dbg(&sep->pdev->dev,
 		"command_args.offset: %x\n", command_args.offset);
 
-	/* place in the shared area that is known by the sep */
+	/* Place in the shared area that is known by the sep */
 	token_addr = (u32 *)(sep->shared_addr +
 		SEP_DRIVER_DATA_POOL_ALLOCATION_OFFSET_IN_BYTES +
 		(sep->num_of_data_allocations)*2*sizeof(u32));
@@ -1148,7 +1169,7 @@ static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
 	dev_dbg(&sep->pdev->dev, "data pool token [0] %x\n", token_addr[0]);
 	dev_dbg(&sep->pdev->dev, "data pool token [1] %x\n", token_addr[1]);
 
-	/* write the memory back to the user space */
+	/* Write the memory back to the user space */
 	error = copy_to_user((void *)arg, (void *)&command_args,
 		sizeof(struct alloc_struct));
 	if (error) {
@@ -1175,17 +1196,18 @@ end_function:
 }
 
 /**
- *	sep_lock_kernel_pages -
- *	This function locks all the physical pages of the kernel virtual buffer
- *	and construct a basic lli  array, where each entry holds the physical
- *	page address and the size that application data holds in this page
- *	This function is used only during kernel crypto mod calls from within
- *	the kernel (when ioctl is not used)
+ *	sep_lock_kernel_pages - map kernel pages for DMA
  *	@sep: pointer to struct sep_device
  *	@kernel_virt_addr: address of data buffer in kernel
  *	@data_size: size of data
  *	@lli_array_ptr: lli array
  *	@in_out_flag: input into device or output from device
+ *
+ *	This function locks all the physical pages of the kernel virtual buffer
+ *	and construct a basic lli  array, where each entry holds the physical
+ *	page address and the size that application data holds in this page
+ *	This function is used only during kernel crypto mod calls from within
+ *	the kernel (when ioctl is not used)
  */
 static int sep_lock_kernel_pages(struct sep_device *sep,
 	u32 kernel_virt_addr,
@@ -1273,16 +1295,17 @@ end_function:
 }
 
 /**
- *	sep_lock_user_pages -
- *	This function locks all the physical pages of the application
- *	virtual buffer and construct a basic lli  array, where each entry
- *	holds the physical page address and the size that application
- *	data holds in this physical pages
+ *	sep_lock_user_pages - lock and map user pages for DMA
  *	@sep: pointer to struct sep_device
  *	@app_virt_addr: user memory data buffer
  *	@data_size: size of data buffer
  *	@lli_array_ptr: lli array
  *	@in_out_flag: input or output to device
+ *
+ *	This function locks all the physical pages of the application
+ *	virtual buffer and construct a basic lli  array, where each entry
+ *	holds the physical page address and the size that application
+ *	data holds in this physical pages
  */
 static int sep_lock_user_pages(struct sep_device *sep,
 	u32 app_virt_addr,
@@ -1505,17 +1528,16 @@ end_function:
 }
 
 /**
- *	u32 sep_calculate_lli_table_max_size -
- *	this function calculates the size of data
- *	that can be inserted into the lli
- *	table from this array the condition is that
- *	either the table is full
- *	(all etnries are entered), or there are no more
- *	entries in the lli array
+ *	u32 sep_calculate_lli_table_max_size - size the LLI table
  *	@sep: pointer to struct sep_device
  *	@lli_in_array_ptr
  *	@num_array_entries
  *	@last_table_flag
+ *
+ *	This function calculates the size of data that can be inserted into
+ *	the lli table from this array, such that either the table is full
+ *	(all entries are entered), or there are no more entries in the
+ *	lli array
  */
 static u32 sep_calculate_lli_table_max_size(struct sep_device *sep,
 	struct sep_lli_entry *lli_in_array_ptr,
@@ -1590,15 +1612,16 @@ end_function:
 }
 
 /**
- *	sep_build_lli_table -
- *	this functions builds ont lli table from the lli_array according to
- *	the given size of data
+ *	sep_build_lli_table - build an lli array for the given table
  *	@sep: pointer to struct sep_device
  *	@lli_array_ptr: pointer to lli array
  *	@lli_table_ptr: pointer to lli table
  *	@num_processed_entries_ptr: pointer to number of entries
  *	@num_table_entries_ptr: pointer to number of tables
  *	@table_data_size: total data size
+ *
+ *	Builds ant lli table from the lli_array according to
+ *	the given size of data
  */
 static void sep_build_lli_table(struct sep_device *sep,
 	struct sep_lli_entry	*lli_array_ptr,
@@ -1707,13 +1730,14 @@ static void sep_build_lli_table(struct sep_device *sep,
 }
 
 /**
- *	sep_shared_area_virt_to_bus -
+ *	sep_shared_area_virt_to_bus - map shared area to bus address
+ *	@sep: pointer to struct sep_device
+ *	@virt_address: virtual address to convert
+ *
  *	This functions returns the physical address inside shared area according
  *	to the virtual address. It can be either on the externa RAM device
  *	(ioremapped), or on the system RAM
  *	This implementation is for the external RAM
- *	@sep: pointer to struct sep_device
- *	@virt_address: virtual address to convert
  */
 static dma_addr_t sep_shared_area_virt_to_bus(struct sep_device *sep,
 	void *virt_address)
@@ -1731,13 +1755,14 @@ static dma_addr_t sep_shared_area_virt_to_bus(struct sep_device *sep,
 }
 
 /**
- *	sep_shared_area_bus_to_virt -
+ *	sep_shared_area_bus_to_virt - map shared area bus address to kernel
+ *	@sep: pointer to struct sep_device
+ *	@bus_address: bus address to convert
+ *
  *	This functions returns the virtual address inside shared area
  *	according to the physical address. It can be either on the
  *	externa RAM device (ioremapped), or on the system RAM
  *	This implementation is for the external RAM
- *	@sep: pointer to struct sep_device
- *	@bus_address: bus address to convert
  */
 
 static void *sep_shared_area_bus_to_virt(struct sep_device *sep,
@@ -1754,13 +1779,13 @@ static void *sep_shared_area_bus_to_virt(struct sep_device *sep,
 }
 
 /**
- *	sep_debug_print_lli_tables -
- *	this function goes over the list of the print created tables and
- *	prints all the data
+ *	sep_debug_print_lli_tables - dump LLI table
  *	@sep: pointer to struct sep_device
  *	@lli_table_ptr: pointer to sep_lli_entry
  *	@num_table_entries: number of entries
  *	@table_data_size: total data size
+ *
+ *	Walk the the list of the print created tables and print all the data
  */
 static void sep_debug_print_lli_tables(struct sep_device *sep,
 	struct sep_lli_entry *lli_table_ptr,
@@ -1831,12 +1856,14 @@ static void sep_debug_print_lli_tables(struct sep_device *sep,
 
 
 /**
- *	sep_prepare_empty_lli_table -
- *	This function creates empty lli tables when there is no data
+ *	sep_prepare_empty_lli_table - create a blank LLI table
  *	@sep: pointer to struct sep_device
  *	@lli_table_addr_ptr: pointer to lli table
  *	@num_entries_ptr: pointer to number of entries
  *	@table_data_size_ptr: point to table data size
+ *
+ *	This function creates empty lli tables when there is no data
+
  */
 static void sep_prepare_empty_lli_table(struct sep_device *sep,
 		dma_addr_t *lli_table_addr_ptr,
@@ -1881,11 +1908,7 @@ static void sep_prepare_empty_lli_table(struct sep_device *sep,
 }
 
 /**
- *	sep_prepare_input_dma_table -
- *	This function prepares only input DMA table for synhronic symmetric
- *	operations (HASH)
- *	Note that all bus addresses that are passed to the sep
- *	are in 32 bit format; the SEP is a 32 bit device
+ *	sep_prepare_input_dma_table - prepare input DMA mappings
  *	@sep: pointer to struct sep_device
  *	@data_size:
  *	@block_size:
@@ -1893,6 +1916,11 @@ static void sep_prepare_empty_lli_table(struct sep_device *sep,
  *	@num_entries_ptr:
  *	@table_data_size_ptr:
  *	@is_kva: set for kernel data (kernel cryptio call)
+ *
+ *	This function prepares only input DMA table for synhronic symmetric
+ *	operations (HASH)
+ *	Note that all bus addresses that are passed to the sep
+ *	are in 32 bit format; the SEP is a 32 bit device
  */
 static int sep_prepare_input_dma_table(struct sep_device *sep,
 	unsigned long app_virt_addr,
@@ -2099,12 +2127,7 @@ end_function:
 
 }
 /**
- *	sep_construct_dma_tables_from_lli -
- *	This function creates the input and output dma tables for
- *	symmetric operations (AES/DES) according to the block
- *	size from LLI arays
- *	Note that all bus addresses that are passed to the sep
- *	are in 32 bit format; the SEP is a 32 bit device
+ *	sep_construct_dma_tables_from_lli - prepare AES/DES mappings
  *	@sep: pointer to struct_sep
  *	@lli_in_array:
  *	@sep_in_lli_entries:
@@ -2116,6 +2139,12 @@ end_function:
  *	@in_num_entries_ptr
  *	@out_num_entries_ptr
  *	@table_data_size_ptr
+ *
+ *	This function creates the input and output dma tables for
+ *	symmetric operations (AES/DES) according to the block
+ *	size from LLI arays
+ *	Note that all bus addresses that are passed to the sep
+ *	are in 32 bit format; the SEP is a 32 bit device
  */
 static int sep_construct_dma_tables_from_lli(
 	struct sep_device *sep,
@@ -2358,12 +2387,7 @@ static int sep_construct_dma_tables_from_lli(
 }
 
 /**
- *	sep_prepare_input_output_dma_table -
- *	This function builds input and output DMA tables for synhronic
- *	symmetric operations (AES, DES, HASH). It also checks that each table
- *	is of the modular block size
- *	Note that all bus addresses that are passed to the sep
- *	are in 32 bit format; the SEP is a 32 bit device
+ *	sep_prepare_input_output_dma_table - prepare DMA I/O table
  *	@app_virt_in_addr:
  *	@app_virt_out_addr:
  *	@data_size:
@@ -2374,6 +2398,12 @@ static int sep_construct_dma_tables_from_lli(
  *	@out_num_entries_ptr:
  *	@table_data_size_ptr:
  *	@is_kva: set for kernel data; used only for kernel crypto module
+ *
+ *	This function builds input and output DMA tables for synhronic
+ *	symmetric operations (AES, DES, HASH). It also checks that each table
+ *	is of the modular block size
+ *	Note that all bus addresses that are passed to the sep
+ *	are in 32 bit format; the SEP is a 32 bit device
  */
 static int sep_prepare_input_output_dma_table(struct sep_device *sep,
 	unsigned long app_virt_in_addr,
@@ -2522,12 +2552,7 @@ end_function:
 }
 
 /**
- *	sep_prepare_input_output_dma_table_in_dcb -
- *	This function prepares the linked dma tables and puts the
- *	address for the linked list of tables inta a dcb (data control
- *	block) the address of which is known by the sep hardware
- *	Note that all bus addresses that are passed to the sep
- *	are in 32 bit format; the SEP is a 32 bit device
+ *	sep_prepare_input_output_dma_table_in_dcb - prepare control blocks
  *	@app_in_address: unsigned long; for data buffer in (user space)
  *	@app_out_address: unsigned long; for data buffer out (user space)
  *	@data_in_size: u32; for size of data
@@ -2535,6 +2560,12 @@ end_function:
  *	@tail_block_size: u32; for size of tail block
  *	@isapplet: bool; to indicate external app
  *	@is_kva: bool; kernel buffer; only used for kernel crypto module
+ *
+ *	This function prepares the linked dma tables and puts the
+ *	address for the linked list of tables inta a dcb (data control
+ *	block) the address of which is known by the sep hardware
+ *	Note that all bus addresses that are passed to the sep
+ *	are in 32 bit format; the SEP is a 32 bit device
  */
 static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 	u32  app_in_address,
@@ -2737,14 +2768,14 @@ end_function:
 
 
 /**
- *	sep_create_sync_dma_tables_handler -
- *	this function handles tha request for creation of the DMA table
- *	for the synchronic symmetric operations (AES,DES)
- *	Note that all bus addresses that are passed to the sep
- *	are in 32 bit format; the SEP is a 32 bit device
+ *	sep_create_sync_dma_tables_handler - create sync dma tables
  *	@sep: pointer to struct sep_device
  *	@arg: pointer to struct bld_syn_tab_struct
-*/
+ *
+ *	Handle the request for creation of the DMA tables for the synchronic
+ *	symmetric operations (AES,DES). Note that all bus addresses that are
+ *	passed to the SEP are in 32 bit format; the SEP is a 32 bit device
+ */
 static int sep_create_sync_dma_tables_handler(struct sep_device *sep,
 						unsigned long arg)
 {
@@ -2799,11 +2830,12 @@ end_function:
 }
 
 /**
- *	sep_free_dma_tables_and_dcb -
- *	This function frees the dma tables and dcb block
+ *	sep_free_dma_tables_and_dcb - free DMA tables and DCBs
  *	@sep: pointer to struct sep_device
  *	@isapplet: indicates external application (used for kernel access)
  *	@is_kva: indicates kernel addresses (only used for kernel crypto)
+ *
+ *	This function frees the dma tables and dcb block
  */
 static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
 	bool is_kva)
@@ -2858,11 +2890,12 @@ static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
 }
 
 /**
- *	sep_get_static_pool_addr_handler -
- *	this function sets the bus and virtual addresses of the static pool
- *	and returns the virtual address
+ *	sep_get_static_pool_addr_handler - get static pool address
  *	@sep: pointer to struct sep_device
  *	@arg: parameters from user space application
+ *
+ *	This function sets the bus and virtual addresses of the static pool
+ *	and returns the virtual address
  */
 static int sep_get_static_pool_addr_handler(struct sep_device *sep,
 	unsigned long arg)
@@ -2901,8 +2934,7 @@ static int sep_get_static_pool_addr_handler(struct sep_device *sep,
 }
 
 /**
- *	sep_start_handler -
- *	This function starts the sep device
+ *	sep_start_handler - start device
  *	@sep: pointer to struct sep_device
  */
 static int sep_start_handler(struct sep_device *sep)
@@ -2926,11 +2958,12 @@ static int sep_start_handler(struct sep_device *sep)
 }
 
 /**
- *	ep_check_sum_calc -
- *	This function performs a checsum for messages that are sent
+ *	ep_check_sum_calc - checksum messages
+ *	@data: buffer to checksum
+ *	@length: buffer size
+ *
+ *	This function performs a checksum for messages that are sent
  *	to the sep
- *	@data:
- *	@length:
  */
 static u32 sep_check_sum_calc(u8 *data, u32 length)
 {
@@ -2956,17 +2989,18 @@ static u32 sep_check_sum_calc(u8 *data, u32 length)
 
 /**
  *	sep_init_handler -
- *	this function handles the request for SEP initialization
+ *	@sep: pointer to struct sep_device
+ *	@arg: parameters from user space application
+ *
+ *	Handles the request for SEP initialization
  *	Note that this will go away for Medfield once the SCU
  *	SEP initialization is complete
  *	Also note that the message to the sep has components
  *	from user space as well as components written by the driver
- *	This is becuase the portions of the message that partain to
+ *	This is becuase the portions of the message that pertain to
  *	physical addresses must be set by the driver after the message
  *	leaves custody of the user space application for security
  *	reasons.
- *	@sep: pointer to struct sep_device
- *	@arg: parameters from user space application
  */
 static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 {
@@ -3127,9 +3161,10 @@ end_function:
 }
 
 /**
- *	sep_end_transaction_handler -
- *	This API handles the end transaction request
+ *	sep_end_transaction_handler - end transaction
  *	@sep: pointer to struct sep_device
+ *
+ *	This API handles the end transaction request
  */
 static int sep_end_transaction_handler(struct sep_device *sep)
 {
@@ -3163,11 +3198,12 @@ static int sep_end_transaction_handler(struct sep_device *sep)
 }
 
 /**
- *	sep_prepare_dcb_handler -
- *	This function will retrieve the RAR buffer physical addresses, type
- *	& size corresponding to the RAR handles provided in the buffers vector.
+ *	sep_prepare_dcb_handler - prepare a control block 
  *	@sep: pointer to struct sep_device
  *	@arg: pointer to user parameters
+ *
+ *	This function will retrieve the RAR buffer physical addresses, type
+ *	& size corresponding to the RAR handles provided in the buffers vector.
  */
 
 static int sep_prepare_dcb_handler(struct sep_device *sep, unsigned long arg)
@@ -3211,10 +3247,11 @@ end_function:
 }
 
 /**
- *	sep_free_dcb_handler -
- *	this function frees the DCB resources
- *	and updates the needed user-space buffers
+ *	sep_free_dcb_handler - free control block resources
  *	@sep: pointer to struct sep_device
+ *
+ *	This function frees the DCB resources and updates the needed
+ *	user-space buffers.
  */
 static int sep_free_dcb_handler(struct sep_device *sep)
 {
@@ -3230,11 +3267,12 @@ static int sep_free_dcb_handler(struct sep_device *sep)
 }
 
 /**
- *	sep_rar_prepare_output_msg_handler -
- *	This function will retrieve the RAR buffer physical addresses, type
- *	& size corresponding to the RAR handles provided in the buffers vector.
+ *	sep_rar_prepare_output_msg_handler - prepare an output message 
  *	@sep: pointer to struct sep_device
  *	@arg: pointer to user parameters
+ *
+ *	This function will retrieve the RAR buffer physical addresses, type
+ *	& size corresponding to the RAR handles provided in the buffers vector.
  */
 
 static int sep_rar_prepare_output_msg_handler(struct sep_device *sep,
@@ -3300,10 +3338,11 @@ end_function:
 }
 
 /**
- *	sep_realloc_ext_cache_handler -
- *	This function tells the sep where the extapp is located
+ *	sep_realloc_ext_cache_handler - report location of extcache
  *	@sep: pointer to struct sep_device
  *	@arg: pointer to user parameters
+ *
+ *	This function tells the sep where the extapp is located
  */
 static int sep_realloc_ext_cache_handler(struct sep_device *sep,
 	unsigned long arg)
@@ -3332,6 +3371,8 @@ static int sep_realloc_ext_cache_handler(struct sep_device *sep,
  *	@filp: pointer to struct file
  *	@cmd: command
  *	@arg: pointer to argument structure
+ *
+ *	Implement the ioctl methods availble on the SEP device.
  */
 static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
@@ -3462,6 +3503,8 @@ end_function:
  *	@filp: pointer to struct file
  *	@cmd: command
  *	@arg: pointer to argument structure
+ *
+ *	Implement the additional ioctls for the singleton device
  */
 static long sep_singleton_ioctl(struct file  *filp, u32 cmd, unsigned long arg)
 {
@@ -3522,6 +3565,7 @@ end_function:
  *	@filp: pointer to struct file
  *	@cmd: command
  *	@arg: pointer to argument structure
+ *
  *	Called by the request daemon to perform ioctls on the daemon device
  */
 
@@ -3643,10 +3687,11 @@ static irqreturn_t sep_inthandler(int irq, void *dev_id)
 }
 
 /**
- *	sep_callback -
+ *	sep_callback - RAR callback
+ *	@sep_context_pointer: pointer to struct sep_device
+ *
  *	Function that is called by rar_register when it is ready with
  *	a region (only for Moorestown)
- *	@sep_context_pointer: pointer to struct sep_device
  */
 static int sep_callback(unsigned long sep_context_pointer)
 {
@@ -3696,10 +3741,12 @@ end_function:
 }
 
 /**
- *	sep_probe -
- *	Function that is activated on the successful probe of the SEP device
+ *	sep_probe - probe a matching PCI device
  *	@pdev: pci_device
  *	@end: pci_device_id
+ *
+ *	Attempt to set up and configure a SEP device that has been
+ *	discovered by the PCI layer.
  */
 static int __devinit sep_probe(struct pci_dev *pdev,
 	const struct pci_device_id *ent)
@@ -3904,10 +3951,11 @@ static const struct file_operations sep_file_operations = {
 };
 
 /**
- *	sep_reconfig_shared_area -
- *	reconfig the shared area between HOST and SEP - needed in case
- *	the DX_CC_Init function was called before OS loading
+ *	sep_reconfig_shared_area - reconfigure shared area
  *	@sep: pointer to struct sep_device
+ *
+ *	Reconfig the shared area between HOST and SEP - needed in case
+ *	the DX_CC_Init function was called before OS loading.
  */
 static int sep_reconfig_shared_area(struct sep_device *sep)
 {
@@ -3948,9 +3996,10 @@ static int sep_reconfig_shared_area(struct sep_device *sep)
 }
 
 /**
- *	sep_register_driver_to_fs -
- *	This function registers the driver to the file system
+ *	sep_register_driver_to_fs - register misc devices
  *	@sep: pointer to struct sep_device
+ *
+ *	This function registers the driver to the file system
  */
 static int sep_register_driver_to_fs(struct sep_device *sep)
 {
@@ -4000,7 +4049,9 @@ static int sep_register_driver_to_fs(struct sep_device *sep)
 }
 
 /**
- *	sep_init - init function; this is the first thing called on boot
+ *	sep_init - init function
+ *
+ *	Module load time. Register the PCI device driver.
  */
 static int __init sep_init(void)
 {
@@ -4051,7 +4102,10 @@ end_function:
 
 
 /**
- *	sep_exit - called to unload driver (never called on static compile)
+ *	sep_exit - called to unload driver 
+ *
+ *	Drop the misc devices then remove and unmap the various resources
+ *	that are not released by the driver remove method.
  */
 static void __exit sep_exit(void)
 {


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 07/12] sep: clean up some of the obvious sillies
  2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
                   ` (5 preceding siblings ...)
  2010-11-24 19:34 ` [PATCH 06/12] sep: Fix the kernel-doc in SEP Alan Cox
@ 2010-11-24 19:38 ` Alan Cox
  2010-11-24 19:38 ` [PATCH 08/12] sep: Use kzalloc when needed Alan Cox
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 19:38 UTC (permalink / raw)
  To: greg, mark.a.allyn, linux-kernel

From: Alan Cox <alan@linux.intel.com>

Various assignments are done but not used
dev_dbg formatting is a bit weird and wraps when not needed
Take out some of the blank lines and reformat a bit to reduce view size
Remove some comments that are obvious
Fix else formatting
Remove some user triggerable dev_warns
Fix copy_from_user error return cases (-EFAULT not bytes copied)

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/staging/sep/sep_driver.c |  941 ++++++++++----------------------------
 1 files changed, 249 insertions(+), 692 deletions(-)


diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index 4a0bb43..f576285 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -83,15 +83,13 @@ static struct sep_device *sep_dev;
  *	This functions copies the cache and resident from their source
  *	location into destination shared memory.
  */
-
 static int sep_load_firmware(struct sep_device *sep)
 {
 	const struct firmware *fw;
 	char *cache_name = "cache.image.bin";
 	char *res_name = "resident.image.bin";
 	char *extapp_name = "extapp.image.bin";
-
-	int error = 0;
+	int error ;
 	unsigned int work1, work2, work3;
 
 	/* set addresses and load resident */
@@ -110,7 +108,7 @@ static int sep_load_firmware(struct sep_device *sep)
 
 	dev_dbg(&sep->pdev->dev, "resident virtual is %p\n",
 		sep->resident_addr);
-	dev_dbg(&sep->pdev->dev, "residnet bus is %lx\n",
+	dev_dbg(&sep->pdev->dev, "resident bus is %lx\n",
 		(unsigned long)sep->resident_bus);
 	dev_dbg(&sep->pdev->dev, "resident size is %08x\n",
 		sep->resident_size);
@@ -134,7 +132,7 @@ static int sep_load_firmware(struct sep_device *sep)
 
 	error = request_firmware(&fw, cache_name, &sep->pdev->dev);
 	if (error) {
-		dev_warn(&sep->pdev->dev, "cant request cache fw\n");
+		dev_warn(&sep->pdev->dev, "Unable to request cache firmware\n");
 		return error;
 	}
 
@@ -155,7 +153,7 @@ static int sep_load_firmware(struct sep_device *sep)
 
 	error = request_firmware(&fw, extapp_name, &sep->pdev->dev);
 	if (error) {
-		dev_warn(&sep->pdev->dev, "cant request extapp fw\n");
+		dev_warn(&sep->pdev->dev, "Unable to request extapp firmware\n");
 		return error;
 	}
 
@@ -181,15 +179,13 @@ MODULE_FIRMWARE("sep/extapp.image.bin");
  *	sep_dump_message - dump the message that is pending
  *	@sep: sep device
  */
-
 static void sep_dump_message(struct sep_device *sep)
 {
 	int count;
 	u32 *p = sep->shared_addr;
 	for (count = 0; count < 12 * 4; count += 4)
-		dev_dbg(&sep->pdev->dev,
-			"Word %d of the message is %x\n",
-			count, *p++);
+		dev_dbg(&sep->pdev->dev, "Word %d of the message is %x\n",
+								count, *p++);
 }
 
 /**
@@ -197,7 +193,6 @@ static void sep_dump_message(struct sep_device *sep)
  *	@sep: security processor
  *	@size: size of shared area
  */
-
 static int sep_map_and_alloc_shared_area(struct sep_device *sep)
 {
 	sep->shared_addr = dma_alloc_coherent(&sep->pdev->dev,
@@ -211,8 +206,8 @@ static int sep_map_and_alloc_shared_area(struct sep_device *sep)
 	}
 	dev_dbg(&sep->pdev->dev,
 		"sep: shared_addr %x bytes @%p (bus %llx)\n",
-		sep->shared_size, sep->shared_addr,
-			(unsigned long long)sep->shared_bus);
+				sep->shared_size, sep->shared_addr,
+				(unsigned long long)sep->shared_bus);
 	return 0;
 }
 
@@ -235,7 +230,6 @@ static void sep_unmap_and_free_shared_area(struct sep_device *sep)
  *	Returns virtual address inside the shared area according
  *	to the bus address.
  */
-
 static void *sep_shared_bus_to_virt(struct sep_device *sep,
 						dma_addr_t bus_address)
 {
@@ -249,11 +243,9 @@ static void *sep_shared_bus_to_virt(struct sep_device *sep,
  *
  *	Called when the user opens the singleton device interface
  */
-
 static int sep_singleton_open(struct inode *inode_ptr, struct file *file_ptr)
 {
 	int error = 0;
-
 	struct sep_device *sep;
 
 	/*
@@ -290,7 +282,6 @@ end_function:
  *
  *	Returns zero on success otherwise an error code.
  */
-
 static int sep_open(struct inode *inode, struct file *filp)
 {
 	struct sep_device *sep;
@@ -317,16 +308,13 @@ static int sep_open(struct inode *inode, struct file *filp)
  *	multiple simultaenous opens that means this method is called when the
  *	final reference to the open handle is dropped.
  */
-
 static int sep_singleton_release(struct inode *inode, struct file *filp)
 {
 	struct sep_device *sep = filp->private_data;
 
 	dev_dbg(&sep->pdev->dev, "Singleton release for pid %d\n",
-		current->pid);
-
+							current->pid);
 	clear_bit(0, &sep->singleton_access_flag);
-
 	return 0;
 }
 
@@ -340,14 +328,11 @@ static int sep_singleton_release(struct inode *inode, struct file *filp)
  *
  *	Returns zero on success otherwise an error code.
  */
-
 static int sep_request_daemon_open(struct inode *inode, struct file *filp)
 {
-	struct sep_device *sep;
-
+	struct sep_device *sep = sep_dev;
 	int error = 0;
 
-	sep = sep_dev;
 	filp->private_data = sep;
 
 	dev_dbg(&sep->pdev->dev, "Request daemon open for pid %d\n",
@@ -355,13 +340,8 @@ static int sep_request_daemon_open(struct inode *inode, struct file *filp)
 
 	/* There is supposed to be only one request daemon */
 	dev_dbg(&sep->pdev->dev, "calling test and set for req_dmon open 0\n");
-	if (test_and_set_bit(0, &sep->request_daemon_open)) {
+	if (test_and_set_bit(0, &sep->request_daemon_open))
 		error = -EBUSY;
-		goto end_function;
-	}
-
-end_function:
-
 	return error;
 }
 
@@ -372,7 +352,6 @@ end_function:
  *
  *	Called on the final close of a SEP daemon.
  */
-
 static int sep_request_daemon_release(struct inode *inode, struct file *filp)
 {
 	struct sep_device *sep = filp->private_data;
@@ -382,7 +361,6 @@ static int sep_request_daemon_release(struct inode *inode, struct file *filp)
 
 	/* clear the request_daemon_open flag */
 	clear_bit(0, &sep->request_daemon_open);
-
 	return 0;
 }
 
@@ -395,15 +373,11 @@ static int sep_request_daemon_release(struct inode *inode, struct file *filp)
  */
 static int sep_req_daemon_send_reply_command_handler(struct sep_device *sep)
 {
-	int error = 0;
-
 	unsigned long lck_flags;
 
 	dev_dbg(&sep->pdev->dev,
 		"sep_req_daemon_send_reply_command_handler start\n");
 
-	error = 0;
-
 	sep_dump_message(sep);
 
 	/* counters are lockable region */
@@ -426,7 +400,7 @@ static int sep_req_daemon_send_reply_command_handler(struct sep_device *sep)
 	dev_dbg(&sep->pdev->dev,
 		"sep_req_daemon_send_reply_command_handler end\n");
 
-	return error;
+	return 0;
 }
 
 
@@ -436,80 +410,56 @@ static int sep_req_daemon_send_reply_command_handler(struct sep_device *sep)
  *
  *	Handles the request to  free dma table for synchronic actions
  */
-
 static int sep_free_dma_table_data_handler(struct sep_device *sep)
 {
-	/* counter */
-	int count = 0;
-
-	/* dcb counter */
-	int dcb_counter = 0;
-
+	int count;
+	int dcb_counter;
 	/* pointer to the current dma_resource struct */
 	struct sep_dma_resource *dma;
 
-	dev_dbg(&sep->pdev->dev,
-		"sep_free_dma_table_data_handler start\n");
-
-
-	for (dcb_counter = 0; dcb_counter < sep->nr_dcb_creat;
-		dcb_counter++) {
+	dev_dbg(&sep->pdev->dev, "sep_free_dma_table_data_handler start\n");
 
+	for (dcb_counter = 0; dcb_counter < sep->nr_dcb_creat; dcb_counter++) {
 		dma = &sep->dma_res_arr[dcb_counter];
 
 		/* unmap and free input map array */
 		if (dma->in_map_array) {
-
-			for (count = 0; count < dma->in_num_pages;
-				count++) {
-
+			for (count = 0; count < dma->in_num_pages; count++) {
 				dma_unmap_page(&sep->pdev->dev,
 					dma->in_map_array[count].dma_addr,
 					dma->in_map_array[count].size,
 					DMA_TO_DEVICE);
 			}
-
 			kfree(dma->in_map_array);
 		}
 
 		/* unmap output map array, DON'T free it yet */
 		if (dma->out_map_array) {
-			for (count = 0; count < dma->out_num_pages;
-				count++) {
-
+			for (count = 0; count < dma->out_num_pages; count++) {
 				dma_unmap_page(&sep->pdev->dev,
 					dma->out_map_array[count].dma_addr,
 					dma->out_map_array[count].size,
 					DMA_FROM_DEVICE);
 			}
-
 			kfree(dma->out_map_array);
 		}
 
 		/* free page cache for output */
 		if (dma->in_page_array) {
-			for (count = 0; count < dma->in_num_pages;
-				count++) {
-
+			for (count = 0; count < dma->in_num_pages; count++) {
 				flush_dcache_page(dma->in_page_array[count]);
 				page_cache_release(dma->in_page_array[count]);
 			}
-
 			kfree(dma->in_page_array);
-
 		}
 
 		if (dma->out_page_array) {
-			for (count = 0; count < dma->out_num_pages;
-				count++) {
-
+			for (count = 0; count < dma->out_num_pages; count++) {
 				if (!PageReserved(dma->out_page_array[count]))
 					SetPageDirty(dma->out_page_array[count]);
-
 				flush_dcache_page(dma->out_page_array[count]);
 				page_cache_release(dma->out_page_array[count]);
 			}
-
 			kfree(dma->out_page_array);
 		}
 
@@ -522,19 +472,15 @@ static int sep_free_dma_table_data_handler(struct sep_device *sep)
 		dma->out_map_array = 0;
 		dma->in_map_num_entries = 0;
 		dma->out_map_num_entries = 0;
-
 	}
 
 	sep->nr_dcb_creat = 0;
 	sep->num_lli_tables_created = 0;
 
-	dev_dbg(&sep->pdev->dev,
-		"sep_free_dma_table_data_handler end\n");
-
+	dev_dbg(&sep->pdev->dev, "sep_free_dma_table_data_handler end\n");
 	return 0;
 }
 
-
 /**
  *	sep_request_daemon_mmap - maps the shared area to user space
  *	@filp: pointer to struct file
@@ -546,11 +492,8 @@ static int sep_free_dma_table_data_handler(struct sep_device *sep)
 static int sep_request_daemon_mmap(struct file  *filp,
 	struct vm_area_struct  *vma)
 {
-	/* device */
 	struct sep_device *sep = filp->private_data;
-
 	dma_addr_t bus_address;
-
 	int error = 0;
 
 	dev_dbg(&sep->pdev->dev, "daemon mmap start\n");
@@ -563,23 +506,19 @@ static int sep_request_daemon_mmap(struct file  *filp,
 	/* get physical address */
 	bus_address = sep->shared_bus;
 
-	dev_dbg(&sep->pdev->dev,
-		"bus_address is %08lx\n",
-		(unsigned long)bus_address);
+	dev_dbg(&sep->pdev->dev, "bus_address is %08lx\n",
+					(unsigned long)bus_address);
 
 	if (remap_pfn_range(vma, vma->vm_start, bus_address >> PAGE_SHIFT,
 		vma->vm_end - vma->vm_start, vma->vm_page_prot)) {
 
-		dev_warn(&sep->pdev->dev,
-			"remap_page_range failed\n");
+		dev_warn(&sep->pdev->dev, "remap_page_range failed\n");
 		error = -EAGAIN;
 		goto end_function;
 	}
 
 end_function:
-
 	dev_dbg(&sep->pdev->dev, "daemon mmap end\n");
-
 	return error;
 }
 
@@ -595,69 +534,46 @@ static unsigned int sep_request_daemon_poll(struct file *filp,
 	poll_table  *wait)
 {
 	u32	mask = 0;
-
 	/* GPR2 register */
 	u32	retval2;
-
 	unsigned long lck_flags;
-
 	struct sep_device *sep = filp->private_data;
 
-	dev_dbg(&sep->pdev->dev,
-		"daemon poll: start\n");
-
-	dev_dbg(&sep->pdev->dev, "daemon poll: calling poll wait sep_event\n");
+	dev_dbg(&sep->pdev->dev, "daemon poll: start\n");
 
 	poll_wait(filp, &sep->event_request_daemon, wait);
 
-	dev_dbg(&sep->pdev->dev, "daemon poll: exit poll wait sep_event\n");
-
-	dev_dbg(&sep->pdev->dev,
-		"daemon poll: send_ct is %lx reply ct is %lx\n",
-		sep->send_ct, sep->reply_ct);
+	dev_dbg(&sep->pdev->dev, "daemon poll: send_ct is %lx reply ct is %lx\n",
+						sep->send_ct, sep->reply_ct);
 
 	spin_lock_irqsave(&sep->snd_rply_lck, lck_flags);
 	/* check if the data is ready */
 	if (sep->send_ct == sep->reply_ct) {
-
 		spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
 
 		retval2 = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR2_REG_ADDR);
-
 		dev_dbg(&sep->pdev->dev,
 			"daemon poll: data check (GPR2) is %x\n", retval2);
 
 		/* check if PRINT request */
 		if ((retval2 >> 30) & 0x1) {
-
-			dev_dbg(&sep->pdev->dev,
-				"daemon poll: PRINTF request in\n");
+			dev_dbg(&sep->pdev->dev, "daemon poll: PRINTF request in\n");
 			mask |= POLLIN;
 			goto end_function;
 		}
-
 		/* check if NVS request */
 		if (retval2 >> 31) {
-
-			dev_dbg(&sep->pdev->dev,
-				"daemon poll: NVS request in\n");
+			dev_dbg(&sep->pdev->dev, "daemon poll: NVS request in\n");
 			mask |= POLLPRI | POLLWRNORM;
 		}
-	}
-
-	else {
-
+	} else {
 		spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
-
 		dev_dbg(&sep->pdev->dev,
 			"daemon poll: no reply received; returning 0\n");
 		mask = 0;
 	}
-
 end_function:
-
-	dev_dbg(&sep->pdev->dev,
-		"daemon poll: exit\n");
+	dev_dbg(&sep->pdev->dev, "daemon poll: exit\n");
 	return mask;
 }
 
@@ -668,7 +584,6 @@ end_function:
  *
  *	Called on the final close of a SEP device.
  */
-
 static int sep_release(struct inode *inode, struct file *filp)
 {
 	struct sep_device *sep = filp->private_data;
@@ -709,9 +624,6 @@ static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
 
 	dev_dbg(&sep->pdev->dev, "mmap start\n");
 
-
-	dev_dbg(&sep->pdev->dev, "calling wait on event_mmap, tsetbit"
-		" SEP_MMAP_LOCK_BIT in_use_flags 0\n");
 	/* Set the transaction busy (own the device) */
 	wait_event_interruptible(sep->event,
 		test_and_set_bit(SEP_MMAP_LOCK_BIT,
@@ -748,8 +660,7 @@ static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
 		goto end_function_with_error;
 	}
 
-	dev_dbg(&sep->pdev->dev,
-		"shared_addr is %p\n", sep->shared_addr);
+	dev_dbg(&sep->pdev->dev, "shared_addr is %p\n", sep->shared_addr);
 
 	/* get bus address */
 	bus_addr = sep->shared_bus;
@@ -759,17 +670,14 @@ static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
 
 	if (remap_pfn_range(vma, vma->vm_start, bus_addr >> PAGE_SHIFT,
 		vma->vm_end - vma->vm_start, vma->vm_page_prot)) {
-		dev_warn(&sep->pdev->dev,
-			"remap_page_range failed\n");
+		dev_warn(&sep->pdev->dev, "remap_page_range failed\n");
 		error = -EAGAIN;
 		goto end_function_with_error;
 	}
-
 	dev_dbg(&sep->pdev->dev, "mmap end\n");
 	goto end_function;
 
 end_function_with_error:
-
 	/* clear the bit */
 	clear_bit(SEP_MMAP_LOCK_BIT, &sep->in_use_flags);
 	mutex_lock(&sep->sep_mutex);
@@ -782,7 +690,6 @@ end_function_with_error:
 	wake_up(&sep->event);
 
 end_function:
-
 	return error;
 }
 
@@ -799,7 +706,6 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
 	u32 mask = 0;
 	u32 retval = 0;
 	u32 retval2 = 0;
-
 	unsigned long lck_flags;
 
 	struct sep_device *sep = filp->private_data;
@@ -814,7 +720,6 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
 		mutex_unlock(&sep->sep_mutex);
 		goto end_function;
 	}
-
 	mutex_unlock(&sep->sep_mutex);
 
 	/* check if send command or send_reply were activated previously */
@@ -829,18 +734,13 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
 
 	poll_wait(filp, &sep->event, wait);
 
-	dev_dbg(&sep->pdev->dev, "poll: exit wait sep_event\n");
-
 	dev_dbg(&sep->pdev->dev, "poll: send_ct is %lx reply ct is %lx\n",
 		sep->send_ct, sep->reply_ct);
 
 	/* check if error occured during poll */
 	retval2 = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
-
 	if (retval2 != 0x0) {
-
-		dev_warn(&sep->pdev->dev, "poll; poll error %x\n",
-			retval2);
+		dev_warn(&sep->pdev->dev, "poll; poll error %x\n", retval2);
 		mask |= POLLERR;
 		goto end_function;
 	}
@@ -848,7 +748,6 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
 	spin_lock_irqsave(&sep->snd_rply_lck, lck_flags);
 
 	if (sep->send_ct == sep->reply_ct) {
-
 		spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
 		retval = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR2_REG_ADDR);
 		dev_dbg(&sep->pdev->dev, "poll: data ready check (GPR2)  %x\n",
@@ -856,46 +755,33 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
 
 		/* check if printf request  */
 		if ((retval >> 30) & 0x1) {
-
 			dev_dbg(&sep->pdev->dev, "poll: sep printf request\n");
 			wake_up(&sep->event_request_daemon);
 			goto end_function;
-
 		}
 
 		/* check if the this is sep reply or request */
 		if (retval >> 31) {
-
 			dev_dbg(&sep->pdev->dev, "poll: sep request\n");
 			wake_up(&sep->event_request_daemon);
-
 		} else {
-
 			dev_dbg(&sep->pdev->dev, "poll: normal return\n");
-
 			/* in case it is again by send_reply_comand */
-
 			clear_bit(SEP_SEND_MSG_LOCK_BIT, &sep->in_use_flags);
-
 			sep_dump_message(sep);
-
 			dev_dbg(&sep->pdev->dev,
 				"poll; sep reply POLLIN | POLLRDNORM\n");
 
 			mask |= POLLIN | POLLRDNORM;
 		}
-
 	} else {
-
 		spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
-
 		dev_dbg(&sep->pdev->dev,
 			"poll; no reply received; returning mask of 0\n");
 		mask = 0;
 	}
 
 end_function:
-
 	dev_dbg(&sep->pdev->dev, "poll: end\n");
 	return mask;
 }
@@ -907,7 +793,6 @@ end_function:
  *	Return the address of the two dwords in memory used for time
  *	setting.
  */
-
 static u32 *sep_time_address(struct sep_device *sep)
 {
 	return sep->shared_addr + SEP_DRIVER_SYSTEM_TIME_MEMORY_OFFSET_IN_BYTES;
@@ -926,8 +811,7 @@ static unsigned long sep_set_time(struct sep_device *sep)
 	u32 *time_addr;	/* address of time as seen by the kernel */
 
 
-	dev_dbg(&sep->pdev->dev,
-		"sep:sep_set_time start\n");
+	dev_dbg(&sep->pdev->dev, "sep:sep_set_time start\n");
 
 	do_gettimeofday(&time);
 
@@ -937,12 +821,9 @@ static unsigned long sep_set_time(struct sep_device *sep)
 	time_addr[0] = SEP_TIME_VAL_TOKEN;
 	time_addr[1] = time.tv_sec;
 
-	dev_dbg(&sep->pdev->dev,
-		"time.tv_sec is %lu\n", time.tv_sec);
-	dev_dbg(&sep->pdev->dev,
-		"time_addr is %p\n", time_addr);
-	dev_dbg(&sep->pdev->dev,
-		"sep->shared_addr is %p\n", sep->shared_addr);
+	dev_dbg(&sep->pdev->dev, "time.tv_sec is %lu\n", time.tv_sec);
+	dev_dbg(&sep->pdev->dev, "time_addr is %p\n", time_addr);
+	dev_dbg(&sep->pdev->dev, "sep->shared_addr is %p\n", sep->shared_addr);
 
 	return time.tv_sec;
 }
@@ -958,14 +839,11 @@ static unsigned long sep_set_time(struct sep_device *sep)
 static int sep_set_caller_id_handler(struct sep_device *sep, u32 arg)
 {
 	void __user *hash;
-	int   error;
+	int   error = 0;
 	int   i;
 	struct caller_id_struct command_args;
 
-	dev_dbg(&sep->pdev->dev,
-		"sep_set_caller_id_handler start\n");
-
-	error = 0;
+	dev_dbg(&sep->pdev->dev, "sep_set_caller_id_handler start\n");
 
 	for (i = 0; i < SEP_CALLER_ID_TABLE_NUM_ENTRIES; i++) {
 		if (sep->caller_id_table[i].pid == 0)
@@ -973,12 +851,9 @@ static int sep_set_caller_id_handler(struct sep_device *sep, u32 arg)
 	}
 
 	if (i == SEP_CALLER_ID_TABLE_NUM_ENTRIES) {
-		dev_warn(&sep->pdev->dev,
-			"no more caller id entries left\n");
-		dev_warn(&sep->pdev->dev,
-			"maximum number is %d\n",
-			SEP_CALLER_ID_TABLE_NUM_ENTRIES);
-
+		dev_warn(&sep->pdev->dev, "no more caller id entries left\n");
+		dev_warn(&sep->pdev->dev, "maximum number is %d\n",
+					SEP_CALLER_ID_TABLE_NUM_ENTRIES);
 		error = -EUSERS;
 		goto end_function;
 	}
@@ -1002,7 +877,7 @@ static int sep_set_caller_id_handler(struct sep_device *sep, u32 arg)
 		command_args.callerIdSizeInBytes);
 
 	if (command_args.callerIdSizeInBytes >
-				SEP_CALLER_ID_HASH_SIZE_IN_BYTES) {
+					SEP_CALLER_ID_HASH_SIZE_IN_BYTES) {
 		error = -EMSGSIZE;
 		goto end_function;
 	}
@@ -1013,8 +888,7 @@ static int sep_set_caller_id_handler(struct sep_device *sep, u32 arg)
 		hash, command_args.callerIdSizeInBytes))
 		error = -EFAULT;
 end_function:
-	dev_dbg(&sep->pdev->dev,
-		"sep_set_caller_id_handler end\n");
+	dev_dbg(&sep->pdev->dev, "sep_set_caller_id_handler end\n");
 	return error;
 }
 
@@ -1030,29 +904,23 @@ static int sep_set_current_caller_id(struct sep_device *sep)
 	int i;
 
 	dev_dbg(&sep->pdev->dev, "sep_set_current_caller_id start\n");
-
 	dev_dbg(&sep->pdev->dev, "current process is %d\n", current->pid);
 
 	/* zero the previous value */
-	memset((void *)(sep->shared_addr +
-		(SEP_CALLER_ID_OFFSET_BYTES)),
-		0,
-		SEP_CALLER_ID_HASH_SIZE_IN_BYTES);
+	memset(sep->shared_addr + SEP_CALLER_ID_OFFSET_BYTES,
+					0, SEP_CALLER_ID_HASH_SIZE_IN_BYTES);
 
 	for (i = 0; i < SEP_CALLER_ID_TABLE_NUM_ENTRIES; i++) {
 		if (sep->caller_id_table[i].pid == current->pid) {
 			dev_dbg(&sep->pdev->dev, "Caller Id found\n");
 
-			memcpy((void *)(sep->shared_addr +
-				(SEP_CALLER_ID_OFFSET_BYTES)),
+			memcpy(sep->shared_addr + SEP_CALLER_ID_OFFSET_BYTES,
 				(void *)(sep->caller_id_table[i].callerIdHash),
 				SEP_CALLER_ID_HASH_SIZE_IN_BYTES);
 			break;
 		}
 	}
-
 	dev_dbg(&sep->pdev->dev, "sep_set_current_caller_id end\n");
-
 	return 0;
 }
 
@@ -1065,7 +933,6 @@ static int sep_set_current_caller_id(struct sep_device *sep)
  *
  *      Note that this function does fall under the ioctl lock
  */
-
 static int sep_send_command_handler(struct sep_device *sep)
 {
 	unsigned long lck_flags;
@@ -1073,13 +940,10 @@ static int sep_send_command_handler(struct sep_device *sep)
 
 	dev_dbg(&sep->pdev->dev, "sep_send_command_handler start\n");
 
-	dev_dbg(&sep->pdev->dev, "calling test and set for "
-		" in_use_flags SEP_SEND_MSG_LOCK_BIT 0\n");
 	if (test_and_set_bit(SEP_SEND_MSG_LOCK_BIT, &sep->in_use_flags)) {
 		error = -EPROTO;
 		goto end_function;
 	}
-
 	sep_set_time(sep);
 
 	/* only Medfield has caller id */
@@ -1093,8 +957,9 @@ static int sep_send_command_handler(struct sep_device *sep)
 	sep->send_ct++;
 	spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
 
-	dev_dbg(&sep->pdev->dev, "sep_send_command_handler"
-		"send_ct %lx reply_ct %lx\n", sep->send_ct, sep->reply_ct);
+	dev_dbg(&sep->pdev->dev,
+		"sep_send_command_handler send_ct %lx reply_ct %lx\n",
+						sep->send_ct, sep->reply_ct);
 
 	/* send interrupt to SEP */
 	sep_write_reg(sep, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x2);
@@ -1156,8 +1021,7 @@ static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
 		SEP_DRIVER_DATA_POOL_ALLOCATION_OFFSET_IN_BYTES +
 		(sep->num_of_data_allocations)*2*sizeof(u32));
 
-	dev_dbg(&sep->pdev->dev,
-		"allocation offset: %x\n",
+	dev_dbg(&sep->pdev->dev, "allocation offset: %x\n",
 		SEP_DRIVER_DATA_POOL_ALLOCATION_OFFSET_IN_BYTES);
 	dev_dbg(&sep->pdev->dev, "data pool token addr is %p\n", token_addr);
 
@@ -1173,7 +1037,7 @@ static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
 	error = copy_to_user((void *)arg, (void *)&command_args,
 		sizeof(struct alloc_struct));
 	if (error) {
-
+		error = -EFAULT;
 		dev_warn(&sep->pdev->dev,
 			"allocate data pool copy to user error\n");
 		goto end_function;
@@ -1189,9 +1053,7 @@ static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
 		(int)sep->data_pool_bytes_allocated);
 
 end_function:
-
-	dev_dbg(&sep->pdev->dev,
-		"sep_allocate_data_pool_memory_handler end\n");
+	dev_dbg(&sep->pdev->dev, "sep_allocate_data_pool_memory_handler end\n");
 	return error;
 }
 
@@ -1216,12 +1078,9 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
 	int in_out_flag)
 
 {
-	/* error */
 	int error = 0;
-
 	/* array of lli */
 	struct sep_lli_entry *lli_array;
-
 	/* map array */
 	struct sep_dma_map *map_array;
 
@@ -1235,11 +1094,9 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
 
 	lli_array = kmalloc(sizeof(struct sep_lli_entry), GFP_ATOMIC);
 	if (!lli_array) {
-
 		error = -ENOMEM;
 		goto end_function;
 	}
-
 	map_array = kmalloc(sizeof(struct sep_dma_map), GFP_ATOMIC);
 	if (!map_array) {
 		error = -ENOMEM;
@@ -1260,8 +1117,7 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
 	lli_array[0].block_size = map_array[0].size;
 
 	dev_dbg(&sep->pdev->dev,
-		"lli_array[0].bus_address is %08lx,"
-		" lli_array[0].block_size is %x\n",
+	"lli_array[0].bus_address is %08lx, lli_array[0].block_size is %x\n",
 		(unsigned long)lli_array[0].bus_address,
 		lli_array[0].block_size);
 
@@ -1279,18 +1135,13 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
 		sep->dma_res_arr[sep->nr_dcb_creat].out_map_array = map_array;
 		sep->dma_res_arr[sep->nr_dcb_creat].out_map_num_entries = 1;
 	}
-
 	goto end_function;
 
 end_function_with_error:
-
 	kfree(lli_array);
 
 end_function:
-
-	dev_dbg(&sep->pdev->dev,
-		"sep_lock_kernel_pages end\n");
-
+	dev_dbg(&sep->pdev->dev, "sep_lock_kernel_pages end\n");
 	return error;
 }
 
@@ -1314,59 +1165,39 @@ static int sep_lock_user_pages(struct sep_device *sep,
 	int in_out_flag)
 
 {
-	/* error */
-	int error;
-
+	int error = 0;
+	u32 count;
+	int result;
 	/* the the page of the end address of the user space buffer */
 	u32 end_page;
-
 	/* the page of the start address of the user space buffer */
 	u32 start_page;
-
 	/* the range in pages */
 	u32 num_pages;
-
-	/* array of pointers ot page */
+	/* array of pointers to page */
 	struct page **page_array;
-
 	/* array of lli */
 	struct sep_lli_entry *lli_array;
-
 	/* map array */
 	struct sep_dma_map *map_array;
-
 	/* direction of the DMA mapping for locked pages */
 	enum dma_data_direction	dir;
 
-	/* count */
-	u32 count;
-
-	/* result */
-	int result;
-
 	dev_dbg(&sep->pdev->dev,
 		"sep_lock_user_pages start\n");
 
-	error = 0;
-
 	/* set start and end pages  and num pages */
 	end_page = (app_virt_addr + data_size - 1) >> PAGE_SHIFT;
 	start_page = app_virt_addr >> PAGE_SHIFT;
 	num_pages = end_page - start_page + 1;
 
-	dev_dbg(&sep->pdev->dev,
-		"app_virt_addr is %x\n", app_virt_addr);
-	dev_dbg(&sep->pdev->dev,
-		"data_size is %x\n", data_size);
-	dev_dbg(&sep->pdev->dev,
-		"start_page is %x\n", start_page);
-	dev_dbg(&sep->pdev->dev,
-		"end_page is %x\n", end_page);
-	dev_dbg(&sep->pdev->dev,
-		"num_pages is %x\n", num_pages);
+	dev_dbg(&sep->pdev->dev, "app_virt_addr is %x\n", app_virt_addr);
+	dev_dbg(&sep->pdev->dev, "data_size is %x\n", data_size);
+	dev_dbg(&sep->pdev->dev, "start_page is %x\n", start_page);
+	dev_dbg(&sep->pdev->dev, "end_page is %x\n", end_page);
+	dev_dbg(&sep->pdev->dev, "num_pages is %x\n", num_pages);
 
-	dev_dbg(&sep->pdev->dev,
-		"starting page_array malloc\n");
+	dev_dbg(&sep->pdev->dev, "starting page_array malloc\n");
 
 	/* allocate array of pages structure pointers */
 	page_array = kmalloc(sizeof(struct page *) * num_pages, GFP_ATOMIC);
@@ -1374,11 +1205,9 @@ static int sep_lock_user_pages(struct sep_device *sep,
 		error = -ENOMEM;
 		goto end_function;
 	}
-
 	map_array = kmalloc(sizeof(struct sep_dma_map) * num_pages, GFP_ATOMIC);
 	if (!map_array) {
-		dev_warn(&sep->pdev->dev,
-			"kmalloc for map_array failed\n");
+		dev_warn(&sep->pdev->dev, "kmalloc for map_array failed\n");
 		error = -ENOMEM;
 		goto end_function_with_error1;
 	}
@@ -1387,15 +1216,12 @@ static int sep_lock_user_pages(struct sep_device *sep,
 		GFP_ATOMIC);
 
 	if (!lli_array) {
-
-		dev_warn(&sep->pdev->dev,
-			"kmalloc for lli_array failed\n");
+		dev_warn(&sep->pdev->dev, "kmalloc for lli_array failed\n");
 		error = -ENOMEM;
 		goto end_function_with_error2;
 	}
 
-	dev_dbg(&sep->pdev->dev,
-		"starting get_user_pages\n");
+	dev_dbg(&sep->pdev->dev, "starting get_user_pages\n");
 
 	/* convert the application virtual address into a set of physical */
 	down_read(&current->mm->mmap_sem);
@@ -1408,15 +1234,13 @@ static int sep_lock_user_pages(struct sep_device *sep,
 
 	/* check the number of pages locked - if not all then exit with error */
 	if (result != num_pages) {
-
 		dev_warn(&sep->pdev->dev,
 			"not all pages locked by get_user_pages\n");
 		error = -ENOMEM;
 		goto end_function_with_error3;
 	}
 
-	dev_dbg(&sep->pdev->dev,
-		"get_user_pages succeeded\n");
+	dev_dbg(&sep->pdev->dev, "get_user_pages succeeded\n");
 
 	/* set direction */
 	if (in_out_flag == SEP_DRIVER_IN_FLAG)
@@ -1441,9 +1265,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
 		lli_array[count].bus_address = (u32)map_array[count].dma_addr;
 		lli_array[count].block_size = PAGE_SIZE;
 
-		dev_warn(&sep->pdev->dev,
-			"lli_array[%x].bus_address is %08lx, \
-			lli_array[%x].block_size is %x\n",
+		dev_warn(&sep->pdev->dev, "lli_array[%x].bus_address is %08lx, lli_array[%x].block_size is %x\n",
 			count, (unsigned long)lli_array[count].bus_address,
 			count, lli_array[count].block_size);
 	}
@@ -1460,20 +1282,17 @@ static int sep_lock_user_pages(struct sep_device *sep,
 			PAGE_SIZE - (app_virt_addr & (~PAGE_MASK));
 
 	dev_dbg(&sep->pdev->dev,
-		"lli_array[0].bus_address is %08lx, \
-		lli_array[0].block_size is %x\n",
+		"lli_array[0].bus_address is %08lx, lli_array[0].block_size is %x\n",
 		(unsigned long)lli_array[count].bus_address,
 		lli_array[count].block_size);
 
 	/* check the size of the last page */
 	if (num_pages > 1) {
-
 		lli_array[num_pages - 1].block_size =
 			(app_virt_addr + data_size) & (~PAGE_MASK);
 
 		dev_warn(&sep->pdev->dev,
-			"lli_array[%x].bus_address is %08lx, \
-			lli_array[%x].block_size is %x\n",
+			"lli_array[%x].bus_address is %08lx, lli_array[%x].block_size is %x\n",
 			num_pages - 1,
 			(unsigned long)lli_array[count].bus_address,
 			num_pages - 1,
@@ -1483,47 +1302,35 @@ static int sep_lock_user_pages(struct sep_device *sep,
 	/* set output params acording to the in_out flag */
 	if (in_out_flag == SEP_DRIVER_IN_FLAG) {
 		*lli_array_ptr = lli_array;
-		sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages =
-			num_pages;
-		sep->dma_res_arr[sep->nr_dcb_creat].in_page_array =
-			page_array;
-		sep->dma_res_arr[sep->nr_dcb_creat].in_map_array =
-			map_array;
+		sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages = num_pages;
+		sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = page_array;
+		sep->dma_res_arr[sep->nr_dcb_creat].in_map_array = map_array;
 		sep->dma_res_arr[sep->nr_dcb_creat].in_map_num_entries =
-			num_pages;
+								num_pages;
 	} else {
 		*lli_array_ptr = lli_array;
-		sep->dma_res_arr[sep->nr_dcb_creat].out_num_pages =
-			num_pages;
+		sep->dma_res_arr[sep->nr_dcb_creat].out_num_pages = num_pages;
 		sep->dma_res_arr[sep->nr_dcb_creat].out_page_array =
-			page_array;
-		sep->dma_res_arr[sep->nr_dcb_creat].out_map_array =
-			map_array;
+								page_array;
+		sep->dma_res_arr[sep->nr_dcb_creat].out_map_array = map_array;
 		sep->dma_res_arr[sep->nr_dcb_creat].out_map_num_entries =
-			num_pages;
+								num_pages;
 	}
-
 	goto end_function;
 
 end_function_with_error3:
-
 	/* free lli array */
 	kfree(lli_array);
 
 end_function_with_error2:
-
 	kfree(map_array);
 
 end_function_with_error1:
-
 	/* free page array */
 	kfree(page_array);
 
 end_function:
-
-	dev_dbg(&sep->pdev->dev,
-		"sep_lock_user_pages end\n");
-
+	dev_dbg(&sep->pdev->dev, "sep_lock_user_pages end\n");
 	return error;
 }
 
@@ -1544,16 +1351,12 @@ static u32 sep_calculate_lli_table_max_size(struct sep_device *sep,
 	u32 num_array_entries,
 	u32 *last_table_flag)
 {
+	u32 counter;
 	/* table data size */
-	u32 table_data_size;
-
+	u32 table_data_size = 0;
 	/* data size for the next table */
 	u32 next_table_data_size;
 
-	/* counter */
-	u32 counter;
-
-	table_data_size = 0;
 	*last_table_flag = 0;
 
 	/*
@@ -1562,7 +1365,7 @@ static u32 sep_calculate_lli_table_max_size(struct sep_device *sep,
 	 */
 	for (counter = 0;
 		(counter < (SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP - 1)) &&
-		(counter < num_array_entries); counter++)
+			(counter < num_array_entries); counter++)
 		table_data_size += lli_in_array_ptr[counter].block_size;
 
 	/*
@@ -1571,7 +1374,6 @@ static u32 sep_calculate_lli_table_max_size(struct sep_device *sep,
 	 * and no need to check the block alignment
 	 */
 	if (counter == num_array_entries) {
-
 		/* set the last table flag */
 		*last_table_flag = 1;
 		goto end_function;
@@ -1584,11 +1386,8 @@ static u32 sep_calculate_lli_table_max_size(struct sep_device *sep,
 	 */
 	next_table_data_size = 0;
 	for (; counter < num_array_entries; counter++) {
-
 		next_table_data_size += lli_in_array_ptr[counter].block_size;
-
 		if (next_table_data_size >= SEP_DRIVER_MIN_DATA_SIZE_PER_TABLE)
-
 			break;
 	}
 
@@ -1603,11 +1402,9 @@ static u32 sep_calculate_lli_table_max_size(struct sep_device *sep,
 		table_data_size -= (SEP_DRIVER_MIN_DATA_SIZE_PER_TABLE -
 			next_table_data_size);
 
-	dev_dbg(&sep->pdev->dev,
-		"table data size is %x\n", table_data_size);
-
+	dev_dbg(&sep->pdev->dev, "table data size is %x\n",
+							table_data_size);
 end_function:
-
 	return table_data_size;
 }
 
@@ -1632,20 +1429,17 @@ static void sep_build_lli_table(struct sep_device *sep,
 {
 	/* current table data size */
 	u32 curr_table_data_size;
-
 	/* counter of lli array entry */
 	u32 array_counter;
 
-	dev_dbg(&sep->pdev->dev,
-		"sep_build_lli_table start\n");
+	dev_dbg(&sep->pdev->dev, "sep_build_lli_table start\n");
 
 	/* init currrent table data size and lli array entry counter */
 	curr_table_data_size = 0;
 	array_counter = 0;
 	*num_table_entries_ptr = 1;
 
-	dev_dbg(&sep->pdev->dev,
-		"table_data_size is %x\n", table_data_size);
+	dev_dbg(&sep->pdev->dev, "table_data_size is %x\n", table_data_size);
 
 	/* fill the table till table size reaches the needed amount */
 	while (curr_table_data_size < table_data_size) {
@@ -1660,18 +1454,15 @@ static void sep_build_lli_table(struct sep_device *sep,
 
 		curr_table_data_size += lli_array_ptr[array_counter].block_size;
 
-		dev_dbg(&sep->pdev->dev,
-			"lli_table_ptr is %p\n", lli_table_ptr);
-		dev_dbg(&sep->pdev->dev,
-			"lli_table_ptr->bus_address is %08lx\n",
-			(unsigned long)lli_table_ptr->bus_address);
-		dev_dbg(&sep->pdev->dev,
-			"lli_table_ptr->block_size is %x\n",
+		dev_dbg(&sep->pdev->dev, "lli_table_ptr is %p\n",
+								lli_table_ptr);
+		dev_dbg(&sep->pdev->dev, "lli_table_ptr->bus_address is %08lx\n",
+				(unsigned long)lli_table_ptr->bus_address);
+		dev_dbg(&sep->pdev->dev, "lli_table_ptr->block_size is %x\n",
 			lli_table_ptr->block_size);
 
 		/* check for overflow of the table data */
 		if (curr_table_data_size > table_data_size) {
-
 			dev_dbg(&sep->pdev->dev,
 				"curr_table_data_size too large\n");
 
@@ -1686,15 +1477,13 @@ static void sep_build_lli_table(struct sep_device *sep,
 			/* update the block size left in the lli array */
 			lli_array_ptr[array_counter].block_size =
 				(curr_table_data_size - table_data_size);
-
 		} else
-
 			/* advance to the next entry in the lli_array */
 			array_counter++;
 
 		dev_dbg(&sep->pdev->dev,
 			"lli_table_ptr->bus_address is %08lx\n",
-			(unsigned long)lli_table_ptr->bus_address);
+				(unsigned long)lli_table_ptr->bus_address);
 		dev_dbg(&sep->pdev->dev,
 			"lli_table_ptr->block_size is %x\n",
 			lli_table_ptr->block_size);
@@ -1707,26 +1496,19 @@ static void sep_build_lli_table(struct sep_device *sep,
 	lli_table_ptr->bus_address = 0xffffffff;
 	lli_table_ptr->block_size = 0;
 
-	dev_dbg(&sep->pdev->dev,
-		"lli_table_ptr is %p\n", lli_table_ptr);
-	dev_dbg(&sep->pdev->dev,
-		"lli_table_ptr->bus_address is %08lx\n",
-		(unsigned long)lli_table_ptr->bus_address);
-	dev_dbg(&sep->pdev->dev,
-		"lli_table_ptr->block_size is %x\n",
-		lli_table_ptr->block_size);
+	dev_dbg(&sep->pdev->dev, "lli_table_ptr is %p\n", lli_table_ptr);
+	dev_dbg(&sep->pdev->dev, "lli_table_ptr->bus_address is %08lx\n",
+				(unsigned long)lli_table_ptr->bus_address);
+	dev_dbg(&sep->pdev->dev, "lli_table_ptr->block_size is %x\n",
+						lli_table_ptr->block_size);
 
 	/* set the output parameter */
 	*num_processed_entries_ptr += array_counter;
 
-	dev_dbg(&sep->pdev->dev,
-		"num_processed_entries_ptr is %x\n",
+	dev_dbg(&sep->pdev->dev, "num_processed_entries_ptr is %x\n",
 		*num_processed_entries_ptr);
 
-	dev_dbg(&sep->pdev->dev,
-		"sep_build_lli_table end\n");
-
-	return;
+	dev_dbg(&sep->pdev->dev, "sep_build_lli_table end\n");
 }
 
 /**
@@ -1742,16 +1524,12 @@ static void sep_build_lli_table(struct sep_device *sep,
 static dma_addr_t sep_shared_area_virt_to_bus(struct sep_device *sep,
 	void *virt_address)
 {
-	dev_dbg(&sep->pdev->dev,
-		"sh virt to phys v %08lx\n",
-		(unsigned long)virt_address);
-	dev_dbg(&sep->pdev->dev,
-		"sh virt to phys p %08lx\n",
-		(unsigned long)(sep->shared_bus
-		+ (virt_address - sep->shared_addr)));
+	dev_dbg(&sep->pdev->dev, "sh virt to phys v %p\n", virt_address);
+	dev_dbg(&sep->pdev->dev, "sh virt to phys p %08lx\n",
+		(unsigned long)
+		sep->shared_bus + (virt_address - sep->shared_addr));
 
-	return sep->shared_bus
-		+ (size_t)(virt_address - sep->shared_addr);
+	return sep->shared_bus + (size_t)(virt_address - sep->shared_addr);
 }
 
 /**
@@ -1764,18 +1542,14 @@ static dma_addr_t sep_shared_area_virt_to_bus(struct sep_device *sep,
  *	externa RAM device (ioremapped), or on the system RAM
  *	This implementation is for the external RAM
  */
-
 static void *sep_shared_area_bus_to_virt(struct sep_device *sep,
 	dma_addr_t bus_address)
 {
-	dev_dbg(&sep->pdev->dev,
-		"shared bus to virt b=%x v=%x\n",
-		(u32)bus_address,
-		(u32)(sep->shared_addr +
+	dev_dbg(&sep->pdev->dev, "shared bus to virt b=%x v=%x\n",
+		(u32)bus_address, (u32)(sep->shared_addr +
 			(size_t)(bus_address - sep->shared_bus)));
 
-	return sep->shared_addr
-		+ (size_t)(bus_address - sep->shared_bus);
+	return sep->shared_addr	+ (size_t)(bus_address - sep->shared_bus);
 }
 
 /**
@@ -1792,20 +1566,17 @@ static void sep_debug_print_lli_tables(struct sep_device *sep,
 	unsigned long num_table_entries,
 	unsigned long table_data_size)
 {
-	unsigned long table_count = 0;
+	unsigned long table_count = 1;
 	unsigned long entries_count = 0;
 
-	dev_dbg(&sep->pdev->dev,
-		"sep_debug_print_lli_tables start\n");
+	dev_dbg(&sep->pdev->dev, "sep_debug_print_lli_tables start\n");
 
-	table_count = 1;
 	while ((unsigned long) lli_table_ptr != 0xffffffff) {
 		dev_dbg(&sep->pdev->dev,
 			"lli table %08lx, table_data_size is %lu\n",
 			table_count, table_data_size);
-		dev_dbg(&sep->pdev->dev,
-			"num_table_entries is %lu\n",
-			num_table_entries);
+		dev_dbg(&sep->pdev->dev, "num_table_entries is %lu\n",
+							num_table_entries);
 
 		/* print entries of the table (without info entry) */
 		for (entries_count = 0; entries_count < num_table_entries;
@@ -1820,7 +1591,6 @@ static void sep_debug_print_lli_tables(struct sep_device *sep,
 				(unsigned long)lli_table_ptr->bus_address,
 				lli_table_ptr->block_size);
 		}
-
 		/* point to the info entry */
 		lli_table_ptr--;
 
@@ -1850,8 +1620,7 @@ static void sep_debug_print_lli_tables(struct sep_device *sep,
 
 		table_count++;
 	}
-	dev_dbg(&sep->pdev->dev,
-			"sep_debug_print_lli_tables end\n");
+	dev_dbg(&sep->pdev->dev, "sep_debug_print_lli_tables end\n");
 }
 
 
@@ -1863,7 +1632,6 @@ static void sep_debug_print_lli_tables(struct sep_device *sep,
  *	@table_data_size_ptr: point to table data size
  *
  *	This function creates empty lli tables when there is no data
-
  */
 static void sep_prepare_empty_lli_table(struct sep_device *sep,
 		dma_addr_t *lli_table_addr_ptr,
@@ -1878,9 +1646,8 @@ static void sep_prepare_empty_lli_table(struct sep_device *sep,
 	lli_table_ptr =
 		(struct sep_lli_entry *)(sep->shared_addr +
 		SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
-		sep->num_lli_tables_created *
-		sizeof(struct sep_lli_entry) *
-		SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);
+		sep->num_lli_tables_created * sizeof(struct sep_lli_entry) *
+			SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);
 
 	lli_table_ptr->bus_address = 0;
 	lli_table_ptr->block_size = 0;
@@ -1931,43 +1698,29 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 	u32 *table_data_size_ptr,
 	bool is_kva)
 {
+	int error = 0;
 	/* pointer to the info entry of the table - the last entry */
 	struct sep_lli_entry *info_entry_ptr;
-
-	/* array of pointers ot page */
+	/* array of pointers to page */
 	struct sep_lli_entry *lli_array_ptr;
-
 	/* points to the first entry to be processed in the lli_in_array */
 	u32 current_entry = 0;
-
 	/* num entries in the virtual buffer */
 	u32 sep_lli_entries = 0;
-
 	/* lli table pointer */
 	struct sep_lli_entry *in_lli_table_ptr;
-
 	/* the total data in one table */
 	u32 table_data_size = 0;
-
 	/* flag for last table */
 	u32 last_table_flag = 0;
-
 	/* number of entries in lli table */
 	u32 num_entries_in_table = 0;
-
 	/* next table address */
 	u32 lli_table_alloc_addr = 0;
 
-	/* error */
-	int error = 0;
-
-	dev_dbg(&sep->pdev->dev,
-		"sep_prepare_input_dma_table start\n");
-
-	dev_dbg(&sep->pdev->dev,
-		"data_size is %x\n", data_size);
-	dev_dbg(&sep->pdev->dev,
-		"block_size is %x\n", block_size);
+	dev_dbg(&sep->pdev->dev, "sep_prepare_input_dma_table start\n");
+	dev_dbg(&sep->pdev->dev, "data_size is %x\n", data_size);
+	dev_dbg(&sep->pdev->dev, "block_size is %x\n", block_size);
 
 	/* initialize the pages pointers */
 	sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = 0;
@@ -1976,29 +1729,22 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 	/* set the kernel address for first table to be allocated */
 	lli_table_alloc_addr = (u32)(sep->shared_addr +
 		SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
-		sep->num_lli_tables_created *
-		sizeof(struct sep_lli_entry) *
+		sep->num_lli_tables_created * sizeof(struct sep_lli_entry) *
 		SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);
 
 	if (data_size == 0) {
-
 		/* special case  - create meptu table - 2 entries, zero data */
 		sep_prepare_empty_lli_table(sep, lli_table_ptr,
-			num_entries_ptr,
-			table_data_size_ptr);
-
+				num_entries_ptr, table_data_size_ptr);
 		goto update_dcb_counter;
 	}
 
 	/* check if the pages are in Kernel Virtual Address layout */
 	if (is_kva == true)
-
 		/* lock the pages in the kernel */
 		error = sep_lock_kernel_pages(sep, app_virt_addr,
 			data_size, &lli_array_ptr, SEP_DRIVER_IN_FLAG);
-
 	else
-
 		/*
 		 * lock the pages of the user buffer
 		 * and translate them to pages
@@ -2009,15 +1755,13 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 	if (error)
 		goto end_function;
 
-	dev_dbg(&sep->pdev->dev,
-		"output sep_in_num_pages is %x\n",
+	dev_dbg(&sep->pdev->dev, "output sep_in_num_pages is %x\n",
 		sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages);
 
 	current_entry = 0;
 	info_entry_ptr = 0;
 
-	sep_lli_entries =
-		sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages;
+	sep_lli_entries = sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages;
 
 	/* loop till all the entries in in array are not processed */
 	while (current_entry < sep_lli_entries) {
@@ -2048,17 +1792,16 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 			(sep_lli_entries - current_entry),
 			&last_table_flag);
 
-		/**
+		/*
 		 * if this is not the last table -
 		 * then allign it to the block size
 		 */
 		if (!last_table_flag)
 			table_data_size =
-			(table_data_size / block_size) * block_size;
+				(table_data_size / block_size) * block_size;
 
-		dev_dbg(&sep->pdev->dev,
-			"output table_data_size is %x\n",
-			table_data_size);
+		dev_dbg(&sep->pdev->dev, "output table_data_size is %x\n",
+							table_data_size);
 
 		/* construct input lli table */
 		sep_build_lli_table(sep, &lli_array_ptr[current_entry],
@@ -2077,52 +1820,38 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 				"output lli_table_in_ptr is %08lx\n",
 				(unsigned long)*lli_table_ptr);
 
-		}
-
-		else {
-
+		} else {
 			/* update the info entry of the previous in table */
 			info_entry_ptr->bus_address =
 				sep_shared_area_virt_to_bus(sep,
-				in_lli_table_ptr);
-				info_entry_ptr->block_size =
+							in_lli_table_ptr);
+			info_entry_ptr->block_size = 
 				((num_entries_in_table) << 24) |
 				(table_data_size);
 		}
-
 		/* save the pointer to the info entry of the current tables */
 		info_entry_ptr = in_lli_table_ptr + num_entries_in_table - 1;
-
 	}
-
 	/* print input tables */
 	sep_debug_print_lli_tables(sep, (struct sep_lli_entry *)
 		sep_shared_area_bus_to_virt(sep, *lli_table_ptr),
-		*num_entries_ptr,
-		*table_data_size_ptr);
-
+		*num_entries_ptr, *table_data_size_ptr);
 	/* the array of the pages */
 	kfree(lli_array_ptr);
 
 update_dcb_counter:
-
 	/* update dcb counter */
 	sep->nr_dcb_creat++;
-
 	goto end_function;
 
 end_function_error:
-
 	/* free all the allocated resources */
 	kfree(sep->dma_res_arr[sep->nr_dcb_creat].in_map_array);
 	kfree(lli_array_ptr);
 	kfree(sep->dma_res_arr[sep->nr_dcb_creat].in_page_array);
 
 end_function:
-
-	dev_dbg(&sep->pdev->dev,
-		"sep_prepare_input_dma_table end\n");
-
+	dev_dbg(&sep->pdev->dev, "sep_prepare_input_dma_table end\n");
 	return error;
 
 }
@@ -2161,45 +1890,32 @@ static int sep_construct_dma_tables_from_lli(
 {
 	/* points to the area where next lli table can be allocated */
 	u32 lli_table_alloc_addr = 0;
-
 	/* input lli table */
 	struct sep_lli_entry *in_lli_table_ptr = 0;
-
 	/* output lli table */
 	struct sep_lli_entry *out_lli_table_ptr = 0;
-
 	/* pointer to the info entry of the table - the last entry */
 	struct sep_lli_entry *info_in_entry_ptr = 0;
-
 	/* pointer to the info entry of the table - the last entry */
 	struct sep_lli_entry *info_out_entry_ptr = 0;
-
 	/* points to the first entry to be processed in the lli_in_array */
 	u32 current_in_entry = 0;
-
 	/* points to the first entry to be processed in the lli_out_array */
 	u32 current_out_entry = 0;
-
 	/* max size of the input table */
 	u32 in_table_data_size = 0;
-
 	/* max size of the output table */
 	u32 out_table_data_size = 0;
-
 	/* flag te signifies if this is the last tables build */
 	u32 last_table_flag = 0;
-
 	/* the data size that should be in table */
 	u32 table_data_size = 0;
-
 	/* number of etnries in the input table */
 	u32 num_entries_in_table = 0;
-
 	/* number of etnries in the output table */
 	u32 num_entries_out_table = 0;
 
-	dev_dbg(&sep->pdev->dev,
-		"sep_construct_dma_tables_from_lli start\n");
+	dev_dbg(&sep->pdev->dev, "sep_construct_dma_tables_from_lli start\n");
 
 	/* initiate to point after the message area */
 	lli_table_alloc_addr = (u32)(sep->shared_addr +
@@ -2210,7 +1926,6 @@ static int sep_construct_dma_tables_from_lli(
 
 	/* loop till all the entries in in array are not processed */
 	while (current_in_entry < sep_in_lli_entries) {
-
 		/* set the new input and output tables */
 		in_lli_table_ptr =
 			(struct sep_lli_entry *)lli_table_alloc_addr;
@@ -2229,8 +1944,7 @@ static int sep_construct_dma_tables_from_lli(
 			SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
 			SYNCHRONIC_DMA_TABLES_AREA_SIZE_BYTES)) {
 
-			dev_warn(&sep->pdev->dev,
-				"dma table limit overrun\n");
+			dev_warn(&sep->pdev->dev, "dma table limit overrun\n");
 			return -ENOMEM;
 		}
 
@@ -2281,8 +1995,8 @@ static int sep_construct_dma_tables_from_lli(
 				block_size;
 		}
 
-		dev_dbg(&sep->pdev->dev,
-			"table_data_size is %x\n", table_data_size);
+		dev_dbg(&sep->pdev->dev, "table_data_size is %x\n",
+							table_data_size);
 
 		/* construct input lli table */
 		sep_build_lli_table(sep, &lli_in_array[current_in_entry],
@@ -2380,9 +2094,7 @@ static int sep_construct_dma_tables_from_lli(
 	*out_num_entries_ptr,
 	*table_data_size_ptr);
 
-	dev_dbg(&sep->pdev->dev,
-		"sep_construct_dma_tables_from_lli end\n");
-
+	dev_dbg(&sep->pdev->dev, "sep_construct_dma_tables_from_lli end\n");
 	return 0;
 }
 
@@ -2418,20 +2130,15 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
 	bool is_kva)
 
 {
+	int error = 0;
 	/* array of pointers of page */
 	struct sep_lli_entry *lli_in_array;
-
 	/* array of pointers of page */
 	struct sep_lli_entry *lli_out_array;
 
-	/* error */
-	int error = 0;
-
-	dev_dbg(&sep->pdev->dev,
-		"sep_prepare_input_output_dma_table start\n");
+	dev_dbg(&sep->pdev->dev, "sep_prepare_input_output_dma_table start\n");
 
 	if (data_size == 0) {
-
 		/* prepare empty table for input and output */
 		sep_prepare_empty_lli_table(sep, lli_table_in_ptr,
 			in_num_entries_ptr, table_data_size_ptr);
@@ -2471,8 +2178,8 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
 		error = sep_lock_user_pages(sep, app_virt_in_addr,
 				data_size, &lli_in_array, SEP_DRIVER_IN_FLAG);
 		if (error) {
-			dev_warn(&sep->pdev->dev, "sep_lock_user_pages for "
-					"input virtual buffer failed\n");
+			dev_warn(&sep->pdev->dev, 
+				"sep_lock_user_pages for input virtual buffer failed\n");
 			goto end_function;
 		}
 
@@ -2480,20 +2187,17 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
 			data_size, &lli_out_array, SEP_DRIVER_OUT_FLAG);
 
 		if (error) {
-			dev_warn(&sep->pdev->dev, "sep_lock_user_pages for "
-					"output virtual buffer failed\n");
+			dev_warn(&sep->pdev->dev,
+				"sep_lock_user_pages for output virtual buffer failed\n");
 			goto end_function_free_lli_in;
 		}
 	}
 
-	dev_dbg(&sep->pdev->dev,
-		"sep_in_num_pages is %x\n",
+	dev_dbg(&sep->pdev->dev, "sep_in_num_pages is %x\n",
 		sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages);
-	dev_dbg(&sep->pdev->dev,
-		"sep_out_num_pages is %x\n",
+	dev_dbg(&sep->pdev->dev, "sep_out_num_pages is %x\n",
 		sep->dma_res_arr[sep->nr_dcb_creat].out_num_pages);
-	dev_dbg(&sep->pdev->dev,
-		"SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP is %x\n",
+	dev_dbg(&sep->pdev->dev, "SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP is %x\n",
 		SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);
 
 	/* call the fucntion that creates table from the lli arrays */
@@ -2514,38 +2218,32 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
 	kfree(lli_in_array);
 
 update_dcb_counter:
-
 	/* update dcb counter */
 	sep->nr_dcb_creat++;
-
 	/* fall through - free the lli entry arrays */
-	dev_dbg(&sep->pdev->dev,
-		"in_num_entries_ptr is %08x\n", *in_num_entries_ptr);
-	dev_dbg(&sep->pdev->dev,
-		"out_num_entries_ptr is %08x\n", *out_num_entries_ptr);
-	dev_dbg(&sep->pdev->dev,
-		"table_data_size_ptr is %08x\n", *table_data_size_ptr);
+	dev_dbg(&sep->pdev->dev, "in_num_entries_ptr is %08x\n",
+						*in_num_entries_ptr);
+	dev_dbg(&sep->pdev->dev, "out_num_entries_ptr is %08x\n",
+						*out_num_entries_ptr);
+	dev_dbg(&sep->pdev->dev, "table_data_size_ptr is %08x\n",
+						*table_data_size_ptr);
 
 	goto end_function;
 
 end_function_with_error:
-
 	kfree(sep->dma_res_arr[sep->nr_dcb_creat].out_map_array);
 	kfree(sep->dma_res_arr[sep->nr_dcb_creat].out_page_array);
 	kfree(lli_out_array);
 
 
 end_function_free_lli_in:
-
 	kfree(sep->dma_res_arr[sep->nr_dcb_creat].in_map_array);
 	kfree(sep->dma_res_arr[sep->nr_dcb_creat].in_page_array);
 	kfree(lli_in_array);
 
 end_function:
-
 	dev_dbg(&sep->pdev->dev,
-		"sep_prepare_input_output_dma_table"
-		" end result = %d\n", error);
+		"sep_prepare_input_output_dma_table end result = %d\n", error);
 
 	return error;
 
@@ -2576,35 +2274,26 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 	bool            isapplet,
 	bool		is_kva)
 {
-	/* error */
 	int error = 0;
-
 	/* size of tail */
 	u32 tail_size = 0;
-
 	/* address of the created dcb table */
 	struct sep_dcblock *dcb_table_ptr = 0;
-
 	/* the physical address of the first input DMA table */
 	dma_addr_t in_first_mlli_address = 0;
-
 	/* number of entries in the first input DMA table */
 	u32  in_first_num_entries = 0;
-
 	/* the physical address of the first output DMA table */
 	dma_addr_t  out_first_mlli_address = 0;
-
 	/* number of entries in the first output DMA table */
 	u32  out_first_num_entries = 0;
-
 	/* data in the first input/output table */
 	u32  first_data_size = 0;
 
-	dev_dbg(&sep->pdev->dev,
-		"prepare_input_output_dma_table_in_dcb start\n");
+	dev_dbg(&sep->pdev->dev, "prepare_input_output_dma_table_in_dcb start\n");
 
 	if (sep->nr_dcb_creat == SEP_MAX_NUM_SYNC_DMA_OPS) {
-		/*No more DCBS to allocate*/
+		/* No more DCBS to allocate */
 		dev_warn(&sep->pdev->dev, "no more dcb's available\n");
 		error = -ENOSPC;
 		goto end_function;
@@ -2627,17 +2316,12 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 
 	if (isapplet == true) {
 		tail_size = data_in_size % block_size;
-
 		if (tail_size) {
-
 			if (data_in_size < tail_block_size) {
-				dev_warn(&sep->pdev->dev,
-					"data in size smaller than tail"
-					"  block size\n");
+				dev_warn(&sep->pdev->dev, "data in size smaller than tail block size\n");
 				error = -ENOSPC;
 				goto end_function;
 			}
-
 			if (tail_block_size)
 				/*
 				 * case the tail size should be
@@ -2645,7 +2329,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 				 */
 				tail_size = tail_block_size +
 					((data_in_size -
-					tail_block_size) % block_size);
+						tail_block_size) % block_size);
 		}
 
 		/* check if there is enough data for dma operation */
@@ -2653,9 +2337,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 			if (is_kva == true) {
 				memcpy(dcb_table_ptr->tail_data,
 					(void *)app_in_address, data_in_size);
-			}
-
-			else {
+			} else {
 				if (copy_from_user(dcb_table_ptr->tail_data,
 					(void __user *)app_in_address,
 					data_in_size)) {
@@ -2669,7 +2351,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 			/* set the output user-space address for mem2mem op */
 			if (app_out_address)
 				dcb_table_ptr->out_vr_tail_pt =
-					(u32)app_out_address;
+							(u32)app_out_address;
 
 			/*
 			 * Update both data length parameters in order to avoid
@@ -2679,15 +2361,12 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 			tail_size = 0x0;
 			data_in_size = 0x0;
 		}
-
 		if (tail_size) {
 			if (is_kva == true) {
 				memcpy(dcb_table_ptr->tail_data,
 					(void *)(app_in_address + data_in_size -
 					tail_size), tail_size);
-			}
-
-			else {
+			} else {
 				/* we have tail data - copy it to dcb */
 				if (copy_from_user(dcb_table_ptr->tail_data,
 					(void *)(app_in_address +
@@ -2696,17 +2375,16 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 					goto end_function;
 				}
 			}
-
 			if (app_out_address)
 				/*
-				 * Caclulate the output address
+				 * Calculate the output address
 				 * according to tail data size
 				 */
 				dcb_table_ptr->out_vr_tail_pt =
 					app_out_address + data_in_size
 					- tail_size;
 
-			/*save the real tail data size*/
+			/* Save the real tail data size */
 			dcb_table_ptr->tail_data_size = tail_size;
 			/*
 			 * Update the data size without the tail
@@ -2715,7 +2393,6 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 			data_in_size = (data_in_size - tail_size);
 		}
 	}
-
 	/* check if we need to build only input table or input/output */
 	if (app_out_address) {
 		/* prepare input/output tables */
@@ -2730,9 +2407,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 			&out_first_num_entries,
 			&first_data_size,
 			is_kva);
-	}
-
-	else {
+	} else {
 		/* prepare input tables */
 		error = sep_prepare_input_dma_table(sep,
 			app_in_address,
@@ -2745,8 +2420,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 	}
 
 	if (error) {
-		dev_warn(&sep->pdev->dev, "prepare dma table call failed"
-			" from prepare dcb call\n");
+		dev_warn(&sep->pdev->dev, "prepare dma table call failed from prepare dcb call\n");
 		goto end_function;
 	}
 
@@ -2759,7 +2433,6 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 	dcb_table_ptr->output_mlli_data_size = first_data_size;
 
 end_function:
-
 	dev_dbg(&sep->pdev->dev,
 		"sep_prepare_input_output_dma_table_in_dcb end\n");
 	return error;
@@ -2788,28 +2461,22 @@ static int sep_create_sync_dma_tables_handler(struct sep_device *sep,
 		"sep_create_sync_dma_tables_handler start\n");
 
 	if (copy_from_user(&command_args, (void __user *)arg,
-		sizeof(struct bld_syn_tab_struct))) {
+					sizeof(struct bld_syn_tab_struct))) {
 		error = -EFAULT;
-		dev_warn(&sep->pdev->dev, "create dma tables;"
-			" copy_from_user fails\n");
 		goto end_function;
 	}
 
-	dev_dbg(&sep->pdev->dev,
-		"app_in_address is %08llx\n", command_args.app_in_address);
-	dev_dbg(&sep->pdev->dev,
-		"app_out_address is %08llx\n", command_args.app_out_address);
-	dev_dbg(&sep->pdev->dev,
-		"data_size is %u\n", command_args.data_in_size);
-	dev_dbg(&sep->pdev->dev,
-		"block_size is %u\n", command_args.block_size);
+	dev_dbg(&sep->pdev->dev, "app_in_address is %08llx\n",
+						command_args.app_in_address);
+	dev_dbg(&sep->pdev->dev, "app_out_address is %08llx\n",
+						command_args.app_out_address);
+	dev_dbg(&sep->pdev->dev, "data_size is %u\n",
+						command_args.data_in_size);
+	dev_dbg(&sep->pdev->dev, "block_size is %u\n",
+						command_args.block_size);
 
 	/* validate user parameters */
 	if (!command_args.app_in_address) {
-
-		dev_warn(&sep->pdev->dev,
-			"params validation error\n");
-
 		error = -EINVAL;
 		goto end_function;
 	}
@@ -2824,7 +2491,6 @@ static int sep_create_sync_dma_tables_handler(struct sep_device *sep,
 		false);
 
 end_function:
-
 	dev_dbg(&sep->pdev->dev, "sep_create_sync_dma_tables_handler end\n");
 	return error;
 }
@@ -2840,17 +2506,14 @@ end_function:
 static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
 	bool is_kva)
 {
-
 	int i = 0;
 	int error = 0;
 	int error_temp = 0;
-
 	struct sep_dcblock *dcb_table_ptr;
 
 	dev_dbg(&sep->pdev->dev, "sep_free_dma_tables_and_dcb start\n");
 
 	if (isapplet == true) {
-
 		/* set pointer to first dcb table */
 		dcb_table_ptr = (struct sep_dcblock *)
 			(sep->shared_addr +
@@ -2858,30 +2521,25 @@ static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
 
 		/* go over each dcb and see if tail pointer must be updated */
 		for (i = 0; i < sep->nr_dcb_creat; i++, dcb_table_ptr++) {
-
 			if (dcb_table_ptr->out_vr_tail_pt) {
-
 				if (is_kva == true) {
 					memcpy((void *)dcb_table_ptr->out_vr_tail_pt,
 						dcb_table_ptr->tail_data,
 						dcb_table_ptr->tail_data_size);
-				}
-
-				else {
+				} else {
 					error_temp = copy_to_user(
 						(void *)dcb_table_ptr->out_vr_tail_pt,
 						dcb_table_ptr->tail_data,
 						dcb_table_ptr->tail_data_size);
 				}
-
 				if (error_temp) {
 					/* release the dma resource */
-					error = error_temp;
+					error = -EFAULT;
+					break;
 				}
 			}
 		}
 	}
-
 	/* free the output pages, if any */
 	sep_free_dma_table_data_handler(sep);
 
@@ -2901,9 +2559,7 @@ static int sep_get_static_pool_addr_handler(struct sep_device *sep,
 	unsigned long arg)
 {
 	struct stat_pool_addr_struct command_args;
-
 	u32 *static_pool_addr = 0;
-
 	unsigned long addr_hold;
 
 	dev_dbg(&sep->pdev->dev, "sep_get_static_pool_addr_handler start\n");
@@ -3013,22 +2669,18 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 	struct init_struct command_args;
 
 	dev_dbg(&sep->pdev->dev, "sep_init_handler start\n");
-	error = 0;
 
 	/* make sure that we have not initialized already */
 	reg_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
 
 	if (reg_val != 0x2) {
 		error = SEP_ALREADY_INITIALIZED_ERR;
-		dev_warn(&sep->pdev->dev,
-			"init; device already initialized\n");
+		dev_warn(&sep->pdev->dev, "init; device already initialized\n");
 		goto end_function;
 	}
 
 	/* only root can initialize */
 	if (!capable(CAP_SYS_ADMIN)) {
-		dev_warn(&sep->pdev->dev,
-			"init; only root can init\n");
 		error = -EACCES;
 		goto end_function;
 	}
@@ -3038,17 +2690,13 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 		sizeof(struct init_struct));
 
 	if (error) {
-		dev_warn(&sep->pdev->dev,
-			"init; copy_from_user failed %x\n", error);
+		error = -EFAULT;
 		goto end_function;
 	}
 
 	/* validate parameters */
 	if (!command_args.message_addr || !command_args.sep_sram_addr ||
 		command_args.message_size_in_words > 14) {
-
-		dev_warn(&sep->pdev->dev,
-			"init; parameter error\n");
 		error = -EINVAL;
 		goto end_function;
 	}
@@ -3060,9 +2708,7 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 		command_args.message_size_in_words*sizeof(u32));
 
 	if (error) {
-
-		dev_warn(&sep->pdev->dev,
-			"init; copy sep init message failed %x\n", error);
+		error = -EFAULT;
 		goto end_function;
 	}
 
@@ -3070,7 +2716,6 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 	error = sep_load_firmware(sep);
 
 	if (error) {
-
 		dev_warn(&sep->pdev->dev,
 			"init; copy sep init message failed %x\n", error);
 		goto end_function;
@@ -3102,10 +2747,8 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 
 	/* debug print of message */
 	for (counter = 0; counter < command_args.message_size_in_words;
-		counter++)
-
-		dev_dbg(&sep->pdev->dev,
-			"init; sep message word %d is %x\n",
+								counter++)
+		dev_dbg(&sep->pdev->dev, "init; sep message word %d is %x\n",
 			counter, message_buff[counter]);
 
 	/* tell the sep the sram address */
@@ -3113,11 +2756,9 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 
 	/* push the message to the sep */
 	for (counter = 0; counter < command_args.message_size_in_words;
-		counter++) {
-
+								counter++) {
 		sep_write_reg(sep, HW_SRAM_DATA_REG_ADDR,
-			message_buff[counter]);
-
+						message_buff[counter]);
 		sep_wait_sram_write(sep);
 	}
 
@@ -3132,7 +2773,6 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 	while (!(reg_val & 0xFFFFFFFD));
 
 	if (reg_val == 0x1) {
-
 		dev_warn(&sep->pdev->dev, "init; device int failed\n");
 		error = sep_read_reg(sep, 0x8060);
 		dev_warn(&sep->pdev->dev, "init; sw monitor is %x\n", error);
@@ -3140,9 +2780,7 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 		dev_warn(&sep->pdev->dev, "init; error is %x\n", error);
 		goto end_function;
 	}
-
-	dev_dbg(&sep->pdev->dev, "init; end CC INIT, reg_val is %x\n",
-		reg_val);
+	dev_dbg(&sep->pdev->dev, "init; end CC INIT, reg_val is %x\n", reg_val);
 
 	/* signal sep to zero the GPR3 */
 	sep_write_reg(sep, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x10);
@@ -3154,7 +2792,6 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 		reg_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
 	while (reg_val != 0);
 
-
 end_function:
 	dev_dbg(&sep->pdev->dev, "init is done\n");
 	return error;
@@ -3205,34 +2842,32 @@ static int sep_end_transaction_handler(struct sep_device *sep)
  *	This function will retrieve the RAR buffer physical addresses, type
  *	& size corresponding to the RAR handles provided in the buffers vector.
  */
-
 static int sep_prepare_dcb_handler(struct sep_device *sep, unsigned long arg)
 {
 	/* error */
-	int error = 0;
-
+	int error;
 	/* command arguments */
 	struct build_dcb_struct command_args;
 
 	dev_dbg(&sep->pdev->dev, "sep_prepare_dcb_handler start\n");
 
-	/* get the command arguments */
+	/* Get the command arguments */
 	if (copy_from_user(&command_args, (void __user *)arg,
-		sizeof(struct build_dcb_struct))) {
+					sizeof(struct build_dcb_struct))) {
 		error = -EFAULT;
 		goto end_function;
 	}
 
-	dev_dbg(&sep->pdev->dev,
-		"app_in_address is %08llx\n", command_args.app_in_address);
-	dev_dbg(&sep->pdev->dev,
-		"app_out_address is %08llx\n", command_args.app_out_address);
-	dev_dbg(&sep->pdev->dev,
-		"data_size is %x\n", command_args.data_in_size);
-	dev_dbg(&sep->pdev->dev,
-		"block_size is %x\n", command_args.block_size);
-	dev_dbg(&sep->pdev->dev,
-		"tail block_size is %x\n", command_args.tail_block_size);
+	dev_dbg(&sep->pdev->dev, "app_in_address is %08llx\n",
+						command_args.app_in_address);
+	dev_dbg(&sep->pdev->dev, "app_out_address is %08llx\n",
+						command_args.app_out_address);
+	dev_dbg(&sep->pdev->dev, "data_size is %x\n",
+						command_args.data_in_size);
+	dev_dbg(&sep->pdev->dev, "block_size is %x\n",
+						command_args.block_size);
+	dev_dbg(&sep->pdev->dev, "tail block_size is %x\n",
+						command_args.tail_block_size);
 
 	error = sep_prepare_input_output_dma_table_in_dcb(sep,
 		command_args.app_in_address, command_args.app_out_address,
@@ -3240,7 +2875,6 @@ static int sep_prepare_dcb_handler(struct sep_device *sep, unsigned long arg)
 		command_args.tail_block_size, true, false);
 
 end_function:
-
 	dev_dbg(&sep->pdev->dev, "sep_prepare_dcb_handler end\n");
 	return error;
 
@@ -3274,52 +2908,40 @@ static int sep_free_dcb_handler(struct sep_device *sep)
  *	This function will retrieve the RAR buffer physical addresses, type
  *	& size corresponding to the RAR handles provided in the buffers vector.
  */
-
 static int sep_rar_prepare_output_msg_handler(struct sep_device *sep,
 	unsigned long arg)
 {
-	/* error return code */
 	int error = 0;
-
 	/* command args */
 	struct rar_hndl_to_bus_struct command_args;
 	struct RAR_buffer rar_buf;
-
 	/* bus address */
 	dma_addr_t  rar_bus = 0;
-
 	/* holds the RAR address in the system memory offset */
 	u32 *rar_addr;
 
-	dev_dbg(&sep->pdev->dev,
-		"sep_rar_prepare_output_msg_handler start\n");
+	dev_dbg(&sep->pdev->dev, "sep_rar_prepare_output_msg_handler start\n");
 
 	/* copy the data */
-	if (copy_from_user(&command_args,
-		(void __user *)arg,
-		sizeof(command_args))) {
+	if (copy_from_user(&command_args, (void __user *)arg,
+						sizeof(command_args))) {
 		error = -EFAULT;
 		goto end_function;
 	}
 
 	/* call to translation function only if user handle is not NULL */
 	if (command_args.rar_handle) {
-
 		memset(&rar_buf, 0, sizeof(rar_buf));
 		rar_buf.info.handle = (u32)command_args.rar_handle;
 
 		if (rar_handle_to_bus(&rar_buf, 1) != 1) {
-			dev_dbg(&sep->pdev->dev,
-				"rar_handle_to_bus failure\n");
+			dev_dbg(&sep->pdev->dev, "rar_handle_to_bus failure\n");
 			error = -EFAULT;
 			goto end_function;
 		}
-
 		rar_bus = rar_buf.bus_address;
 	}
-
-	dev_dbg(&sep->pdev->dev, "rar msg; rar_addr_bus = %x\n",
-		(u32)rar_bus);
+	dev_dbg(&sep->pdev->dev, "rar msg; rar_addr_bus = %x\n", (u32)rar_bus);
 
 	/* set value in the SYSTEM MEMORY offset */
 	rar_addr = (u32 *)(sep->shared_addr +
@@ -3330,10 +2952,7 @@ static int sep_rar_prepare_output_msg_handler(struct sep_device *sep,
 	rar_addr[1] = rar_bus;
 
 end_function:
-
-	dev_dbg(&sep->pdev->dev,
-		"sep_rar_prepare_output_msg_handler start\n");
-
+	dev_dbg(&sep->pdev->dev, "sep_rar_prepare_output_msg_handler start\n");
 	return error;
 }
 
@@ -3355,13 +2974,12 @@ static int sep_realloc_ext_cache_handler(struct sep_device *sep,
 		SEP_DRIVER_SYSTEM_EXT_CACHE_ADDR_OFFSET_IN_BYTES);
 
 	/* copy the physical address to the System Area for the sep */
-
 	system_addr[0] = SEP_EXT_CACHE_ADDR_VAL_TOKEN;
-	dev_dbg(&sep->pdev->dev,
-		"ext cache init; system addr 0 is %x\n", system_addr[0]);
+	dev_dbg(&sep->pdev->dev, "ext cache init; system addr 0 is %x\n",
+							system_addr[0]);
 	system_addr[1] = sep->extapp_bus;
-	dev_dbg(&sep->pdev->dev,
-		"ext cache init; system addr 1 is %x\n", system_addr[1]);
+	dev_dbg(&sep->pdev->dev, "ext cache init; system addr 1 is %x\n",
+							system_addr[1]);
 
 	return 0;
 }
@@ -3410,8 +3028,7 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	/* make sure we own this device */
 	mutex_lock(&sep->sep_mutex);
 	if ((current->pid != sep->pid_doing_transaction) &&
-		(sep->pid_doing_transaction != 0)) {
-
+				(sep->pid_doing_transaction != 0)) {
 		dev_dbg(&sep->pdev->dev, "ioctl pid is not owner\n");
 		mutex_unlock(&sep->sep_mutex);
 		error = -EACCES;
@@ -3485,15 +3102,13 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		error = sep_free_dcb_handler(sep);
 		break;
 	default:
-		dev_warn(&sep->pdev->dev, "invalid ioctl %x\n", cmd);
+		dev_dbg(&sep->pdev->dev, "invalid ioctl %x\n", cmd);
 		error = -ENOTTY;
 		break;
 	}
-
 	mutex_unlock(&sep->ioctl_mutex);
 
 end_function:
-
 	dev_dbg(&sep->pdev->dev, "ioctl end\n");
 	return error;
 }
@@ -3508,18 +3123,12 @@ end_function:
  */
 static long sep_singleton_ioctl(struct file  *filp, u32 cmd, unsigned long arg)
 {
-
 	/* error */
-	long error;
+	long error = 0;
 	struct sep_device *sep = filp->private_data;
 
-	error = 0;
-
-	dev_dbg(&sep->pdev->dev,
-		"singleton_ioctl start\n");
-
-	dev_dbg(&sep->pdev->dev,
-		"cmd is %x\n", cmd);
+	dev_dbg(&sep->pdev->dev, "singleton_ioctl start\n");
+	dev_dbg(&sep->pdev->dev, "cmd is %x\n", cmd);
 
 	/* check that the command is for sep device */
 	if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) {
@@ -3530,8 +3139,7 @@ static long sep_singleton_ioctl(struct file  *filp, u32 cmd, unsigned long arg)
 	/* make sure we own this device */
 	mutex_lock(&sep->sep_mutex);
 	if ((current->pid != sep->pid_doing_transaction) &&
-		(sep->pid_doing_transaction != 0)) {
-
+				(sep->pid_doing_transaction != 0)) {
 		dev_dbg(&sep->pdev->dev, "singleton ioctl pid is not owner\n");
 		mutex_unlock(&sep->sep_mutex);
 		error = -EACCES;
@@ -3541,21 +3149,17 @@ static long sep_singleton_ioctl(struct file  *filp, u32 cmd, unsigned long arg)
 	mutex_unlock(&sep->sep_mutex);
 
 	switch (cmd) {
-
 	case SEP_IOCTLSETCALLERID:
 		mutex_lock(&sep->ioctl_mutex);
 		error = sep_set_caller_id_handler(sep, arg);
 		mutex_unlock(&sep->ioctl_mutex);
 		break;
-
 	default:
 		error = sep_ioctl(filp, cmd, arg);
 		break;
-
 	}
 
 end_function:
-
 	dev_dbg(&sep->pdev->dev, "singleton ioctl end\n");
 	return error;
 }
@@ -3568,20 +3172,15 @@ end_function:
  *
  *	Called by the request daemon to perform ioctls on the daemon device
  */
-
 static long sep_request_daemon_ioctl(struct file *filp, u32 cmd,
 	unsigned long arg)
 {
 
 	long error;
-
 	struct sep_device *sep = filp->private_data;
 
-	dev_dbg(&sep->pdev->dev,
-		"daemon ioctl: start\n");
-
-	dev_dbg(&sep->pdev->dev,
-		"daemon ioctl: cmd is %x\n", cmd);
+	dev_dbg(&sep->pdev->dev, "daemon ioctl: start\n");
+	dev_dbg(&sep->pdev->dev, "daemon ioctl: cmd is %x\n", cmd);
 
 	/* check that the command is for sep device */
 	if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) {
@@ -3594,13 +3193,10 @@ static long sep_request_daemon_ioctl(struct file *filp, u32 cmd,
 
 	switch (cmd) {
 	case SEP_IOCSENDSEPRPLYCOMMAND:
-
 		/* send reply command to SEP */
 		error = sep_req_daemon_send_reply_command_handler(sep);
 		break;
-
 	case SEP_IOCENDTRANSACTION:
-
 		/*
 		 * end req daemon transaction, do nothing
 		 * will be removed upon update in middleware
@@ -3608,19 +3204,14 @@ static long sep_request_daemon_ioctl(struct file *filp, u32 cmd,
 		 */
 		error = 0;
 		break;
-
 	default:
-		dev_dbg(&sep->pdev->dev,
-		"daemon ioctl: no such IOCTL\n");
+		dev_dbg(&sep->pdev->dev, "daemon ioctl: no such IOCTL\n");
 		error = -ENOTTY;
 	}
-
 	mutex_unlock(&sep->ioctl_mutex);
 
 end_function:
-
-	dev_dbg(&sep->pdev->dev,
-		"daemon ioctl: end\n");
+	dev_dbg(&sep->pdev->dev, "daemon ioctl: end\n");
 	return error;
 
 }
@@ -3630,7 +3221,6 @@ end_function:
  *	@irq: interrupt
  *	@dev_id: device id
  */
-
 static irqreturn_t sep_inthandler(int irq, void *dev_id)
 {
 	irqreturn_t int_error = IRQ_HANDLED;
@@ -3640,18 +3230,16 @@ static irqreturn_t sep_inthandler(int irq, void *dev_id)
 
 	/* read the IRR register to check if this is SEP interrupt */
 	reg_val = sep_read_reg(sep, HW_HOST_IRR_REG_ADDR);
-	dev_dbg(&sep->pdev->dev,
-		"SEP Interrupt - reg is %08x\n", reg_val);
+	dev_dbg(&sep->pdev->dev, "SEP Interrupt - reg is %08x\n", reg_val);
 
 	if (reg_val & (0x1 << 13)) {
-
 		/* lock and update the counter of reply messages */
 		spin_lock_irqsave(&sep->snd_rply_lck, lck_flags);
 		sep->reply_ct++;
 		spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
 
 		dev_dbg(&sep->pdev->dev, "sep int: send_ct %lx reply_ct %lx\n",
-			sep->send_ct, sep->reply_ct);
+					sep->send_ct, sep->reply_ct);
 
 		/* is this printf or daemon request? */
 		reg_val2 = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR2_REG_ADDR);
@@ -3659,27 +3247,19 @@ static irqreturn_t sep_inthandler(int irq, void *dev_id)
 			"SEP Interrupt - reg2 is %08x\n", reg_val2);
 
 		if ((reg_val2 >> 30) & 0x1) {
-
 			dev_dbg(&sep->pdev->dev, "int: printf request\n");
 			wake_up(&sep->event_request_daemon);
-		}
-
-		else if (reg_val2 >> 31) {
-
+		} else if (reg_val2 >> 31) {
 			dev_dbg(&sep->pdev->dev, "int: daemon request\n");
 			wake_up(&sep->event_request_daemon);
 		} else {
-
 			dev_dbg(&sep->pdev->dev, "int: sep reply\n");
 			wake_up(&sep->event);
 		}
-
 	} else {
-
 		dev_dbg(&sep->pdev->dev, "int: not sep interrupt\n");
 		int_error = IRQ_NONE;
 	}
-
 	if (int_error == IRQ_HANDLED)
 		sep_write_reg(sep, HW_HOST_ICR_REG_ADDR, reg_val);
 
@@ -3695,16 +3275,14 @@ static irqreturn_t sep_inthandler(int irq, void *dev_id)
  */
 static int sep_callback(unsigned long sep_context_pointer)
 {
-	int error = 0;
-	struct sep_device *sep =
-		(struct sep_device *)sep_context_pointer;
-
-	dma_addr_t rar_end_address = 0;
+	int error;
+	struct sep_device *sep = (struct sep_device *)sep_context_pointer;
+	dma_addr_t rar_end_address;
 
 	dev_dbg(&sep->pdev->dev, "callback start\n");
 
 	error = rar_get_address(RAR_TYPE_IMAGE, &sep->rar_bus,
-		&rar_end_address);
+							&rar_end_address);
 
 	if (error) {
 		dev_warn(&sep->pdev->dev, "mrst cant get rar region\n");
@@ -3714,9 +3292,9 @@ static int sep_callback(unsigned long sep_context_pointer)
 	sep->rar_size = (size_t)(rar_end_address - sep->rar_bus + 1);
 
 	if (!request_mem_region(sep->rar_bus, sep->rar_size,
-		"sep_sec_driver")) {
+							"sep_sec_driver")) {
 		dev_warn(&sep->pdev->dev,
-			"request mem region for mrst failed\n");
+				"request mem region for mrst failed\n");
 		error = -1;
 		goto end_function;
 	}
@@ -3724,18 +3302,15 @@ static int sep_callback(unsigned long sep_context_pointer)
 	sep->rar_addr = ioremap_nocache(sep->rar_bus, sep->rar_size);
 	if (!sep->rar_addr) {
 		dev_warn(&sep->pdev->dev,
-			"ioremap nocache for mrst rar failed\n");
-		error = -1;
+				"ioremap nocache for mrst rar failed\n");
+		error = -ENOMEM;
 		goto end_function;
 	}
-
-	dev_dbg(&sep->pdev->dev, "rar start is %p, phy is %llx,"
-		" size is %x\n",
-		sep->rar_addr, (unsigned long long)sep->rar_bus,
-		sep->rar_size);
+	dev_dbg(&sep->pdev->dev, "rar start is %p, phy is %llx, size is %x\n",
+			sep->rar_addr, (unsigned long long)sep->rar_bus,
+			sep->rar_size);
 
 end_function:
-
 	dev_dbg(&sep->pdev->dev, "callback end\n");
 	return error;
 }
@@ -3769,7 +3344,6 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 
 	/* allocate the sep_device structure for this device */
 	sep_dev = kmalloc(sizeof(struct sep_device), GFP_ATOMIC);
-
 	if (sep_dev == NULL) {
 		dev_warn(&pdev->dev,
 			"can't kmalloc the sep_device structure\n");
@@ -3865,8 +3439,7 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 			sep->rar_size);
 	}
 
-	dev_dbg(&sep->pdev->dev,
-		"about to write IMR and ICR REG_ADDR\n");
+	dev_dbg(&sep->pdev->dev, "about to write IMR and ICR REG_ADDR\n");
 
 	/* clear ICR register */
 	sep_write_reg(sep, HW_HOST_ICR_REG_ADDR, 0xFFFFFFFF);
@@ -3874,18 +3447,14 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 	/* set the IMR register - open only GPR 2 */
 	sep_write_reg(sep, HW_HOST_IMR_REG_ADDR, (~(0x1 << 13)));
 
-	dev_dbg(&sep->pdev->dev,
-		"about to call request_irq\n");
+	dev_dbg(&sep->pdev->dev, "about to call request_irq\n");
 	/* get the interrupt line */
 	error = request_irq(pdev->irq, sep_inthandler, IRQF_SHARED,
 		"sep_driver", sep);
 
-	if (error)
-		goto end_function_free_res;
-
-	goto end_function;
+	if (!error)
+		goto end_function;
 
-end_function_free_res:
 	if (sep->rar_addr)
 		dma_free_coherent(&sep->pdev->dev, sep->rar_size,
 			sep->rar_addr, sep->rar_bus);
@@ -3959,37 +3528,29 @@ static const struct file_operations sep_file_operations = {
  */
 static int sep_reconfig_shared_area(struct sep_device *sep)
 {
-	int ret_val = 0;
+	int ret_val;
 
 	dev_dbg(&sep->pdev->dev, "reconfig shared area start\n");
 
 	/* send the new SHARED MESSAGE AREA to the SEP */
 	dev_dbg(&sep->pdev->dev, "sending %08llx to sep\n",
-		(unsigned long long)sep->shared_bus);
+				(unsigned long long)sep->shared_bus);
 
-	sep_write_reg(sep, HW_HOST_HOST_SEP_GPR1_REG_ADDR,
-		sep->shared_bus);
+	sep_write_reg(sep, HW_HOST_HOST_SEP_GPR1_REG_ADDR, sep->shared_bus);
 
 	/* poll for SEP response */
 	ret_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR1_REG_ADDR);
 
-	while (ret_val != 0xffffffff &&
-		ret_val != sep->shared_bus) {
-
-		ret_val = sep_read_reg(sep,
-		  HW_HOST_SEP_HOST_GPR1_REG_ADDR);
-	}
+	while (ret_val != 0xffffffff && ret_val != sep->shared_bus)
+		ret_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR1_REG_ADDR);
 
 	/* check the return value (register) */
 	if (ret_val != sep->shared_bus) {
 		dev_warn(&sep->pdev->dev, "could not reconfig shared area\n");
 		dev_warn(&sep->pdev->dev, "result was %x\n", ret_val);
 		ret_val = -ENOMEM;
-	}
-
-	else {
+	} else
 		ret_val = 0;
-	}
 
 	dev_dbg(&sep->pdev->dev, "reconfig shared area end\n");
 	return ret_val;
@@ -4003,7 +3564,7 @@ static int sep_reconfig_shared_area(struct sep_device *sep)
  */
 static int sep_register_driver_to_fs(struct sep_device *sep)
 {
-	int ret_val = 0;
+	int ret_val;
 
 	sep->miscdev_sep.minor = MISC_DYNAMIC_MINOR;
 	sep->miscdev_sep.name = SEP_DEV_NAME;
@@ -4035,8 +3596,7 @@ static int sep_register_driver_to_fs(struct sep_device *sep)
 	if (!sep->mrst) {
 		ret_val = misc_register(&sep->miscdev_daemon);
 		if (ret_val) {
-			dev_warn(&sep->pdev->dev,
-				"misc reg fails for dmn %x\n",
+			dev_warn(&sep->pdev->dev, "misc reg fails for dmn %x\n",
 				ret_val);
 			misc_deregister(&sep->miscdev_sep);
 			misc_deregister(&sep->miscdev_singleton);
@@ -4044,7 +3604,6 @@ static int sep_register_driver_to_fs(struct sep_device *sep)
 			return ret_val;
 		}
 	}
-
 	return ret_val;
 }
 
@@ -4062,8 +3621,8 @@ static int __init sep_init(void)
 
 	ret_val = pci_register_driver(&sep_pci_driver);
 	if (ret_val) {
-		pr_debug("sep_driver:sep_driver_to_device failed,"
-			" ret_val is %d\n", ret_val);
+		pr_debug("sep_driver:sep_driver_to_device failed, ret_val is %d\n",
+								ret_val);
 		goto end_function;
 	}
 
@@ -4085,11 +3644,9 @@ static int __init sep_init(void)
 	/* register driver to fs */
 	ret_val = sep_register_driver_to_fs(sep);
 	if (ret_val) {
-		dev_warn(&sep->pdev->dev,
-			"error registering device to file\n");
+		dev_warn(&sep->pdev->dev, "error registering device to file\n");
 		goto end_function_unregister_pci;
 	}
-
 	goto end_function;
 
 end_function_unregister_pci:


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 08/12] sep: Use kzalloc when needed
  2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
                   ` (6 preceding siblings ...)
  2010-11-24 19:38 ` [PATCH 07/12] sep: clean up some of the obvious sillies Alan Cox
@ 2010-11-24 19:38 ` Alan Cox
  2010-11-24 19:38 ` [PATCH 09/12] sep: Make SEP consistent Alan Cox
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 19:38 UTC (permalink / raw)
  To: greg, mark.a.allyn, linux-kernel

From: Alan Cox <alan@linux.intel.com>

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/staging/sep/sep_driver.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)


diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index f576285..ff9df36 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -3343,16 +3343,13 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 	}
 
 	/* allocate the sep_device structure for this device */
-	sep_dev = kmalloc(sizeof(struct sep_device), GFP_ATOMIC);
+	sep_dev = kzalloc(sizeof(struct sep_device), GFP_ATOMIC);
 	if (sep_dev == NULL) {
 		dev_warn(&pdev->dev,
 			"can't kmalloc the sep_device structure\n");
 		return -ENOMEM;
 	}
 
-	/* zero out sep structure */
-	memset((void *)sep_dev, 0, sizeof(struct sep_device));
-
 	/*
 	 * we're going to use another variable for actually
 	 * working with the device; this way, if we have
@@ -3365,8 +3362,6 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 
 	if (pdev->device == MRST_PCI_DEVICE_ID)
 		sep->mrst = 1;
-	else
-		sep->mrst = 0;
 
 	dev_dbg(&sep->pdev->dev, "PCI obtained, device being prepared\n");
 	dev_dbg(&sep->pdev->dev, "revision is %d\n", sep->pdev->revision);
@@ -3423,7 +3418,6 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 			goto end_function_deallocate_sep_shared_area;
 		}
 	} else {
-
 		sep->rar_size = FAKE_RAR_SIZE;
 		sep->rar_addr = dma_alloc_coherent(NULL,
 			sep->rar_size, &sep->rar_bus, GFP_KERNEL);


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 09/12] sep: Make SEP consistent
  2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
                   ` (7 preceding siblings ...)
  2010-11-24 19:38 ` [PATCH 08/12] sep: Use kzalloc when needed Alan Cox
@ 2010-11-24 19:38 ` Alan Cox
  2010-11-24 19:38 ` [PATCH 10/12] sep: cant is an angular inclination Alan Cox
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 19:38 UTC (permalink / raw)
  To: greg, mark.a.allyn, linux-kernel

From: Alan Cox <alan@linux.intel.com>

SEP is initials so make it consistent in the driver, ditto DMA and DCB
Consistent capitalisation of comment leads


Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/staging/sep/sep_driver.c |  631 +++++++++++++++++++-------------------
 1 files changed, 313 insertions(+), 318 deletions(-)


diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index ff9df36..9c16558 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -92,7 +92,7 @@ static int sep_load_firmware(struct sep_device *sep)
 	int error ;
 	unsigned int work1, work2, work3;
 
-	/* set addresses and load resident */
+	/* Set addresses and load resident */
 	sep->resident_bus = sep->rar_bus;
 	sep->resident_addr = sep->rar_addr;
 
@@ -113,7 +113,7 @@ static int sep_load_firmware(struct sep_device *sep)
 	dev_dbg(&sep->pdev->dev, "resident size is %08x\n",
 		sep->resident_size);
 
-	/* set addresses for dcache (no loading needed) */
+	/* Set addresses for dcache (no loading needed) */
 	work1 = (unsigned int)sep->resident_bus;
 	work2 = (unsigned int)sep->resident_size;
 	work3 = (work1 + work2 + (1024 * 4)) & 0xfffff000;
@@ -126,7 +126,7 @@ static int sep_load_firmware(struct sep_device *sep)
 
 	sep->dcache_size = 1024 * 128;
 
-	/* set addresses and load cache */
+	/* Set addresses and load cache */
 	sep->cache_bus = sep->dcache_bus + sep->dcache_size;
 	sep->cache_addr = sep->dcache_addr + sep->dcache_size;
 
@@ -147,7 +147,7 @@ static int sep_load_firmware(struct sep_device *sep)
 	dev_dbg(&sep->pdev->dev, "cache size is %08x\n",
 		sep->cache_size);
 
-	/* set addresses and load extapp */
+	/* Set addresses and load extapp */
 	sep->extapp_bus = sep->cache_bus + (1024 * 370);
 	sep->extapp_addr = sep->cache_addr + (1024 * 370);
 
@@ -177,7 +177,7 @@ MODULE_FIRMWARE("sep/extapp.image.bin");
 
 /**
  *	sep_dump_message - dump the message that is pending
- *	@sep: sep device
+ *	@sep: SEP device
  */
 static void sep_dump_message(struct sep_device *sep)
 {
@@ -205,7 +205,7 @@ static int sep_map_and_alloc_shared_area(struct sep_device *sep)
 		return -ENOMEM;
 	}
 	dev_dbg(&sep->pdev->dev,
-		"sep: shared_addr %x bytes @%p (bus %llx)\n",
+		"shared_addr %x bytes @%p (bus %llx)\n",
 				sep->shared_size, sep->shared_addr,
 				(unsigned long long)sep->shared_bus);
 	return 0;
@@ -249,7 +249,7 @@ static int sep_singleton_open(struct inode *inode_ptr, struct file *file_ptr)
 	struct sep_device *sep;
 
 	/*
-	 * Get the sep device structure and use it for the
+	 * Get the SEP device structure and use it for the
 	 * private_data field in filp for other methods
 	 */
 	sep = sep_dev;
@@ -274,8 +274,8 @@ end_function:
 
 /**
  *	sep_open - device open method
- *	@inode: inode of sep device
- *	@filp: file handle to sep device
+ *	@inode: inode of SEP device
+ *	@filp: file handle to SEP device
  *
  *	Open method for the SEP device. Called when userspace opens
  *	the SEP device node. 
@@ -287,7 +287,7 @@ static int sep_open(struct inode *inode, struct file *filp)
 	struct sep_device *sep;
 
 	/*
-	 * Get the sep device structure and use it for the
+	 * Get the SEP device structure and use it for the
 	 * private_data field in filp for other methods
 	 */
 	sep = sep_dev;
@@ -320,8 +320,8 @@ static int sep_singleton_release(struct inode *inode, struct file *filp)
 
 /**
  *	sep_request_daemonopen - request daemon open method
- *	@inode: inode of sep device
- *	@filp: file handle to sep device
+ *	@inode: inode of SEP device
+ *	@filp: file handle to SEP device
  *
  *	Open method for the SEP request daemon. Called when
  *	request daemon in userspace opens the SEP device node.
@@ -359,7 +359,7 @@ static int sep_request_daemon_release(struct inode *inode, struct file *filp)
 	dev_dbg(&sep->pdev->dev, "Reques daemon release for pid %d\n",
 		current->pid);
 
-	/* clear the request_daemon_open flag */
+	/* Clear the request_daemon_open flag */
 	clear_bit(0, &sep->request_daemon_open);
 	return 0;
 }
@@ -380,12 +380,12 @@ static int sep_req_daemon_send_reply_command_handler(struct sep_device *sep)
 
 	sep_dump_message(sep);
 
-	/* counters are lockable region */
+	/* Counters are lockable region */
 	spin_lock_irqsave(&sep->snd_rply_lck, lck_flags);
 	sep->send_ct++;
 	sep->reply_ct++;
 
-	/* send the interrupt to SEP */
+	/* Send the interrupt to SEP */
 	sep_write_reg(sep, HW_HOST_HOST_SEP_GPR2_REG_ADDR,
 		sep->send_ct);
 
@@ -408,13 +408,13 @@ static int sep_req_daemon_send_reply_command_handler(struct sep_device *sep)
  *	sep_free_dma_table_data_handler - free DMA table
  *	@sep: pointere to struct sep_device
  *
- *	Handles the request to  free dma table for synchronic actions
+ *	Handles the request to  free DMA table for synchronic actions
  */
 static int sep_free_dma_table_data_handler(struct sep_device *sep)
 {
 	int count;
 	int dcb_counter;
-	/* pointer to the current dma_resource struct */
+	/* Pointer to the current dma_resource struct */
 	struct sep_dma_resource *dma;
 
 	dev_dbg(&sep->pdev->dev, "sep_free_dma_table_data_handler start\n");
@@ -422,7 +422,7 @@ static int sep_free_dma_table_data_handler(struct sep_device *sep)
 	for (dcb_counter = 0; dcb_counter < sep->nr_dcb_creat; dcb_counter++) {
 		dma = &sep->dma_res_arr[dcb_counter];
 
-		/* unmap and free input map array */
+		/* Unmap and free input map array */
 		if (dma->in_map_array) {
 			for (count = 0; count < dma->in_num_pages; count++) {
 				dma_unmap_page(&sep->pdev->dev,
@@ -433,7 +433,7 @@ static int sep_free_dma_table_data_handler(struct sep_device *sep)
 			kfree(dma->in_map_array);
 		}
 
-		/* unmap output map array, DON'T free it yet */
+		/* Unmap output map array, DON'T free it yet */
 		if (dma->out_map_array) {
 			for (count = 0; count < dma->out_num_pages; count++) {
 				dma_unmap_page(&sep->pdev->dev,
@@ -444,7 +444,7 @@ static int sep_free_dma_table_data_handler(struct sep_device *sep)
 			kfree(dma->out_map_array);
 		}
 
-		/* free page cache for output */
+		/* Free page cache for output */
 		if (dma->in_page_array) {
 			for (count = 0; count < dma->in_num_pages; count++) {
 				flush_dcache_page(dma->in_page_array[count]);
@@ -463,7 +463,7 @@ static int sep_free_dma_table_data_handler(struct sep_device *sep)
 			kfree(dma->out_page_array);
 		}
 
-		/* reset all the values */
+		/* Reset all the values */
 		dma->in_page_array = 0;
 		dma->out_page_array = 0;
 		dma->in_num_pages = 0;
@@ -503,7 +503,7 @@ static int sep_request_daemon_mmap(struct file  *filp,
 		goto end_function;
 	}
 
-	/* get physical address */
+	/* Get physical address */
 	bus_address = sep->shared_bus;
 
 	dev_dbg(&sep->pdev->dev, "bus_address is %08lx\n",
@@ -524,7 +524,7 @@ end_function:
 
 /**
  *	sep_request_daemon_poll - poll implementation
- *	@sep: struct sep_device * for current sep device
+ *	@sep: struct sep_device * for current SEP device
  *	@filp: struct file * for open file
  *	@wait: poll_table * for poll
  *
@@ -547,7 +547,7 @@ static unsigned int sep_request_daemon_poll(struct file *filp,
 						sep->send_ct, sep->reply_ct);
 
 	spin_lock_irqsave(&sep->snd_rply_lck, lck_flags);
-	/* check if the data is ready */
+	/* Check if the data is ready */
 	if (sep->send_ct == sep->reply_ct) {
 		spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
 
@@ -555,13 +555,13 @@ static unsigned int sep_request_daemon_poll(struct file *filp,
 		dev_dbg(&sep->pdev->dev,
 			"daemon poll: data check (GPR2) is %x\n", retval2);
 
-		/* check if PRINT request */
+		/* Check if PRINT request */
 		if ((retval2 >> 30) & 0x1) {
 			dev_dbg(&sep->pdev->dev, "daemon poll: PRINTF request in\n");
 			mask |= POLLIN;
 			goto end_function;
 		}
-		/* check if NVS request */
+		/* Check if NVS request */
 		if (retval2 >> 31) {
 			dev_dbg(&sep->pdev->dev, "daemon poll: NVS request in\n");
 			mask |= POLLPRI | POLLWRNORM;
@@ -591,7 +591,7 @@ static int sep_release(struct inode *inode, struct file *filp)
 	dev_dbg(&sep->pdev->dev, "Release for pid %d\n", current->pid);
 
 	mutex_lock(&sep->sep_mutex);
-	/* is this the process that has a transaction open?
+	/* Is this the process that has a transaction open?
 	 * If so, lets reset pid_doing_transaction to 0 and
 	 * clear the in use flags, and then wake up sep_event
 	 * so that other processes can do transactions
@@ -614,7 +614,7 @@ static int sep_release(struct inode *inode, struct file *filp)
  *	@filp: pointer to struct file
  *	@vma: pointer to vm_area_struct
  *
- *	Called on an mmap of our space via the normal sep device
+ *	Called on an mmap of our space via the normal SEP device
  */
 static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
 {
@@ -636,8 +636,8 @@ static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
 	/*
 	 * The pid_doing_transaction indicates that this process
 	 * now owns the facilities to performa a transaction with
-	 * the sep. While this process is performing a transaction,
-	 * no other process who has the sep device open can perform
+	 * the SEP. While this process is performing a transaction,
+	 * no other process who has the SEP device open can perform
 	 * any transactions. This method allows more than one process
 	 * to have the device open at any given time, which provides
 	 * finer granularity for device utilization by multiple
@@ -647,12 +647,12 @@ static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
 	sep->pid_doing_transaction = current->pid;
 	mutex_unlock(&sep->sep_mutex);
 
-	/* zero the pools and the number of data pool alocation pointers */
+	/* Zero the pools and the number of data pool alocation pointers */
 	sep->data_pool_bytes_allocated = 0;
 	sep->num_of_data_allocations = 0;
 
 	/*
-	 * check that the size of the mapped range is as the size of the message
+	 * Check that the size of the mapped range is as the size of the message
 	 * shared area
 	 */
 	if ((vma->vm_end - vma->vm_start) > SEP_DRIVER_MMMAP_AREA_SIZE) {
@@ -662,7 +662,7 @@ static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
 
 	dev_dbg(&sep->pdev->dev, "shared_addr is %p\n", sep->shared_addr);
 
-	/* get bus address */
+	/* Get bus address */
 	bus_addr = sep->shared_bus;
 
 	dev_dbg(&sep->pdev->dev,
@@ -678,13 +678,13 @@ static int sep_mmap(struct file *filp, struct vm_area_struct *vma)
 	goto end_function;
 
 end_function_with_error:
-	/* clear the bit */
+	/* Clear the bit */
 	clear_bit(SEP_MMAP_LOCK_BIT, &sep->in_use_flags);
 	mutex_lock(&sep->sep_mutex);
 	sep->pid_doing_transaction = 0;
 	mutex_unlock(&sep->sep_mutex);
 
-	/* raise event for stuck contextes */
+	/* Raise event for stuck contextes */
 
 	dev_warn(&sep->pdev->dev, "mmap error - waking up event\n");
 	wake_up(&sep->event);
@@ -722,14 +722,14 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
 	}
 	mutex_unlock(&sep->sep_mutex);
 
-	/* check if send command or send_reply were activated previously */
+	/* Check if send command or send_reply were activated previously */
 	if (!test_bit(SEP_SEND_MSG_LOCK_BIT, &sep->in_use_flags)) {
 		dev_warn(&sep->pdev->dev, "poll; lock bit set\n");
 		mask = POLLERR;
 		goto end_function;
 	}
 
-	/* add the event to the polling wait table */
+	/* Add the event to the polling wait table */
 	dev_dbg(&sep->pdev->dev, "poll: calling wait sep_event\n");
 
 	poll_wait(filp, &sep->event, wait);
@@ -737,7 +737,7 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
 	dev_dbg(&sep->pdev->dev, "poll: send_ct is %lx reply ct is %lx\n",
 		sep->send_ct, sep->reply_ct);
 
-	/* check if error occured during poll */
+	/* Check if error occured during poll */
 	retval2 = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
 	if (retval2 != 0x0) {
 		dev_warn(&sep->pdev->dev, "poll; poll error %x\n", retval2);
@@ -753,25 +753,24 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
 		dev_dbg(&sep->pdev->dev, "poll: data ready check (GPR2)  %x\n",
 			retval);
 
-		/* check if printf request  */
+		/* Check if printf request  */
 		if ((retval >> 30) & 0x1) {
-			dev_dbg(&sep->pdev->dev, "poll: sep printf request\n");
+			dev_dbg(&sep->pdev->dev, "poll: SEP printf request\n");
 			wake_up(&sep->event_request_daemon);
 			goto end_function;
 		}
 
-		/* check if the this is sep reply or request */
+		/* Check if the this is SEP reply or request */
 		if (retval >> 31) {
-			dev_dbg(&sep->pdev->dev, "poll: sep request\n");
+			dev_dbg(&sep->pdev->dev, "poll: SEP request\n");
 			wake_up(&sep->event_request_daemon);
 		} else {
 			dev_dbg(&sep->pdev->dev, "poll: normal return\n");
-			/* in case it is again by send_reply_comand */
+			/* In case it is again by send_reply_comand */
 			clear_bit(SEP_SEND_MSG_LOCK_BIT, &sep->in_use_flags);
 			sep_dump_message(sep);
 			dev_dbg(&sep->pdev->dev,
-				"poll; sep reply POLLIN | POLLRDNORM\n");
-
+				"poll; SEP reply POLLIN | POLLRDNORM\n");
 			mask |= POLLIN | POLLRDNORM;
 		}
 	} else {
@@ -803,19 +802,19 @@ static u32 *sep_time_address(struct sep_device *sep)
  *	@sep: the SEP we are setting the time for
  *
  *	Calculates time and sets it at the predefined address.
- *	Called with the sep mutex held.
+ *	Called with the SEP mutex held.
  */
 static unsigned long sep_set_time(struct sep_device *sep)
 {
 	struct timeval time;
-	u32 *time_addr;	/* address of time as seen by the kernel */
+	u32 *time_addr;	/* Address of time as seen by the kernel */
 
 
-	dev_dbg(&sep->pdev->dev, "sep:sep_set_time start\n");
+	dev_dbg(&sep->pdev->dev, "sep_set_time start\n");
 
 	do_gettimeofday(&time);
 
-	/* set value in the SYSTEM MEMORY offset */
+	/* Set value in the SYSTEM MEMORY offset */
 	time_addr = sep_time_address(sep);
 
 	time_addr[0] = SEP_TIME_VAL_TOKEN;
@@ -830,7 +829,7 @@ static unsigned long sep_set_time(struct sep_device *sep)
 
 /**
  *	sep_set_caller_id_handler - insert caller id entry
- *	@sep: sep device
+ *	@sep: SEP device
  *	@arg: pointer to struct caller_id_struct
  *
  *	Inserts the data into the caller id table. Note that this function
@@ -858,7 +857,7 @@ static int sep_set_caller_id_handler(struct sep_device *sep, u32 arg)
 		goto end_function;
 	}
 
-	/* copy the data */
+	/* Copy the data */
 	if (copy_from_user(&command_args, (void __user *)arg,
 		sizeof(command_args))) {
 		error = -EFAULT;
@@ -894,9 +893,9 @@ end_function:
 
 /**
  *	sep_set_current_caller_id - set the caller id
- *	@sep: pointer to struct_sep
+ *	@sep: pointer to struct_sep_device
  *
- *	Set the caller ID (if it exists) to the sep. Note that this
+ *	Set the caller ID (if it exists) to the SEP. Note that this
  *	function falls under the ioctl lock
  */
 static int sep_set_current_caller_id(struct sep_device *sep)
@@ -906,7 +905,7 @@ static int sep_set_current_caller_id(struct sep_device *sep)
 	dev_dbg(&sep->pdev->dev, "sep_set_current_caller_id start\n");
 	dev_dbg(&sep->pdev->dev, "current process is %d\n", current->pid);
 
-	/* zero the previous value */
+	/* Zero the previous value */
 	memset(sep->shared_addr + SEP_CALLER_ID_OFFSET_BYTES,
 					0, SEP_CALLER_ID_HASH_SIZE_IN_BYTES);
 
@@ -926,7 +925,7 @@ static int sep_set_current_caller_id(struct sep_device *sep)
 
 /**
  *	sep_send_command_handler - kick off a command
- *	@sep: sep being signalled
+ *	@sep: SEP being signalled
  *
  *	This function raises interrupt to SEP that signals that is has a new
  *	command from the host
@@ -946,13 +945,13 @@ static int sep_send_command_handler(struct sep_device *sep)
 	}
 	sep_set_time(sep);
 
-	/* only Medfield has caller id */
+	/* Only Medfield has caller id */
 	if (sep->mrst == 0)
 		sep_set_current_caller_id(sep);
 
 	sep_dump_message(sep);
 
-	/* update counter */
+	/* Update counter */
 	spin_lock_irqsave(&sep->snd_rply_lck, lck_flags);
 	sep->send_ct++;
 	spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
@@ -961,7 +960,7 @@ static int sep_send_command_handler(struct sep_device *sep)
 		"sep_send_command_handler send_ct %lx reply_ct %lx\n",
 						sep->send_ct, sep->reply_ct);
 
-	/* send interrupt to SEP */
+	/* Send interrupt to SEP */
 	sep_write_reg(sep, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x2);
 
 end_function:
@@ -971,7 +970,7 @@ end_function:
 
 /**
  *	sep_allocate_data_pool_memory_handler -allocate pool memory
- *	@sep: pointer to struct_sep
+ *	@sep: pointer to struct sep_device
  *	@arg: pointer to struct alloc_struct
  *
  *	This function handles the allocate data pool memory request
@@ -1016,7 +1015,7 @@ static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
 	dev_dbg(&sep->pdev->dev,
 		"command_args.offset: %x\n", command_args.offset);
 
-	/* Place in the shared area that is known by the sep */
+	/* Place in the shared area that is known by the SEP */
 	token_addr = (u32 *)(sep->shared_addr +
 		SEP_DRIVER_DATA_POOL_ALLOCATION_OFFSET_IN_BYTES +
 		(sep->num_of_data_allocations)*2*sizeof(u32));
@@ -1043,7 +1042,7 @@ static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
 		goto end_function;
 	}
 
-	/* update the allocation */
+	/* Update the allocation */
 	sep->data_pool_bytes_allocated += command_args.num_bytes;
 	sep->num_of_data_allocations += 1;
 
@@ -1079,9 +1078,9 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
 
 {
 	int error = 0;
-	/* array of lli */
+	/* Array of lli */
 	struct sep_lli_entry *lli_array;
-	/* map array */
+	/* Map array */
 	struct sep_dma_map *map_array;
 
 	dev_dbg(&sep->pdev->dev,
@@ -1110,7 +1109,7 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
 
 
 	/*
-	 * set the start address of the first page - app data may start not at
+	 * Set the start address of the first page - app data may start not at
 	 * the beginning of the page
 	 */
 	lli_array[0].bus_address = (u32)map_array[0].dma_addr;
@@ -1121,7 +1120,7 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
 		(unsigned long)lli_array[0].bus_address,
 		lli_array[0].block_size);
 
-	/* set the output parameters */
+	/* Set the output parameters */
 	if (in_out_flag == SEP_DRIVER_IN_FLAG) {
 		*lli_array_ptr = lli_array;
 		sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages = 1;
@@ -1168,25 +1167,25 @@ static int sep_lock_user_pages(struct sep_device *sep,
 	int error = 0;
 	u32 count;
 	int result;
-	/* the the page of the end address of the user space buffer */
+	/* The the page of the end address of the user space buffer */
 	u32 end_page;
-	/* the page of the start address of the user space buffer */
+	/* The page of the start address of the user space buffer */
 	u32 start_page;
-	/* the range in pages */
+	/* The range in pages */
 	u32 num_pages;
-	/* array of pointers to page */
+	/* Array of pointers to page */
 	struct page **page_array;
-	/* array of lli */
+	/* Array of lli */
 	struct sep_lli_entry *lli_array;
-	/* map array */
+	/* Map array */
 	struct sep_dma_map *map_array;
-	/* direction of the DMA mapping for locked pages */
+	/* Direction of the DMA mapping for locked pages */
 	enum dma_data_direction	dir;
 
 	dev_dbg(&sep->pdev->dev,
 		"sep_lock_user_pages start\n");
 
-	/* set start and end pages  and num pages */
+	/* Set start and end pages  and num pages */
 	end_page = (app_virt_addr + data_size - 1) >> PAGE_SHIFT;
 	start_page = app_virt_addr >> PAGE_SHIFT;
 	num_pages = end_page - start_page + 1;
@@ -1199,7 +1198,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
 
 	dev_dbg(&sep->pdev->dev, "starting page_array malloc\n");
 
-	/* allocate array of pages structure pointers */
+	/* Allocate array of pages structure pointers */
 	page_array = kmalloc(sizeof(struct page *) * num_pages, GFP_ATOMIC);
 	if (!page_array) {
 		error = -ENOMEM;
@@ -1223,7 +1222,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
 
 	dev_dbg(&sep->pdev->dev, "starting get_user_pages\n");
 
-	/* convert the application virtual address into a set of physical */
+	/* Convert the application virtual address into a set of physical */
 	down_read(&current->mm->mmap_sem);
 	result = get_user_pages(current, current->mm, app_virt_addr,
 		num_pages,
@@ -1232,7 +1231,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
 
 	up_read(&current->mm->mmap_sem);
 
-	/* check the number of pages locked - if not all then exit with error */
+	/* Check the number of pages locked - if not all then exit with error */
 	if (result != num_pages) {
 		dev_warn(&sep->pdev->dev,
 			"not all pages locked by get_user_pages\n");
@@ -1242,26 +1241,25 @@ static int sep_lock_user_pages(struct sep_device *sep,
 
 	dev_dbg(&sep->pdev->dev, "get_user_pages succeeded\n");
 
-	/* set direction */
+	/* Set direction */
 	if (in_out_flag == SEP_DRIVER_IN_FLAG)
 		dir = DMA_TO_DEVICE;
 	else
 		dir = DMA_FROM_DEVICE;
 
 	/*
-	 * fill the array using page array data and
-	 * map the pages - this action
-	 * will also flush the cache as needed
+	 * Fill the array using page array data and
+	 * map the pages - this action will also flush the cache as needed
 	 */
 	for (count = 0; count < num_pages; count++) {
-		/* fill the map array */
+		/* Fill the map array */
 		map_array[count].dma_addr =
 			dma_map_page(&sep->pdev->dev, page_array[count],
 			0, PAGE_SIZE, /*dir*/DMA_BIDIRECTIONAL);
 
 		map_array[count].size = PAGE_SIZE;
 
-		/* fill the lli array entry */
+		/* Fill the lli array entry */
 		lli_array[count].bus_address = (u32)map_array[count].dma_addr;
 		lli_array[count].block_size = PAGE_SIZE;
 
@@ -1270,11 +1268,11 @@ static int sep_lock_user_pages(struct sep_device *sep,
 			count, lli_array[count].block_size);
 	}
 
-	/* check the offset for the first page */
+	/* Check the offset for the first page */
 	lli_array[0].bus_address =
 		lli_array[0].bus_address + (app_virt_addr & (~PAGE_MASK));
 
-	/* check that not all the data is in the first page only */
+	/* Check that not all the data is in the first page only */
 	if ((PAGE_SIZE - (app_virt_addr & (~PAGE_MASK))) >= data_size)
 		lli_array[0].block_size = data_size;
 	else
@@ -1286,7 +1284,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
 		(unsigned long)lli_array[count].bus_address,
 		lli_array[count].block_size);
 
-	/* check the size of the last page */
+	/* Check the size of the last page */
 	if (num_pages > 1) {
 		lli_array[num_pages - 1].block_size =
 			(app_virt_addr + data_size) & (~PAGE_MASK);
@@ -1299,7 +1297,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
 			lli_array[count].block_size);
 	}
 
-	/* set output params acording to the in_out flag */
+	/* Set output params acording to the in_out flag */
 	if (in_out_flag == SEP_DRIVER_IN_FLAG) {
 		*lli_array_ptr = lli_array;
 		sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages = num_pages;
@@ -1319,14 +1317,14 @@ static int sep_lock_user_pages(struct sep_device *sep,
 	goto end_function;
 
 end_function_with_error3:
-	/* free lli array */
+	/* Free lli array */
 	kfree(lli_array);
 
 end_function_with_error2:
 	kfree(map_array);
 
 end_function_with_error1:
-	/* free page array */
+	/* Free page array */
 	kfree(page_array);
 
 end_function:
@@ -1352,15 +1350,15 @@ static u32 sep_calculate_lli_table_max_size(struct sep_device *sep,
 	u32 *last_table_flag)
 {
 	u32 counter;
-	/* table data size */
+	/* Table data size */
 	u32 table_data_size = 0;
-	/* data size for the next table */
+	/* Data size for the next table */
 	u32 next_table_data_size;
 
 	*last_table_flag = 0;
 
 	/*
-	 * calculate the data in the out lli table till we fill the whole
+	 * Calculate the data in the out lli table till we fill the whole
 	 * table or till the data has ended
 	 */
 	for (counter = 0;
@@ -1369,20 +1367,19 @@ static u32 sep_calculate_lli_table_max_size(struct sep_device *sep,
 		table_data_size += lli_in_array_ptr[counter].block_size;
 
 	/*
-	 * check if we reached the last entry,
+	 * Check if we reached the last entry,
 	 * meaning this ia the last table to build,
 	 * and no need to check the block alignment
 	 */
 	if (counter == num_array_entries) {
-		/* set the last table flag */
+		/* Set the last table flag */
 		*last_table_flag = 1;
 		goto end_function;
 	}
 
 	/*
-	 * calculate the data size of the next table.
-	 * Stop if no entries left or
-	 * if data size is more the DMA restriction
+	 * Calculate the data size of the next table.
+	 * Stop if no entries left or if data size is more the DMA restriction
 	 */
 	next_table_data_size = 0;
 	for (; counter < num_array_entries; counter++) {
@@ -1392,7 +1389,7 @@ static u32 sep_calculate_lli_table_max_size(struct sep_device *sep,
 	}
 
 	/*
-	 * check if the next table data size is less then DMA rstriction.
+	 * Check if the next table data size is less then DMA rstriction.
 	 * if it is - recalculate the current table size, so that the next
 	 * table data size will be adaquete for DMA
 	 */
@@ -1427,23 +1424,23 @@ static void sep_build_lli_table(struct sep_device *sep,
 	u32 *num_table_entries_ptr,
 	u32 table_data_size)
 {
-	/* current table data size */
+	/* Current table data size */
 	u32 curr_table_data_size;
-	/* counter of lli array entry */
+	/* Counter of lli array entry */
 	u32 array_counter;
 
 	dev_dbg(&sep->pdev->dev, "sep_build_lli_table start\n");
 
-	/* init currrent table data size and lli array entry counter */
+	/* Init currrent table data size and lli array entry counter */
 	curr_table_data_size = 0;
 	array_counter = 0;
 	*num_table_entries_ptr = 1;
 
 	dev_dbg(&sep->pdev->dev, "table_data_size is %x\n", table_data_size);
 
-	/* fill the table till table size reaches the needed amount */
+	/* Fill the table till table size reaches the needed amount */
 	while (curr_table_data_size < table_data_size) {
-		/* update the number of entries in table */
+		/* Update the number of entries in table */
 		(*num_table_entries_ptr)++;
 
 		lli_table_ptr->bus_address =
@@ -1461,24 +1458,24 @@ static void sep_build_lli_table(struct sep_device *sep,
 		dev_dbg(&sep->pdev->dev, "lli_table_ptr->block_size is %x\n",
 			lli_table_ptr->block_size);
 
-		/* check for overflow of the table data */
+		/* Check for overflow of the table data */
 		if (curr_table_data_size > table_data_size) {
 			dev_dbg(&sep->pdev->dev,
 				"curr_table_data_size too large\n");
 
-			/* update the size of block in the table */
+			/* Update the size of block in the table */
 			lli_table_ptr->block_size -=
 			cpu_to_le32((curr_table_data_size - table_data_size));
 
-			/* update the physical address in the lli array */
+			/* Update the physical address in the lli array */
 			lli_array_ptr[array_counter].bus_address +=
 			cpu_to_le32(lli_table_ptr->block_size);
 
-			/* update the block size left in the lli array */
+			/* Update the block size left in the lli array */
 			lli_array_ptr[array_counter].block_size =
 				(curr_table_data_size - table_data_size);
 		} else
-			/* advance to the next entry in the lli_array */
+			/* Advance to the next entry in the lli_array */
 			array_counter++;
 
 		dev_dbg(&sep->pdev->dev,
@@ -1488,11 +1485,11 @@ static void sep_build_lli_table(struct sep_device *sep,
 			"lli_table_ptr->block_size is %x\n",
 			lli_table_ptr->block_size);
 
-		/* move to the next entry in table */
+		/* Move to the next entry in table */
 		lli_table_ptr++;
 	}
 
-	/* set the info entry to default */
+	/* Set the info entry to default */
 	lli_table_ptr->bus_address = 0xffffffff;
 	lli_table_ptr->block_size = 0;
 
@@ -1502,7 +1499,7 @@ static void sep_build_lli_table(struct sep_device *sep,
 	dev_dbg(&sep->pdev->dev, "lli_table_ptr->block_size is %x\n",
 						lli_table_ptr->block_size);
 
-	/* set the output parameter */
+	/* Set the output parameter */
 	*num_processed_entries_ptr += array_counter;
 
 	dev_dbg(&sep->pdev->dev, "num_processed_entries_ptr is %x\n",
@@ -1578,7 +1575,7 @@ static void sep_debug_print_lli_tables(struct sep_device *sep,
 		dev_dbg(&sep->pdev->dev, "num_table_entries is %lu\n",
 							num_table_entries);
 
-		/* print entries of the table (without info entry) */
+		/* Print entries of the table (without info entry) */
 		for (entries_count = 0; entries_count < num_table_entries;
 			entries_count++, lli_table_ptr++) {
 
@@ -1591,7 +1588,7 @@ static void sep_debug_print_lli_tables(struct sep_device *sep,
 				(unsigned long)lli_table_ptr->bus_address,
 				lli_table_ptr->block_size);
 		}
-		/* point to the info entry */
+		/* Point to the info entry */
 		lli_table_ptr--;
 
 		dev_dbg(&sep->pdev->dev,
@@ -1642,7 +1639,7 @@ static void sep_prepare_empty_lli_table(struct sep_device *sep,
 
 	dev_dbg(&sep->pdev->dev, "sep_prepare_empty_lli_table start\n");
 
-	/* find the area for new table */
+	/* Find the area for new table */
 	lli_table_ptr =
 		(struct sep_lli_entry *)(sep->shared_addr +
 		SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
@@ -1656,18 +1653,18 @@ static void sep_prepare_empty_lli_table(struct sep_device *sep,
 	lli_table_ptr->bus_address = 0xFFFFFFFF;
 	lli_table_ptr->block_size = 0;
 
-	/* set the output parameter value */
+	/* Set the output parameter value */
 	*lli_table_addr_ptr = sep->shared_bus +
 		SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
 		sep->num_lli_tables_created *
 		sizeof(struct sep_lli_entry) *
 		SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;
 
-	/* set the num of entries and table data size for empty table */
+	/* Set the num of entries and table data size for empty table */
 	*num_entries_ptr = 2;
 	*table_data_size_ptr = 0;
 
-	/* update the number of created tables */
+	/* Update the number of created tables */
 	sep->num_lli_tables_created++;
 
 	dev_dbg(&sep->pdev->dev, "sep_prepare_empty_lli_table start\n");
@@ -1686,7 +1683,7 @@ static void sep_prepare_empty_lli_table(struct sep_device *sep,
  *
  *	This function prepares only input DMA table for synhronic symmetric
  *	operations (HASH)
- *	Note that all bus addresses that are passed to the sep
+ *	Note that all bus addresses that are passed to the SEP
  *	are in 32 bit format; the SEP is a 32 bit device
  */
 static int sep_prepare_input_dma_table(struct sep_device *sep,
@@ -1699,54 +1696,54 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 	bool is_kva)
 {
 	int error = 0;
-	/* pointer to the info entry of the table - the last entry */
+	/* Pointer to the info entry of the table - the last entry */
 	struct sep_lli_entry *info_entry_ptr;
-	/* array of pointers to page */
+	/* Array of pointers to page */
 	struct sep_lli_entry *lli_array_ptr;
-	/* points to the first entry to be processed in the lli_in_array */
+	/* Points to the first entry to be processed in the lli_in_array */
 	u32 current_entry = 0;
-	/* num entries in the virtual buffer */
+	/* Num entries in the virtual buffer */
 	u32 sep_lli_entries = 0;
-	/* lli table pointer */
+	/* Lli table pointer */
 	struct sep_lli_entry *in_lli_table_ptr;
-	/* the total data in one table */
+	/* The total data in one table */
 	u32 table_data_size = 0;
-	/* flag for last table */
+	/* Flag for last table */
 	u32 last_table_flag = 0;
-	/* number of entries in lli table */
+	/* Number of entries in lli table */
 	u32 num_entries_in_table = 0;
-	/* next table address */
+	/* Next table address */
 	u32 lli_table_alloc_addr = 0;
 
 	dev_dbg(&sep->pdev->dev, "sep_prepare_input_dma_table start\n");
 	dev_dbg(&sep->pdev->dev, "data_size is %x\n", data_size);
 	dev_dbg(&sep->pdev->dev, "block_size is %x\n", block_size);
 
-	/* initialize the pages pointers */
+	/* Initialize the pages pointers */
 	sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = 0;
 	sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages = 0;
 
-	/* set the kernel address for first table to be allocated */
+	/* Set the kernel address for first table to be allocated */
 	lli_table_alloc_addr = (u32)(sep->shared_addr +
 		SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
 		sep->num_lli_tables_created * sizeof(struct sep_lli_entry) *
 		SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);
 
 	if (data_size == 0) {
-		/* special case  - create meptu table - 2 entries, zero data */
+		/* Special case  - create meptu table - 2 entries, zero data */
 		sep_prepare_empty_lli_table(sep, lli_table_ptr,
 				num_entries_ptr, table_data_size_ptr);
 		goto update_dcb_counter;
 	}
 
-	/* check if the pages are in Kernel Virtual Address layout */
+	/* Check if the pages are in Kernel Virtual Address layout */
 	if (is_kva == true)
-		/* lock the pages in the kernel */
+		/* Lock the pages in the kernel */
 		error = sep_lock_kernel_pages(sep, app_virt_addr,
 			data_size, &lli_array_ptr, SEP_DRIVER_IN_FLAG);
 	else
 		/*
-		 * lock the pages of the user buffer
+		 * Lock the pages of the user buffer
 		 * and translate them to pages
 		 */
 		error = sep_lock_user_pages(sep, app_virt_addr,
@@ -1763,10 +1760,10 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 
 	sep_lli_entries = sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages;
 
-	/* loop till all the entries in in array are not processed */
+	/* Loop till all the entries in in array are not processed */
 	while (current_entry < sep_lli_entries) {
 
-		/* set the new input and output tables */
+		/* Set the new input and output tables */
 		in_lli_table_ptr =
 			(struct sep_lli_entry *)lli_table_alloc_addr;
 
@@ -1783,17 +1780,17 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 
 		}
 
-		/* update the number of created tables */
+		/* Update the number of created tables */
 		sep->num_lli_tables_created++;
 
-		/* calculate the maximum size of data for input table */
+		/* Calculate the maximum size of data for input table */
 		table_data_size = sep_calculate_lli_table_max_size(sep,
 			&lli_array_ptr[current_entry],
 			(sep_lli_entries - current_entry),
 			&last_table_flag);
 
 		/*
-		 * if this is not the last table -
+		 * If this is not the last table -
 		 * then allign it to the block size
 		 */
 		if (!last_table_flag)
@@ -1803,14 +1800,14 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 		dev_dbg(&sep->pdev->dev, "output table_data_size is %x\n",
 							table_data_size);
 
-		/* construct input lli table */
+		/* Construct input lli table */
 		sep_build_lli_table(sep, &lli_array_ptr[current_entry],
 			in_lli_table_ptr,
 			&current_entry, &num_entries_in_table, table_data_size);
 
 		if (info_entry_ptr == 0) {
 
-			/* set the output parameters to physical addresses */
+			/* Set the output parameters to physical addresses */
 			*lli_table_ptr = sep_shared_area_virt_to_bus(sep,
 				in_lli_table_ptr);
 			*num_entries_ptr = num_entries_in_table;
@@ -1821,7 +1818,7 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 				(unsigned long)*lli_table_ptr);
 
 		} else {
-			/* update the info entry of the previous in table */
+			/* Update the info entry of the previous in table */
 			info_entry_ptr->bus_address =
 				sep_shared_area_virt_to_bus(sep,
 							in_lli_table_ptr);
@@ -1829,23 +1826,23 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 				((num_entries_in_table) << 24) |
 				(table_data_size);
 		}
-		/* save the pointer to the info entry of the current tables */
+		/* Save the pointer to the info entry of the current tables */
 		info_entry_ptr = in_lli_table_ptr + num_entries_in_table - 1;
 	}
-	/* print input tables */
+	/* Print input tables */
 	sep_debug_print_lli_tables(sep, (struct sep_lli_entry *)
 		sep_shared_area_bus_to_virt(sep, *lli_table_ptr),
 		*num_entries_ptr, *table_data_size_ptr);
-	/* the array of the pages */
+	/* The array of the pages */
 	kfree(lli_array_ptr);
 
 update_dcb_counter:
-	/* update dcb counter */
+	/* Update DCB counter */
 	sep->nr_dcb_creat++;
 	goto end_function;
 
 end_function_error:
-	/* free all the allocated resources */
+	/* Free all the allocated resources */
 	kfree(sep->dma_res_arr[sep->nr_dcb_creat].in_map_array);
 	kfree(lli_array_ptr);
 	kfree(sep->dma_res_arr[sep->nr_dcb_creat].in_page_array);
@@ -1857,7 +1854,7 @@ end_function:
 }
 /**
  *	sep_construct_dma_tables_from_lli - prepare AES/DES mappings
- *	@sep: pointer to struct_sep
+ *	@sep: pointer to struct sep_device
  *	@lli_in_array:
  *	@sep_in_lli_entries:
  *	@lli_out_array:
@@ -1869,10 +1866,10 @@ end_function:
  *	@out_num_entries_ptr
  *	@table_data_size_ptr
  *
- *	This function creates the input and output dma tables for
+ *	This function creates the input and output DMA tables for
  *	symmetric operations (AES/DES) according to the block
  *	size from LLI arays
- *	Note that all bus addresses that are passed to the sep
+ *	Note that all bus addresses that are passed to the SEP
  *	are in 32 bit format; the SEP is a 32 bit device
  */
 static int sep_construct_dma_tables_from_lli(
@@ -1888,56 +1885,56 @@ static int sep_construct_dma_tables_from_lli(
 	u32	*out_num_entries_ptr,
 	u32	*table_data_size_ptr)
 {
-	/* points to the area where next lli table can be allocated */
+	/* Points to the area where next lli table can be allocated */
 	u32 lli_table_alloc_addr = 0;
-	/* input lli table */
+	/* Input lli table */
 	struct sep_lli_entry *in_lli_table_ptr = 0;
-	/* output lli table */
+	/* Output lli table */
 	struct sep_lli_entry *out_lli_table_ptr = 0;
-	/* pointer to the info entry of the table - the last entry */
+	/* Pointer to the info entry of the table - the last entry */
 	struct sep_lli_entry *info_in_entry_ptr = 0;
-	/* pointer to the info entry of the table - the last entry */
+	/* Pointer to the info entry of the table - the last entry */
 	struct sep_lli_entry *info_out_entry_ptr = 0;
-	/* points to the first entry to be processed in the lli_in_array */
+	/* Points to the first entry to be processed in the lli_in_array */
 	u32 current_in_entry = 0;
-	/* points to the first entry to be processed in the lli_out_array */
+	/* Points to the first entry to be processed in the lli_out_array */
 	u32 current_out_entry = 0;
-	/* max size of the input table */
+	/* Max size of the input table */
 	u32 in_table_data_size = 0;
-	/* max size of the output table */
+	/* Max size of the output table */
 	u32 out_table_data_size = 0;
-	/* flag te signifies if this is the last tables build */
+	/* Flag te signifies if this is the last tables build */
 	u32 last_table_flag = 0;
-	/* the data size that should be in table */
+	/* The data size that should be in table */
 	u32 table_data_size = 0;
-	/* number of etnries in the input table */
+	/* Number of etnries in the input table */
 	u32 num_entries_in_table = 0;
-	/* number of etnries in the output table */
+	/* Number of etnries in the output table */
 	u32 num_entries_out_table = 0;
 
 	dev_dbg(&sep->pdev->dev, "sep_construct_dma_tables_from_lli start\n");
 
-	/* initiate to point after the message area */
+	/* Initiate to point after the message area */
 	lli_table_alloc_addr = (u32)(sep->shared_addr +
 		SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
 		(sep->num_lli_tables_created *
 		(sizeof(struct sep_lli_entry) *
 		SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP)));
 
-	/* loop till all the entries in in array are not processed */
+	/* Loop till all the entries in in array are not processed */
 	while (current_in_entry < sep_in_lli_entries) {
-		/* set the new input and output tables */
+		/* Set the new input and output tables */
 		in_lli_table_ptr =
 			(struct sep_lli_entry *)lli_table_alloc_addr;
 
 		lli_table_alloc_addr += sizeof(struct sep_lli_entry) *
 			SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;
 
-		/* set the first output tables */
+		/* Set the first output tables */
 		out_lli_table_ptr =
 			(struct sep_lli_entry *)lli_table_alloc_addr;
 
-		/* check if the DMA table area limit was overrun */
+		/* Check if the DMA table area limit was overrun */
 		if ((lli_table_alloc_addr + sizeof(struct sep_lli_entry) *
 			SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP) >
 			((u32)sep->shared_addr +
@@ -1948,20 +1945,20 @@ static int sep_construct_dma_tables_from_lli(
 			return -ENOMEM;
 		}
 
-		/* update the number of the lli tables created */
+		/* Update the number of the lli tables created */
 		sep->num_lli_tables_created += 2;
 
 		lli_table_alloc_addr += sizeof(struct sep_lli_entry) *
 			SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP;
 
-		/* calculate the maximum size of data for input table */
+		/* Calculate the maximum size of data for input table */
 		in_table_data_size =
 			sep_calculate_lli_table_max_size(sep,
 			&lli_in_array[current_in_entry],
 			(sep_in_lli_entries - current_in_entry),
 			&last_table_flag);
 
-		/* calculate the maximum size of data for output table */
+		/* Calculate the maximum size of data for output table */
 		out_table_data_size =
 			sep_calculate_lli_table_max_size(sep,
 			&lli_out_array[current_out_entry],
@@ -1980,7 +1977,7 @@ static int sep_construct_dma_tables_from_lli(
 
 		if (!last_table_flag) {
 			/*
-			 * if this is not the last table,
+			 * If this is not the last table,
 			 * then must check where the data is smallest
 			 * and then align it to the block size
 			 */
@@ -1988,7 +1985,7 @@ static int sep_construct_dma_tables_from_lli(
 				table_data_size = out_table_data_size;
 
 			/*
-			 * now calculate the table size so that
+			 * Now calculate the table size so that
 			 * it will be module block size
 			 */
 			table_data_size = (table_data_size / block_size) *
@@ -1998,23 +1995,23 @@ static int sep_construct_dma_tables_from_lli(
 		dev_dbg(&sep->pdev->dev, "table_data_size is %x\n",
 							table_data_size);
 
-		/* construct input lli table */
+		/* Construct input lli table */
 		sep_build_lli_table(sep, &lli_in_array[current_in_entry],
 			in_lli_table_ptr,
 			&current_in_entry,
 			&num_entries_in_table,
 			table_data_size);
 
-		/* construct output lli table */
+		/* Construct output lli table */
 		sep_build_lli_table(sep, &lli_out_array[current_out_entry],
 			out_lli_table_ptr,
 			&current_out_entry,
 			&num_entries_out_table,
 			table_data_size);
 
-		/* if info entry is null - this is the first table built */
+		/* If info entry is null - this is the first table built */
 		if (info_in_entry_ptr == 0) {
-			/* set the output parameters to physical addresses */
+			/* Set the output parameters to physical addresses */
 			*lli_table_in_ptr =
 			sep_shared_area_virt_to_bus(sep, in_lli_table_ptr);
 
@@ -2034,7 +2031,7 @@ static int sep_construct_dma_tables_from_lli(
 			"output lli_table_out_ptr is %08lx\n",
 				(unsigned long)*lli_table_out_ptr);
 		} else {
-			/* update the info entry of the previous in table */
+			/* Update the info entry of the previous in table */
 			info_in_entry_ptr->bus_address =
 				sep_shared_area_virt_to_bus(sep,
 				in_lli_table_ptr);
@@ -2043,7 +2040,7 @@ static int sep_construct_dma_tables_from_lli(
 				((num_entries_in_table) << 24) |
 				(table_data_size);
 
-			/* update the info entry of the previous in table */
+			/* Update the info entry of the previous in table */
 			info_out_entry_ptr->bus_address =
 				sep_shared_area_virt_to_bus(sep,
 				out_lli_table_ptr);
@@ -2063,7 +2060,7 @@ static int sep_construct_dma_tables_from_lli(
 				info_out_entry_ptr->block_size);
 		}
 
-		/* save the pointer to the info entry of the current tables */
+		/* Save the pointer to the info entry of the current tables */
 		info_in_entry_ptr = in_lli_table_ptr +
 			num_entries_in_table - 1;
 		info_out_entry_ptr = out_lli_table_ptr +
@@ -2080,14 +2077,14 @@ static int sep_construct_dma_tables_from_lli(
 			(unsigned long)info_out_entry_ptr);
 	}
 
-	/* print input tables */
+	/* Print input tables */
 	sep_debug_print_lli_tables(sep,
 	(struct sep_lli_entry *)
 	sep_shared_area_bus_to_virt(sep, *lli_table_in_ptr),
 	*in_num_entries_ptr,
 	*table_data_size_ptr);
 
-	/* print output tables */
+	/* Print output tables */
 	sep_debug_print_lli_tables(sep,
 	(struct sep_lli_entry *)
 	sep_shared_area_bus_to_virt(sep, *lli_table_out_ptr),
@@ -2114,7 +2111,7 @@ static int sep_construct_dma_tables_from_lli(
  *	This function builds input and output DMA tables for synhronic
  *	symmetric operations (AES, DES, HASH). It also checks that each table
  *	is of the modular block size
- *	Note that all bus addresses that are passed to the sep
+ *	Note that all bus addresses that are passed to the SEP
  *	are in 32 bit format; the SEP is a 32 bit device
  */
 static int sep_prepare_input_output_dma_table(struct sep_device *sep,
@@ -2131,15 +2128,15 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
 
 {
 	int error = 0;
-	/* array of pointers of page */
+	/* Array of pointers of page */
 	struct sep_lli_entry *lli_in_array;
-	/* array of pointers of page */
+	/* Array of pointers of page */
 	struct sep_lli_entry *lli_out_array;
 
 	dev_dbg(&sep->pdev->dev, "sep_prepare_input_output_dma_table start\n");
 
 	if (data_size == 0) {
-		/* prepare empty table for input and output */
+		/* Prepare empty table for input and output */
 		sep_prepare_empty_lli_table(sep, lli_table_in_ptr,
 			in_num_entries_ptr, table_data_size_ptr);
 
@@ -2149,11 +2146,11 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
 		goto update_dcb_counter;
 	}
 
-	/* initialize the pages pointers */
+	/* Initialize the pages pointers */
 	sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = 0;
 	sep->dma_res_arr[sep->nr_dcb_creat].out_page_array = 0;
 
-	/* lock the pages of the buffer and translate them to pages */
+	/* Lock the pages of the buffer and translate them to pages */
 	if (is_kva == true) {
 		error = sep_lock_kernel_pages(sep, app_virt_in_addr,
 			data_size, &lli_in_array, SEP_DRIVER_IN_FLAG);
@@ -2200,7 +2197,7 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
 	dev_dbg(&sep->pdev->dev, "SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP is %x\n",
 		SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);
 
-	/* call the fucntion that creates table from the lli arrays */
+	/* Call the fucntion that creates table from the lli arrays */
 	error = sep_construct_dma_tables_from_lli(sep, lli_in_array,
 		sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages,
 		lli_out_array,
@@ -2218,9 +2215,9 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
 	kfree(lli_in_array);
 
 update_dcb_counter:
-	/* update dcb counter */
+	/* Update DCB counter */
 	sep->nr_dcb_creat++;
-	/* fall through - free the lli entry arrays */
+	/* Fall through - free the lli entry arrays */
 	dev_dbg(&sep->pdev->dev, "in_num_entries_ptr is %08x\n",
 						*in_num_entries_ptr);
 	dev_dbg(&sep->pdev->dev, "out_num_entries_ptr is %08x\n",
@@ -2259,10 +2256,10 @@ end_function:
  *	@isapplet: bool; to indicate external app
  *	@is_kva: bool; kernel buffer; only used for kernel crypto module
  *
- *	This function prepares the linked dma tables and puts the
- *	address for the linked list of tables inta a dcb (data control
- *	block) the address of which is known by the sep hardware
- *	Note that all bus addresses that are passed to the sep
+ *	This function prepares the linked DMA tables and puts the
+ *	address for the linked list of tables inta a DCB (data control
+ *	block) the address of which is known by the SEP hardware
+ *	Note that all bus addresses that are passed to the SEP
  *	are in 32 bit format; the SEP is a 32 bit device
  */
 static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
@@ -2275,36 +2272,36 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 	bool		is_kva)
 {
 	int error = 0;
-	/* size of tail */
+	/* Size of tail */
 	u32 tail_size = 0;
-	/* address of the created dcb table */
+	/* Address of the created DCB table */
 	struct sep_dcblock *dcb_table_ptr = 0;
-	/* the physical address of the first input DMA table */
+	/* The physical address of the first input DMA table */
 	dma_addr_t in_first_mlli_address = 0;
-	/* number of entries in the first input DMA table */
+	/* Number of entries in the first input DMA table */
 	u32  in_first_num_entries = 0;
-	/* the physical address of the first output DMA table */
+	/* The physical address of the first output DMA table */
 	dma_addr_t  out_first_mlli_address = 0;
-	/* number of entries in the first output DMA table */
+	/* Number of entries in the first output DMA table */
 	u32  out_first_num_entries = 0;
-	/* data in the first input/output table */
+	/* Data in the first input/output table */
 	u32  first_data_size = 0;
 
 	dev_dbg(&sep->pdev->dev, "prepare_input_output_dma_table_in_dcb start\n");
 
 	if (sep->nr_dcb_creat == SEP_MAX_NUM_SYNC_DMA_OPS) {
-		/* No more DCBS to allocate */
-		dev_warn(&sep->pdev->dev, "no more dcb's available\n");
+		/* No more DCBs to allocate */
+		dev_warn(&sep->pdev->dev, "no more DCBs available\n");
 		error = -ENOSPC;
 		goto end_function;
 	}
 
-	/* allocate new DCB */
+	/* Allocate new DCB */
 	dcb_table_ptr = (struct sep_dcblock *)(sep->shared_addr +
 		SEP_DRIVER_SYSTEM_DCB_MEMORY_OFFSET_IN_BYTES +
 		(sep->nr_dcb_creat * sizeof(struct sep_dcblock)));
 
-	/* set the default values in the dcb */
+	/* Set the default values in the DCB */
 	dcb_table_ptr->input_mlli_address = 0;
 	dcb_table_ptr->input_mlli_num_entries = 0;
 	dcb_table_ptr->input_mlli_data_size = 0;
@@ -2324,7 +2321,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 			}
 			if (tail_block_size)
 				/*
-				 * case the tail size should be
+				 * Case the tail size should be
 				 * bigger than the real block size
 				 */
 				tail_size = tail_block_size +
@@ -2332,7 +2329,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 						tail_block_size) % block_size);
 		}
 
-		/* check if there is enough data for dma operation */
+		/* Check if there is enough data for DMA operation */
 		if (data_in_size < SEP_DRIVER_MIN_DATA_SIZE_PER_TABLE) {
 			if (is_kva == true) {
 				memcpy(dcb_table_ptr->tail_data,
@@ -2348,7 +2345,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 
 			dcb_table_ptr->tail_data_size = data_in_size;
 
-			/* set the output user-space address for mem2mem op */
+			/* Set the output user-space address for mem2mem op */
 			if (app_out_address)
 				dcb_table_ptr->out_vr_tail_pt =
 							(u32)app_out_address;
@@ -2367,7 +2364,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 					(void *)(app_in_address + data_in_size -
 					tail_size), tail_size);
 			} else {
-				/* we have tail data - copy it to dcb */
+				/* We have tail data - copy it to DCB */
 				if (copy_from_user(dcb_table_ptr->tail_data,
 					(void *)(app_in_address +
 					data_in_size - tail_size), tail_size)) {
@@ -2393,9 +2390,9 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 			data_in_size = (data_in_size - tail_size);
 		}
 	}
-	/* check if we need to build only input table or input/output */
+	/* Check if we need to build only input table or input/output */
 	if (app_out_address) {
-		/* prepare input/output tables */
+		/* Prepare input/output tables */
 		error = sep_prepare_input_output_dma_table(sep,
 			app_in_address,
 			app_out_address,
@@ -2408,7 +2405,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 			&first_data_size,
 			is_kva);
 	} else {
-		/* prepare input tables */
+		/* Prepare input tables */
 		error = sep_prepare_input_dma_table(sep,
 			app_in_address,
 			data_in_size,
@@ -2420,11 +2417,11 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 	}
 
 	if (error) {
-		dev_warn(&sep->pdev->dev, "prepare dma table call failed from prepare dcb call\n");
+		dev_warn(&sep->pdev->dev, "prepare DMA table call failed from prepare DCB call\n");
 		goto end_function;
 	}
 
-	/* set the dcb values */
+	/* Set the DCB values */
 	dcb_table_ptr->input_mlli_address = in_first_mlli_address;
 	dcb_table_ptr->input_mlli_num_entries = in_first_num_entries;
 	dcb_table_ptr->input_mlli_data_size = first_data_size;
@@ -2441,7 +2438,7 @@ end_function:
 
 
 /**
- *	sep_create_sync_dma_tables_handler - create sync dma tables
+ *	sep_create_sync_dma_tables_handler - create sync DMA tables
  *	@sep: pointer to struct sep_device
  *	@arg: pointer to struct bld_syn_tab_struct
  *
@@ -2454,7 +2451,7 @@ static int sep_create_sync_dma_tables_handler(struct sep_device *sep,
 {
 	int error = 0;
 
-	/* command arguments */
+	/* Command arguments */
 	struct bld_syn_tab_struct command_args;
 
 	dev_dbg(&sep->pdev->dev,
@@ -2475,7 +2472,7 @@ static int sep_create_sync_dma_tables_handler(struct sep_device *sep,
 	dev_dbg(&sep->pdev->dev, "block_size is %u\n",
 						command_args.block_size);
 
-	/* validate user parameters */
+	/* Validate user parameters */
 	if (!command_args.app_in_address) {
 		error = -EINVAL;
 		goto end_function;
@@ -2501,7 +2498,7 @@ end_function:
  *	@isapplet: indicates external application (used for kernel access)
  *	@is_kva: indicates kernel addresses (only used for kernel crypto)
  *
- *	This function frees the dma tables and dcb block
+ *	This function frees the DMA tables and DCB
  */
 static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
 	bool is_kva)
@@ -2514,12 +2511,12 @@ static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
 	dev_dbg(&sep->pdev->dev, "sep_free_dma_tables_and_dcb start\n");
 
 	if (isapplet == true) {
-		/* set pointer to first dcb table */
+		/* Set pointer to first DCB table */
 		dcb_table_ptr = (struct sep_dcblock *)
 			(sep->shared_addr +
 			SEP_DRIVER_SYSTEM_DCB_MEMORY_OFFSET_IN_BYTES);
 
-		/* go over each dcb and see if tail pointer must be updated */
+		/* Go over each DCB and see if tail pointer must be updated */
 		for (i = 0; i < sep->nr_dcb_creat; i++, dcb_table_ptr++) {
 			if (dcb_table_ptr->out_vr_tail_pt) {
 				if (is_kva == true) {
@@ -2533,14 +2530,14 @@ static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
 						dcb_table_ptr->tail_data_size);
 				}
 				if (error_temp) {
-					/* release the dma resource */
+					/* Release the DMA resource */
 					error = -EFAULT;
 					break;
 				}
 			}
 		}
 	}
-	/* free the output pages, if any */
+	/* Free the output pages, if any */
 	sep_free_dma_table_data_handler(sep);
 
 	dev_dbg(&sep->pdev->dev, "sep_free_dma_tables_and_dcb end\n");
@@ -2579,7 +2576,7 @@ static int sep_get_static_pool_addr_handler(struct sep_device *sep,
 		(u32)static_pool_addr[1],
 		(u32)command_args.static_virt_address);
 
-	/* send the parameters to user application */
+	/* Send the parameters to user application */
 	if (copy_to_user((void __user *) arg, &command_args,
 		sizeof(struct stat_pool_addr_struct)))
 		return -EFAULT;
@@ -2600,14 +2597,14 @@ static int sep_start_handler(struct sep_device *sep)
 
 	dev_dbg(&sep->pdev->dev, "sep_start_handler start\n");
 
-	/* wait in polling for message from SEP */
+	/* Wait in polling for message from SEP */
 	do
 		reg_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
 	while (!reg_val);
 
-	/* check the value */
+	/* Check the value */
 	if (reg_val == 0x1)
-		/* fatal error - read error status from GPRO */
+		/* Fatal error - read error status from GPRO */
 		error = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR0_REG_ADDR);
 	dev_dbg(&sep->pdev->dev, "sep_start_handler end\n");
 	return error;
@@ -2619,7 +2616,7 @@ static int sep_start_handler(struct sep_device *sep)
  *	@length: buffer size
  *
  *	This function performs a checksum for messages that are sent
- *	to the sep
+ *	to the SEP.
  */
 static u32 sep_check_sum_calc(u8 *data, u32 length)
 {
@@ -2651,7 +2648,7 @@ static u32 sep_check_sum_calc(u8 *data, u32 length)
  *	Handles the request for SEP initialization
  *	Note that this will go away for Medfield once the SCU
  *	SEP initialization is complete
- *	Also note that the message to the sep has components
+ *	Also note that the message to the SEP has components
  *	from user space as well as components written by the driver
  *	This is becuase the portions of the message that pertain to
  *	physical addresses must be set by the driver after the message
@@ -2670,7 +2667,7 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 
 	dev_dbg(&sep->pdev->dev, "sep_init_handler start\n");
 
-	/* make sure that we have not initialized already */
+	/* Make sure that we have not initialized already */
 	reg_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
 
 	if (reg_val != 0x2) {
@@ -2679,13 +2676,13 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 		goto end_function;
 	}
 
-	/* only root can initialize */
+	/* Only root can initialize */
 	if (!capable(CAP_SYS_ADMIN)) {
 		error = -EACCES;
 		goto end_function;
 	}
 
-	/* copy in the parameters */
+	/* Copy in the parameters */
 	error = copy_from_user(&command_args, (void __user *)arg,
 		sizeof(struct init_struct));
 
@@ -2694,14 +2691,14 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 		goto end_function;
 	}
 
-	/* validate parameters */
+	/* Validate parameters */
 	if (!command_args.message_addr || !command_args.sep_sram_addr ||
 		command_args.message_size_in_words > 14) {
 		error = -EINVAL;
 		goto end_function;
 	}
 
-	/* copy in the sep init message */
+	/* Copy in the SEP init message */
 	addr_hold = (unsigned long)command_args.message_addr;
 	error = copy_from_user(message_buff,
 		(void __user *)addr_hold,
@@ -2712,16 +2709,16 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 		goto end_function;
 	}
 
-	/* load resident, cache, and extapp firmware */
+	/* Load resident, cache, and extapp firmware */
 	error = sep_load_firmware(sep);
 
 	if (error) {
 		dev_warn(&sep->pdev->dev,
-			"init; copy sep init message failed %x\n", error);
+			"init; copy SEP init message failed %x\n", error);
 		goto end_function;
 	}
 
-	/* compute the base address */
+	/* Compute the base address */
 	new_base_addr = sep->shared_bus;
 
 	if (sep->resident_bus < new_base_addr)
@@ -2733,7 +2730,7 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 	if (sep->dcache_bus < new_base_addr)
 		new_base_addr = sep->dcache_bus;
 
-	/* put physical addresses in sep message */
+	/* Put physical addresses in SEP message */
 	message_buff[3] = (u32)new_base_addr;
 	message_buff[4] = (u32)sep->shared_bus;
 	message_buff[6] = (u32)sep->resident_bus;
@@ -2745,16 +2742,16 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 		sep_check_sum_calc((u8 *)message_buff,
 		command_args.message_size_in_words*sizeof(u32));
 
-	/* debug print of message */
+	/* Debug print of message */
 	for (counter = 0; counter < command_args.message_size_in_words;
 								counter++)
-		dev_dbg(&sep->pdev->dev, "init; sep message word %d is %x\n",
+		dev_dbg(&sep->pdev->dev, "init; SEP message word %d is %x\n",
 			counter, message_buff[counter]);
 
-	/* tell the sep the sram address */
+	/* Tell the SEP the sram address */
 	sep_write_reg(sep, HW_SRAM_ADDR_REG_ADDR, command_args.sep_sram_addr);
 
-	/* push the message to the sep */
+	/* Push the message to the SEP */
 	for (counter = 0; counter < command_args.message_size_in_words;
 								counter++) {
 		sep_write_reg(sep, HW_SRAM_DATA_REG_ADDR,
@@ -2762,10 +2759,10 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 		sep_wait_sram_write(sep);
 	}
 
-	/* signal sep that message is ready and to init */
+	/* Signal SEP that message is ready and to init */
 	sep_write_reg(sep, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x1);
 
-	/* wait for acknowledge */
+	/* Wait for acknowledge */
 	dev_dbg(&sep->pdev->dev, "init; waiting for msg response\n");
 
 	do
@@ -2782,10 +2779,10 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 	}
 	dev_dbg(&sep->pdev->dev, "init; end CC INIT, reg_val is %x\n", reg_val);
 
-	/* signal sep to zero the GPR3 */
+	/* Signal SEP to zero the GPR3 */
 	sep_write_reg(sep, HW_HOST_HOST_SEP_GPR0_REG_ADDR, 0x10);
 
-	/* wait for response */
+	/* Wait for response */
 	dev_dbg(&sep->pdev->dev, "init; waiting for zero set response\n");
 
 	do
@@ -2807,25 +2804,25 @@ static int sep_end_transaction_handler(struct sep_device *sep)
 {
 	dev_dbg(&sep->pdev->dev, "sep_end_transaction_handler start\n");
 
-	/* clear the data pool pointers Token */
+	/* Clear the data pool pointers Token */
 	memset((void *)(sep->shared_addr +
 		SEP_DRIVER_DATA_POOL_ALLOCATION_OFFSET_IN_BYTES),
 		0, sep->num_of_data_allocations*2*sizeof(u32));
 
-	/* check that all the dma resources were freed */
+	/* Check that all the DMA resources were freed */
 	sep_free_dma_table_data_handler(sep);
 
 	clear_bit(SEP_MMAP_LOCK_BIT, &sep->in_use_flags);
 
 	/*
-	 * we are now through with the transaction. Let's
+	 * We are now through with the transaction. Let's
 	 * allow other processes who have the device open
 	 * to perform transactions
 	 */
 	mutex_lock(&sep->sep_mutex);
 	sep->pid_doing_transaction = 0;
 	mutex_unlock(&sep->sep_mutex);
-	/* raise event for stuck contextes */
+	/* Raise event for stuck contextes */
 	wake_up(&sep->event);
 
 	dev_dbg(&sep->pdev->dev, "waking up event\n");
@@ -2844,9 +2841,8 @@ static int sep_end_transaction_handler(struct sep_device *sep)
  */
 static int sep_prepare_dcb_handler(struct sep_device *sep, unsigned long arg)
 {
-	/* error */
 	int error;
-	/* command arguments */
+	/* Command arguments */
 	struct build_dcb_struct command_args;
 
 	dev_dbg(&sep->pdev->dev, "sep_prepare_dcb_handler start\n");
@@ -2912,24 +2908,24 @@ static int sep_rar_prepare_output_msg_handler(struct sep_device *sep,
 	unsigned long arg)
 {
 	int error = 0;
-	/* command args */
+	/* Command args */
 	struct rar_hndl_to_bus_struct command_args;
 	struct RAR_buffer rar_buf;
-	/* bus address */
+	/* Bus address */
 	dma_addr_t  rar_bus = 0;
-	/* holds the RAR address in the system memory offset */
+	/* Holds the RAR address in the system memory offset */
 	u32 *rar_addr;
 
 	dev_dbg(&sep->pdev->dev, "sep_rar_prepare_output_msg_handler start\n");
 
-	/* copy the data */
+	/* Copy the data */
 	if (copy_from_user(&command_args, (void __user *)arg,
 						sizeof(command_args))) {
 		error = -EFAULT;
 		goto end_function;
 	}
 
-	/* call to translation function only if user handle is not NULL */
+	/* Call to translation function only if user handle is not NULL */
 	if (command_args.rar_handle) {
 		memset(&rar_buf, 0, sizeof(rar_buf));
 		rar_buf.info.handle = (u32)command_args.rar_handle;
@@ -2943,11 +2939,11 @@ static int sep_rar_prepare_output_msg_handler(struct sep_device *sep,
 	}
 	dev_dbg(&sep->pdev->dev, "rar msg; rar_addr_bus = %x\n", (u32)rar_bus);
 
-	/* set value in the SYSTEM MEMORY offset */
+	/* Set value in the SYSTEM MEMORY offset */
 	rar_addr = (u32 *)(sep->shared_addr +
 		SEP_DRIVER_SYSTEM_RAR_MEMORY_OFFSET_IN_BYTES);
 
-	/* copy the physical address to the System Area for the sep */
+	/* Copy the physical address to the System Area for the SEP */
 	rar_addr[0] = SEP_RAR_VAL_TOKEN;
 	rar_addr[1] = rar_bus;
 
@@ -2961,19 +2957,19 @@ end_function:
  *	@sep: pointer to struct sep_device
  *	@arg: pointer to user parameters
  *
- *	This function tells the sep where the extapp is located
+ *	This function tells the SEP where the extapp is located
  */
 static int sep_realloc_ext_cache_handler(struct sep_device *sep,
 	unsigned long arg)
 {
-	/* holds the new ext cache address in the system memory offset */
+	/* Holds the new ext cache address in the system memory offset */
 	u32 *system_addr;
 
-	/* set value in the SYSTEM MEMORY offset */
+	/* Set value in the SYSTEM MEMORY offset */
 	system_addr = (u32 *)(sep->shared_addr +
 		SEP_DRIVER_SYSTEM_EXT_CACHE_ADDR_OFFSET_IN_BYTES);
 
-	/* copy the physical address to the System Area for the sep */
+	/* Copy the physical address to the System Area for the SEP */
 	system_addr[0] = SEP_EXT_CACHE_ADDR_VAL_TOKEN;
 	dev_dbg(&sep->pdev->dev, "ext cache init; system addr 0 is %x\n",
 							system_addr[0]);
@@ -3025,7 +3021,7 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	dev_dbg(&sep->pdev->dev,
 		"SEP_IOCFREEDCB is %x\n", SEP_IOCFREEDCB);
 
-	/* make sure we own this device */
+	/* Make sure we own this device */
 	mutex_lock(&sep->sep_mutex);
 	if ((current->pid != sep->pid_doing_transaction) &&
 				(sep->pid_doing_transaction != 0)) {
@@ -3037,48 +3033,48 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 
 	mutex_unlock(&sep->sep_mutex);
 
-	/* check that the command is for sep device */
+	/* Check that the command is for SEP device */
 	if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) {
 		error = -ENOTTY;
 		goto end_function;
 	}
 
-	/* lock to prevent the daemon to interfere with operation */
+	/* Lock to prevent the daemon to interfere with operation */
 	mutex_lock(&sep->ioctl_mutex);
 
 	switch (cmd) {
 	case SEP_IOCSENDSEPCOMMAND:
-		/* send command to SEP */
+		/* Send command to SEP */
 		error = sep_send_command_handler(sep);
 		break;
 	case SEP_IOCALLOCDATAPOLL:
-		/* allocate data pool */
+		/* Allocate data pool */
 		error = sep_allocate_data_pool_memory_handler(sep, arg);
 		break;
 	case SEP_IOCCREATESYMDMATABLE:
-		/* create dma table for synhronic operation */
+		/* Create DMA table for synhronic operation */
 		error = sep_create_sync_dma_tables_handler(sep, arg);
 		break;
 	case SEP_IOCFREEDMATABLEDATA:
-		/* free the pages */
+		/* Free the pages */
 		error = sep_free_dma_table_data_handler(sep);
 		break;
 	case SEP_IOCSEPSTART:
-		/* start command to sep */
-		if (sep->pdev->revision == 0) /* only for old chip */
+		/* Start command to SEP */
+		if (sep->pdev->revision == 0) /* Only for old chip */
 			error = sep_start_handler(sep);
 		else
-			error = -EPERM; /* not permitted on new chip */
+			error = -EPERM; /* Not permitted on new chip */
 		break;
 	case SEP_IOCSEPINIT:
-		/* init command to sep */
-		if (sep->pdev->revision == 0) /* only for old chip */
+		/* Init command to SEP */
+		if (sep->pdev->revision == 0) /* Only for old chip */
 			error = sep_init_handler(sep, arg);
 		else
-			error = -EPERM; /* not permitted on new chip */
+			error = -EPERM; /* Not permitted on new chip */
 		break;
 	case SEP_IOCGETSTATICPOOLADDR:
-		/* get the physical and virtual addresses of the static pool */
+		/* Get the physical and virtual addresses of the static pool */
 		error = sep_get_static_pool_addr_handler(sep, arg);
 		break;
 	case SEP_IOCENDTRANSACTION:
@@ -3087,10 +3083,10 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	case SEP_IOCREALLOCEXTCACHE:
 		if (sep->mrst)
 			error = -ENODEV;
-		if (sep->pdev->revision == 0) /* only for old chip */
+		if (sep->pdev->revision == 0) /* Only for old chip */
 			error = sep_realloc_ext_cache_handler(sep, arg);
 		else
-			error = -EPERM; /* not permitted on new chip */
+			error = -EPERM; /* Not permitted on new chip */
 		break;
 	case SEP_IOCRARPREPAREMESSAGE:
 		error = sep_rar_prepare_output_msg_handler(sep, arg);
@@ -3123,20 +3119,19 @@ end_function:
  */
 static long sep_singleton_ioctl(struct file  *filp, u32 cmd, unsigned long arg)
 {
-	/* error */
 	long error = 0;
 	struct sep_device *sep = filp->private_data;
 
 	dev_dbg(&sep->pdev->dev, "singleton_ioctl start\n");
 	dev_dbg(&sep->pdev->dev, "cmd is %x\n", cmd);
 
-	/* check that the command is for sep device */
+	/* Check that the command is for the SEP device */
 	if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) {
 		error =  -ENOTTY;
 		goto end_function;
 	}
 
-	/* make sure we own this device */
+	/* Make sure we own this device */
 	mutex_lock(&sep->sep_mutex);
 	if ((current->pid != sep->pid_doing_transaction) &&
 				(sep->pid_doing_transaction != 0)) {
@@ -3182,23 +3177,23 @@ static long sep_request_daemon_ioctl(struct file *filp, u32 cmd,
 	dev_dbg(&sep->pdev->dev, "daemon ioctl: start\n");
 	dev_dbg(&sep->pdev->dev, "daemon ioctl: cmd is %x\n", cmd);
 
-	/* check that the command is for sep device */
+	/* Check that the command is for SEP device */
 	if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER) {
 		error = -ENOTTY;
 		goto end_function;
 	}
 
-	/* only one process can access ioctl at any given time */
+	/* Only one process can access ioctl at any given time */
 	mutex_lock(&sep->ioctl_mutex);
 
 	switch (cmd) {
 	case SEP_IOCSENDSEPRPLYCOMMAND:
-		/* send reply command to SEP */
+		/* Send reply command to SEP */
 		error = sep_req_daemon_send_reply_command_handler(sep);
 		break;
 	case SEP_IOCENDTRANSACTION:
 		/*
-		 * end req daemon transaction, do nothing
+		 * End req daemon transaction, do nothing
 		 * will be removed upon update in middleware
 		 * API library
 		 */
@@ -3217,7 +3212,7 @@ end_function:
 }
 
 /**
- *	sep_inthandler - Interrupt Handler
+ *	sep_inthandler - interrupt handler
  *	@irq: interrupt
  *	@dev_id: device id
  */
@@ -3228,12 +3223,12 @@ static irqreturn_t sep_inthandler(int irq, void *dev_id)
 	u32 reg_val, reg_val2 = 0;
 	struct sep_device *sep = dev_id;
 
-	/* read the IRR register to check if this is SEP interrupt */
+	/* Read the IRR register to check if this is SEP interrupt */
 	reg_val = sep_read_reg(sep, HW_HOST_IRR_REG_ADDR);
 	dev_dbg(&sep->pdev->dev, "SEP Interrupt - reg is %08x\n", reg_val);
 
 	if (reg_val & (0x1 << 13)) {
-		/* lock and update the counter of reply messages */
+		/* Lock and update the counter of reply messages */
 		spin_lock_irqsave(&sep->snd_rply_lck, lck_flags);
 		sep->reply_ct++;
 		spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
@@ -3241,7 +3236,7 @@ static irqreturn_t sep_inthandler(int irq, void *dev_id)
 		dev_dbg(&sep->pdev->dev, "sep int: send_ct %lx reply_ct %lx\n",
 					sep->send_ct, sep->reply_ct);
 
-		/* is this printf or daemon request? */
+		/* Is this printf or daemon request? */
 		reg_val2 = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR2_REG_ADDR);
 		dev_dbg(&sep->pdev->dev,
 			"SEP Interrupt - reg2 is %08x\n", reg_val2);
@@ -3253,11 +3248,11 @@ static irqreturn_t sep_inthandler(int irq, void *dev_id)
 			dev_dbg(&sep->pdev->dev, "int: daemon request\n");
 			wake_up(&sep->event_request_daemon);
 		} else {
-			dev_dbg(&sep->pdev->dev, "int: sep reply\n");
+			dev_dbg(&sep->pdev->dev, "int: SEP reply\n");
 			wake_up(&sep->event);
 		}
 	} else {
-		dev_dbg(&sep->pdev->dev, "int: not sep interrupt\n");
+		dev_dbg(&sep->pdev->dev, "int: not SEP interrupt\n");
 		int_error = IRQ_NONE;
 	}
 	if (int_error == IRQ_HANDLED)
@@ -3329,20 +3324,20 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 	int error = 0;
 	struct sep_device *sep;
 
-	pr_debug("Sep pci probe starting\n");
+	pr_debug("SEP pci probe starting\n");
 	if (sep_dev != NULL) {
 		dev_warn(&pdev->dev, "only one SEP supported.\n");
 		return -EBUSY;
 	}
 
-	/* enable the device */
+	/* Enable the device */
 	error = pci_enable_device(pdev);
 	if (error) {
 		dev_warn(&pdev->dev, "error enabling pci device\n");
 		goto end_function;
 	}
 
-	/* allocate the sep_device structure for this device */
+	/* Allocate the sep_device structure for this device */
 	sep_dev = kzalloc(sizeof(struct sep_device), GFP_ATOMIC);
 	if (sep_dev == NULL) {
 		dev_warn(&pdev->dev,
@@ -3351,7 +3346,7 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 	}
 
 	/*
-	 * we're going to use another variable for actually
+	 * We're going to use another variable for actually
 	 * working with the device; this way, if we have
 	 * multiple devices in the future, it would be easier
 	 * to make appropriate changes
@@ -3366,7 +3361,7 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 	dev_dbg(&sep->pdev->dev, "PCI obtained, device being prepared\n");
 	dev_dbg(&sep->pdev->dev, "revision is %d\n", sep->pdev->revision);
 
-	/* set up our register area */
+	/* Set up our register area */
 	sep->reg_physical_addr = pci_resource_start(sep->pdev, 0);
 	if (!sep->reg_physical_addr) {
 		dev_warn(&sep->pdev->dev, "Error getting register start\n");
@@ -3395,7 +3390,7 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 		(unsigned long long)sep->reg_physical_end,
 		sep->reg_addr);
 
-	/* allocate the shared area */
+	/* Allocate the shared area */
 	sep->shared_size = SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES +
 		SYNCHRONIC_DMA_TABLES_AREA_SIZE_BYTES +
 		SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES +
@@ -3404,11 +3399,11 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 
 	if (sep_map_and_alloc_shared_area(sep)) {
 		error = -ENOMEM;
-		/* allocation failed */
+		/* Allocation failed */
 		goto end_function_error;
 	}
 
-	/* the next section depends on type of unit */
+	/* The next section depends on type of unit */
 	if (sep->mrst) {
 		error = register_rar(RAR_TYPE_IMAGE, &sep_callback,
 			(unsigned long)sep);
@@ -3435,14 +3430,14 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 
 	dev_dbg(&sep->pdev->dev, "about to write IMR and ICR REG_ADDR\n");
 
-	/* clear ICR register */
+	/* Clear ICR register */
 	sep_write_reg(sep, HW_HOST_ICR_REG_ADDR, 0xFFFFFFFF);
 
-	/* set the IMR register - open only GPR 2 */
+	/* Set the IMR register - open only GPR 2 */
 	sep_write_reg(sep, HW_HOST_IMR_REG_ADDR, (~(0x1 << 13)));
 
 	dev_dbg(&sep->pdev->dev, "about to call request_irq\n");
-	/* get the interrupt line */
+	/* Get the interrupt line */
 	error = request_irq(pdev->irq, sep_inthandler, IRQF_SHARED,
 		"sep_driver", sep);
 
@@ -3455,7 +3450,7 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 	goto end_function;
 
 end_function_deallocate_sep_shared_area:
-	/* de-allocate shared area */
+	/* De-allocate shared area */
 	sep_unmap_and_free_shared_area(sep);
 
 end_function_error:
@@ -3475,7 +3470,7 @@ static DEFINE_PCI_DEVICE_TABLE(sep_pci_id_tbl) = {
 
 MODULE_DEVICE_TABLE(pci, sep_pci_id_tbl);
 
-/* field for registering driver to PCI device */
+/* Field for registering driver to PCI device */
 static struct pci_driver sep_pci_driver = {
 	.name = "sep_sec_driver",
 	.id_table = sep_pci_id_tbl,
@@ -3483,7 +3478,7 @@ static struct pci_driver sep_pci_driver = {
 	/* FIXME: remove handler */
 };
 
-/* file operation for singleton sep operations */
+/* File operation for singleton SEP operations */
 static const struct file_operations singleton_file_operations = {
 	.owner = THIS_MODULE,
 	.unlocked_ioctl = sep_singleton_ioctl,
@@ -3493,7 +3488,7 @@ static const struct file_operations singleton_file_operations = {
 	.mmap = sep_mmap,
 };
 
-/* file operation for daemon operations */
+/* File operation for daemon operations */
 static const struct file_operations daemon_file_operations = {
 	.owner = THIS_MODULE,
 	.unlocked_ioctl = sep_request_daemon_ioctl,
@@ -3503,7 +3498,7 @@ static const struct file_operations daemon_file_operations = {
 	.mmap = sep_request_daemon_mmap,
 };
 
-/* the files operations structure of the driver */
+/* The files operations structure of the driver */
 static const struct file_operations sep_file_operations = {
 	.owner = THIS_MODULE,
 	.unlocked_ioctl = sep_ioctl,
@@ -3526,19 +3521,19 @@ static int sep_reconfig_shared_area(struct sep_device *sep)
 
 	dev_dbg(&sep->pdev->dev, "reconfig shared area start\n");
 
-	/* send the new SHARED MESSAGE AREA to the SEP */
+	/* Send the new SHARED MESSAGE AREA to the SEP */
 	dev_dbg(&sep->pdev->dev, "sending %08llx to sep\n",
 				(unsigned long long)sep->shared_bus);
 
 	sep_write_reg(sep, HW_HOST_HOST_SEP_GPR1_REG_ADDR, sep->shared_bus);
 
-	/* poll for SEP response */
+	/* Poll for SEP response */
 	ret_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR1_REG_ADDR);
 
 	while (ret_val != 0xffffffff && ret_val != sep->shared_bus)
 		ret_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR1_REG_ADDR);
 
-	/* check the return value (register) */
+	/* Check the return value (register) */
 	if (ret_val != sep->shared_bus) {
 		dev_warn(&sep->pdev->dev, "could not reconfig shared area\n");
 		dev_warn(&sep->pdev->dev, "result was %x\n", ret_val);
@@ -3574,7 +3569,7 @@ static int sep_register_driver_to_fs(struct sep_device *sep)
 
 	ret_val = misc_register(&sep->miscdev_sep);
 	if (ret_val) {
-		dev_warn(&sep->pdev->dev, "misc reg fails for sep %x\n",
+		dev_warn(&sep->pdev->dev, "misc reg fails for SEP %x\n",
 			ret_val);
 		return ret_val;
 	}
@@ -3611,7 +3606,7 @@ static int __init sep_init(void)
 	int ret_val = 0;
 	struct sep_device *sep = NULL;
 
-	pr_debug("Sep driver: Init start\n");
+	pr_debug("SEP driver: Init start\n");
 
 	ret_val = pci_register_driver(&sep_pci_driver);
 	if (ret_val) {
@@ -3628,14 +3623,14 @@ static int __init sep_init(void)
 	mutex_init(&sep->sep_mutex);
 	mutex_init(&sep->ioctl_mutex);
 
-	/* new chip requires share area reconfigure */
-	if (sep->pdev->revision == 4) { /* only for new chip */
+	/* The new chip requires ashared area reconfigure */
+	if (sep->pdev->revision == 4) { /* Only for new chip */
 		ret_val = sep_reconfig_shared_area(sep);
 		if (ret_val)
 			goto end_function_unregister_pci;
 	}
 
-	/* register driver to fs */
+	/* Register driver to fs */
 	ret_val = sep_register_driver_to_fs(sep);
 	if (ret_val) {
 		dev_warn(&sep->pdev->dev, "error registering device to file\n");
@@ -3665,18 +3660,18 @@ static void __exit sep_exit(void)
 	sep = sep_dev;
 	pr_debug("Exit start\n");
 
-	/* unregister from fs */
+	/* Unregister from fs */
 	misc_deregister(&sep->miscdev_sep);
 	misc_deregister(&sep->miscdev_singleton);
 	misc_deregister(&sep->miscdev_daemon);
 
-	/* free the irq */
+	/* Free the irq */
 	free_irq(sep->pdev->irq, sep);
 
-	/* unregister the driver */
+	/* Unregister the driver */
 	pci_unregister_driver(&sep_pci_driver);
 
-	/* free shared area  */
+	/* Free the shared area  */
 	if (sep_dev) {
 		sep_unmap_and_free_shared_area(sep_dev);
 		dev_dbg(&sep->pdev->dev,


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 10/12] sep: cant is an angular inclination
  2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
                   ` (8 preceding siblings ...)
  2010-11-24 19:38 ` [PATCH 09/12] sep: Make SEP consistent Alan Cox
@ 2010-11-24 19:38 ` Alan Cox
  2010-11-24 19:39 ` [PATCH 11/12] sep: clean up a couple of spots missed in pass one Alan Cox
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 19:38 UTC (permalink / raw)
  To: greg, mark.a.allyn, linux-kernel

From: Alan Cox <alan@linux.intel.com>

So use can't instead.

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/staging/sep/sep_driver.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index 9c16558..ebe7a90 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -98,7 +98,7 @@ static int sep_load_firmware(struct sep_device *sep)
 
 	error = request_firmware(&fw, res_name, &sep->pdev->dev);
 	if (error) {
-		dev_warn(&sep->pdev->dev, "cant request resident fw\n");
+		dev_warn(&sep->pdev->dev, "can't request resident fw\n");
 		return error;
 	}
 
@@ -3280,7 +3280,7 @@ static int sep_callback(unsigned long sep_context_pointer)
 							&rar_end_address);
 
 	if (error) {
-		dev_warn(&sep->pdev->dev, "mrst cant get rar region\n");
+		dev_warn(&sep->pdev->dev, "mrst can't get rar region\n");
 		goto end_function;
 	}
 
@@ -3417,7 +3417,7 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 		sep->rar_addr = dma_alloc_coherent(NULL,
 			sep->rar_size, &sep->rar_bus, GFP_KERNEL);
 		if (sep->rar_addr == NULL) {
-			dev_warn(&sep->pdev->dev, "cant allocate mfld rar\n");
+			dev_warn(&sep->pdev->dev, "can't allocate mfld rar\n");
 			error = -ENOMEM;
 			goto end_function_deallocate_sep_shared_area;
 		}


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 11/12] sep: clean up a couple of spots missed in pass one
  2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
                   ` (9 preceding siblings ...)
  2010-11-24 19:38 ` [PATCH 10/12] sep: cant is an angular inclination Alan Cox
@ 2010-11-24 19:39 ` Alan Cox
  2010-11-24 19:39 ` [PATCH 12/12] sep: Fix crash if a device is not found Alan Cox
  2010-11-24 20:18 ` [PATCH 00/12] SEP cleanups Randy Dunlap
  12 siblings, 0 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 19:39 UTC (permalink / raw)
  To: greg, mark.a.allyn, linux-kernel

From: Alan Cox <alan@linux.intel.com>

Another copy_user case and some formatting of dbg

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/staging/sep/sep_driver.c |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)


diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index ebe7a90..5e27b5a 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -1037,8 +1037,6 @@ static int sep_allocate_data_pool_memory_handler(struct sep_device *sep,
 		sizeof(struct alloc_struct));
 	if (error) {
 		error = -EFAULT;
-		dev_warn(&sep->pdev->dev,
-			"allocate data pool copy to user error\n");
 		goto end_function;
 	}
 
@@ -1083,13 +1081,10 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
 	/* Map array */
 	struct sep_dma_map *map_array;
 
-	dev_dbg(&sep->pdev->dev,
-		"sep_lock_kernel_pages start\n");
-
-	dev_dbg(&sep->pdev->dev,
-		"kernel_virt_addr is %08x\n", kernel_virt_addr);
-	dev_dbg(&sep->pdev->dev,
-		"data_size is %x\n", data_size);
+	dev_dbg(&sep->pdev->dev, "sep_lock_kernel_pages start\n");
+	dev_dbg(&sep->pdev->dev, "kernel_virt_addr is %08x\n",
+							kernel_virt_addr);
+	dev_dbg(&sep->pdev->dev, "data_size is %x\n", data_size);
 
 	lli_array = kmalloc(sizeof(struct sep_lli_entry), GFP_ATOMIC);
 	if (!lli_array) {
@@ -1182,8 +1177,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
 	/* Direction of the DMA mapping for locked pages */
 	enum dma_data_direction	dir;
 
-	dev_dbg(&sep->pdev->dev,
-		"sep_lock_user_pages start\n");
+	dev_dbg(&sep->pdev->dev, "sep_lock_user_pages start\n");
 
 	/* Set start and end pages  and num pages */
 	end_page = (app_virt_addr + data_size - 1) >> PAGE_SHIFT;


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 12/12] sep: Fix crash if a device is not found
  2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
                   ` (10 preceding siblings ...)
  2010-11-24 19:39 ` [PATCH 11/12] sep: clean up a couple of spots missed in pass one Alan Cox
@ 2010-11-24 19:39 ` Alan Cox
  2010-11-24 20:18 ` [PATCH 00/12] SEP cleanups Randy Dunlap
  12 siblings, 0 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 19:39 UTC (permalink / raw)
  To: greg, mark.a.allyn, linux-kernel

From: Alan Cox <alan@linux.intel.com>

The existing code works mostly by luck. The PCI probe is done by the
register and completes before the register returns thus allowing the other
init code to run in time. Without a SEP or if unlucky this doesn't occur
and you get an OOPS which for some reason causes grumpiness.

As the season of good b^Hcheer is supposed to be approaching we should
probably fix it.

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/staging/sep/sep_driver.c |  363 +++++++++++++++++---------------------
 1 files changed, 167 insertions(+), 196 deletions(-)


diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index 5e27b5a..7633111 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -256,8 +256,7 @@ static int sep_singleton_open(struct inode *inode_ptr, struct file *file_ptr)
 
 	file_ptr->private_data = sep;
 
-	dev_dbg(&sep->pdev->dev, "Singleton open for pid %d\n",
-		current->pid);
+	dev_dbg(&sep->pdev->dev, "Singleton open for pid %d\n", current->pid);
 
 	dev_dbg(&sep->pdev->dev, "calling test and set for singleton 0\n");
 	if (test_and_set_bit(0, &sep->singleton_access_flag)) {
@@ -265,10 +264,8 @@ static int sep_singleton_open(struct inode *inode_ptr, struct file *file_ptr)
 		goto end_function;
 	}
 
-	dev_dbg(&sep->pdev->dev,
-		"sep_singleton_open end\n");
+	dev_dbg(&sep->pdev->dev, "sep_singleton_open end\n");
 end_function:
-
 	return error;
 }
 
@@ -386,9 +383,7 @@ static int sep_req_daemon_send_reply_command_handler(struct sep_device *sep)
 	sep->reply_ct++;
 
 	/* Send the interrupt to SEP */
-	sep_write_reg(sep, HW_HOST_HOST_SEP_GPR2_REG_ADDR,
-		sep->send_ct);
-
+	sep_write_reg(sep, HW_HOST_HOST_SEP_GPR2_REG_ADDR, sep->send_ct);
 	sep->send_ct++;
 
 	spin_unlock_irqrestore(&sep->snd_rply_lck, lck_flags);
@@ -3305,6 +3300,125 @@ end_function:
 }
 
 /**
+ *	sep_reconfig_shared_area - reconfigure shared area
+ *	@sep: pointer to struct sep_device
+ *
+ *	Reconfig the shared area between HOST and SEP - needed in case
+ *	the DX_CC_Init function was called before OS loading.
+ */
+static int sep_reconfig_shared_area(struct sep_device *sep)
+{
+	int ret_val;
+
+	dev_dbg(&sep->pdev->dev, "reconfig shared area start\n");
+
+	/* Send the new SHARED MESSAGE AREA to the SEP */
+	dev_dbg(&sep->pdev->dev, "sending %08llx to sep\n",
+				(unsigned long long)sep->shared_bus);
+
+	sep_write_reg(sep, HW_HOST_HOST_SEP_GPR1_REG_ADDR, sep->shared_bus);
+
+	/* Poll for SEP response */
+	ret_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR1_REG_ADDR);
+
+	while (ret_val != 0xffffffff && ret_val != sep->shared_bus)
+		ret_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR1_REG_ADDR);
+
+	/* Check the return value (register) */
+	if (ret_val != sep->shared_bus) {
+		dev_warn(&sep->pdev->dev, "could not reconfig shared area\n");
+		dev_warn(&sep->pdev->dev, "result was %x\n", ret_val);
+		ret_val = -ENOMEM;
+	} else
+		ret_val = 0;
+
+	dev_dbg(&sep->pdev->dev, "reconfig shared area end\n");
+	return ret_val;
+}
+
+/* File operation for singleton SEP operations */
+static const struct file_operations singleton_file_operations = {
+	.owner = THIS_MODULE,
+	.unlocked_ioctl = sep_singleton_ioctl,
+	.poll = sep_poll,
+	.open = sep_singleton_open,
+	.release = sep_singleton_release,
+	.mmap = sep_mmap,
+};
+
+/* File operation for daemon operations */
+static const struct file_operations daemon_file_operations = {
+	.owner = THIS_MODULE,
+	.unlocked_ioctl = sep_request_daemon_ioctl,
+	.poll = sep_request_daemon_poll,
+	.open = sep_request_daemon_open,
+	.release = sep_request_daemon_release,
+	.mmap = sep_request_daemon_mmap,
+};
+
+/* The files operations structure of the driver */
+static const struct file_operations sep_file_operations = {
+	.owner = THIS_MODULE,
+	.unlocked_ioctl = sep_ioctl,
+	.poll = sep_poll,
+	.open = sep_open,
+	.release = sep_release,
+	.mmap = sep_mmap,
+};
+
+/**
+ *	sep_register_driver_with_fs - register misc devices
+ *	@sep: pointer to struct sep_device
+ *
+ *	This function registers the driver with the file system
+ */
+static int sep_register_driver_with_fs(struct sep_device *sep)
+{
+	int ret_val;
+
+	sep->miscdev_sep.minor = MISC_DYNAMIC_MINOR;
+	sep->miscdev_sep.name = SEP_DEV_NAME;
+	sep->miscdev_sep.fops = &sep_file_operations;
+
+	sep->miscdev_singleton.minor = MISC_DYNAMIC_MINOR;
+	sep->miscdev_singleton.name = SEP_DEV_SINGLETON;
+	sep->miscdev_singleton.fops = &singleton_file_operations;
+
+	sep->miscdev_daemon.minor = MISC_DYNAMIC_MINOR;
+	sep->miscdev_daemon.name = SEP_DEV_DAEMON;
+	sep->miscdev_daemon.fops = &daemon_file_operations;
+
+	ret_val = misc_register(&sep->miscdev_sep);
+	if (ret_val) {
+		dev_warn(&sep->pdev->dev, "misc reg fails for SEP %x\n",
+			ret_val);
+		return ret_val;
+	}
+
+	ret_val = misc_register(&sep->miscdev_singleton);
+	if (ret_val) {
+		dev_warn(&sep->pdev->dev, "misc reg fails for sing %x\n",
+			ret_val);
+		misc_deregister(&sep->miscdev_sep);
+		return ret_val;
+	}
+
+	if (!sep->mrst) {
+		ret_val = misc_register(&sep->miscdev_daemon);
+		if (ret_val) {
+			dev_warn(&sep->pdev->dev, "misc reg fails for dmn %x\n",
+				ret_val);
+			misc_deregister(&sep->miscdev_sep);
+			misc_deregister(&sep->miscdev_singleton);
+
+			return ret_val;
+		}
+	}
+	return ret_val;
+}
+
+
+/**
  *	sep_probe - probe a matching PCI device
  *	@pdev: pci_device
  *	@end: pci_device_id
@@ -3349,6 +3463,12 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 
 	sep->pdev = pdev;
 
+	init_waitqueue_head(&sep->event);
+	init_waitqueue_head(&sep->event_request_daemon);
+	spin_lock_init(&sep->snd_rply_lck);
+	mutex_init(&sep->sep_mutex);
+	mutex_init(&sep->ioctl_mutex);
+
 	if (pdev->device == MRST_PCI_DEVICE_ID)
 		sep->mrst = 1;
 
@@ -3435,9 +3555,26 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 	error = request_irq(pdev->irq, sep_inthandler, IRQF_SHARED,
 		"sep_driver", sep);
 
-	if (!error)
-		goto end_function;
+	if (error)
+		goto end_function_dealloc_rar;
 
+	/* The new chip requires ashared area reconfigure */
+	if (sep->pdev->revision == 4) { /* Only for new chip */
+		error = sep_reconfig_shared_area(sep);
+		if (error)
+			goto end_function_free_irq;
+	}
+	/* Finally magic up the device nodes */
+	/* Register driver with the fs */
+	error = sep_register_driver_with_fs(sep);
+	if (error == 0)
+		/* Success */
+		return 0;
+		
+end_function_free_irq:
+	free_irq(pdev->irq, sep);
+
+end_function_dealloc_rar:
 	if (sep->rar_addr)
 		dma_free_coherent(&sep->pdev->dev, sep->rar_size,
 			sep->rar_addr, sep->rar_bus);
@@ -3456,6 +3593,23 @@ end_function:
 	return error;
 }
 
+static void sep_remove(struct pci_dev *pdev)
+{
+	struct sep_device *sep = sep_dev;
+
+	/* Unregister from fs */
+	misc_deregister(&sep->miscdev_sep);
+	misc_deregister(&sep->miscdev_singleton);
+	misc_deregister(&sep->miscdev_daemon);
+
+	/* Free the irq */
+	free_irq(sep->pdev->irq, sep);
+
+	/* Free the shared area  */
+	sep_unmap_and_free_shared_area(sep_dev);
+	iounmap((void *) sep_dev->reg_addr);
+}
+
 static DEFINE_PCI_DEVICE_TABLE(sep_pci_id_tbl) = {
 	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, MRST_PCI_DEVICE_ID)},
 	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, MFLD_PCI_DEVICE_ID)},
@@ -3468,127 +3622,10 @@ MODULE_DEVICE_TABLE(pci, sep_pci_id_tbl);
 static struct pci_driver sep_pci_driver = {
 	.name = "sep_sec_driver",
 	.id_table = sep_pci_id_tbl,
-	.probe = sep_probe
-	/* FIXME: remove handler */
+	.probe = sep_probe,
+	.remove = sep_remove
 };
 
-/* File operation for singleton SEP operations */
-static const struct file_operations singleton_file_operations = {
-	.owner = THIS_MODULE,
-	.unlocked_ioctl = sep_singleton_ioctl,
-	.poll = sep_poll,
-	.open = sep_singleton_open,
-	.release = sep_singleton_release,
-	.mmap = sep_mmap,
-};
-
-/* File operation for daemon operations */
-static const struct file_operations daemon_file_operations = {
-	.owner = THIS_MODULE,
-	.unlocked_ioctl = sep_request_daemon_ioctl,
-	.poll = sep_request_daemon_poll,
-	.open = sep_request_daemon_open,
-	.release = sep_request_daemon_release,
-	.mmap = sep_request_daemon_mmap,
-};
-
-/* The files operations structure of the driver */
-static const struct file_operations sep_file_operations = {
-	.owner = THIS_MODULE,
-	.unlocked_ioctl = sep_ioctl,
-	.poll = sep_poll,
-	.open = sep_open,
-	.release = sep_release,
-	.mmap = sep_mmap,
-};
-
-/**
- *	sep_reconfig_shared_area - reconfigure shared area
- *	@sep: pointer to struct sep_device
- *
- *	Reconfig the shared area between HOST and SEP - needed in case
- *	the DX_CC_Init function was called before OS loading.
- */
-static int sep_reconfig_shared_area(struct sep_device *sep)
-{
-	int ret_val;
-
-	dev_dbg(&sep->pdev->dev, "reconfig shared area start\n");
-
-	/* Send the new SHARED MESSAGE AREA to the SEP */
-	dev_dbg(&sep->pdev->dev, "sending %08llx to sep\n",
-				(unsigned long long)sep->shared_bus);
-
-	sep_write_reg(sep, HW_HOST_HOST_SEP_GPR1_REG_ADDR, sep->shared_bus);
-
-	/* Poll for SEP response */
-	ret_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR1_REG_ADDR);
-
-	while (ret_val != 0xffffffff && ret_val != sep->shared_bus)
-		ret_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR1_REG_ADDR);
-
-	/* Check the return value (register) */
-	if (ret_val != sep->shared_bus) {
-		dev_warn(&sep->pdev->dev, "could not reconfig shared area\n");
-		dev_warn(&sep->pdev->dev, "result was %x\n", ret_val);
-		ret_val = -ENOMEM;
-	} else
-		ret_val = 0;
-
-	dev_dbg(&sep->pdev->dev, "reconfig shared area end\n");
-	return ret_val;
-}
-
-/**
- *	sep_register_driver_to_fs - register misc devices
- *	@sep: pointer to struct sep_device
- *
- *	This function registers the driver to the file system
- */
-static int sep_register_driver_to_fs(struct sep_device *sep)
-{
-	int ret_val;
-
-	sep->miscdev_sep.minor = MISC_DYNAMIC_MINOR;
-	sep->miscdev_sep.name = SEP_DEV_NAME;
-	sep->miscdev_sep.fops = &sep_file_operations;
-
-	sep->miscdev_singleton.minor = MISC_DYNAMIC_MINOR;
-	sep->miscdev_singleton.name = SEP_DEV_SINGLETON;
-	sep->miscdev_singleton.fops = &singleton_file_operations;
-
-	sep->miscdev_daemon.minor = MISC_DYNAMIC_MINOR;
-	sep->miscdev_daemon.name = SEP_DEV_DAEMON;
-	sep->miscdev_daemon.fops = &daemon_file_operations;
-
-	ret_val = misc_register(&sep->miscdev_sep);
-	if (ret_val) {
-		dev_warn(&sep->pdev->dev, "misc reg fails for SEP %x\n",
-			ret_val);
-		return ret_val;
-	}
-
-	ret_val = misc_register(&sep->miscdev_singleton);
-	if (ret_val) {
-		dev_warn(&sep->pdev->dev, "misc reg fails for sing %x\n",
-			ret_val);
-		misc_deregister(&sep->miscdev_sep);
-		return ret_val;
-	}
-
-	if (!sep->mrst) {
-		ret_val = misc_register(&sep->miscdev_daemon);
-		if (ret_val) {
-			dev_warn(&sep->pdev->dev, "misc reg fails for dmn %x\n",
-				ret_val);
-			misc_deregister(&sep->miscdev_sep);
-			misc_deregister(&sep->miscdev_singleton);
-
-			return ret_val;
-		}
-	}
-	return ret_val;
-}
 
 /**
  *	sep_init - init function
@@ -3597,47 +3634,7 @@ static int sep_register_driver_to_fs(struct sep_device *sep)
  */
 static int __init sep_init(void)
 {
-	int ret_val = 0;
-	struct sep_device *sep = NULL;
-
-	pr_debug("SEP driver: Init start\n");
-
-	ret_val = pci_register_driver(&sep_pci_driver);
-	if (ret_val) {
-		pr_debug("sep_driver:sep_driver_to_device failed, ret_val is %d\n",
-								ret_val);
-		goto end_function;
-	}
-
-	sep = sep_dev;
-
-	init_waitqueue_head(&sep->event);
-	init_waitqueue_head(&sep->event_request_daemon);
-	spin_lock_init(&sep->snd_rply_lck);
-	mutex_init(&sep->sep_mutex);
-	mutex_init(&sep->ioctl_mutex);
-
-	/* The new chip requires ashared area reconfigure */
-	if (sep->pdev->revision == 4) { /* Only for new chip */
-		ret_val = sep_reconfig_shared_area(sep);
-		if (ret_val)
-			goto end_function_unregister_pci;
-	}
-
-	/* Register driver to fs */
-	ret_val = sep_register_driver_to_fs(sep);
-	if (ret_val) {
-		dev_warn(&sep->pdev->dev, "error registering device to file\n");
-		goto end_function_unregister_pci;
-	}
-	goto end_function;
-
-end_function_unregister_pci:
-	pci_unregister_driver(&sep_pci_driver);
-
-end_function:
-	dev_dbg(&sep->pdev->dev, "Init end\n");
-	return ret_val;
+	return pci_register_driver(&sep_pci_driver);
 }
 
 
@@ -3649,33 +3646,7 @@ end_function:
  */
 static void __exit sep_exit(void)
 {
-	struct sep_device *sep;
-
-	sep = sep_dev;
-	pr_debug("Exit start\n");
-
-	/* Unregister from fs */
-	misc_deregister(&sep->miscdev_sep);
-	misc_deregister(&sep->miscdev_singleton);
-	misc_deregister(&sep->miscdev_daemon);
-
-	/* Free the irq */
-	free_irq(sep->pdev->irq, sep);
-
-	/* Unregister the driver */
 	pci_unregister_driver(&sep_pci_driver);
-
-	/* Free the shared area  */
-	if (sep_dev) {
-		sep_unmap_and_free_shared_area(sep_dev);
-		dev_dbg(&sep->pdev->dev,
-			"free pages SEP SHARED AREA\n");
-		iounmap((void *) sep_dev->reg_addr);
-		dev_dbg(&sep->pdev->dev,
-			"iounmap\n");
-	}
-	pr_debug("release_mem_region\n");
-	pr_debug("Exit end\n");
 }
 
 


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 00/12] SEP cleanups
  2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
                   ` (11 preceding siblings ...)
  2010-11-24 19:39 ` [PATCH 12/12] sep: Fix crash if a device is not found Alan Cox
@ 2010-11-24 20:18 ` Randy Dunlap
  2010-11-24 22:19   ` Alan Cox
  12 siblings, 1 reply; 15+ messages in thread
From: Randy Dunlap @ 2010-11-24 20:18 UTC (permalink / raw)
  To: Alan Cox; +Cc: greg, mark.a.allyn, linux-kernel

On Wed, 24 Nov 2010 19:23:46 +0000 Alan Cox wrote:

> This is a rework from the bits I sent you a while back Mark (which I suspect
> got eaten in the email) and some other cleanup. I've not beaten it up with
> CodingStyle yet because most of the debug wants removing before that is done
> so it is probably more productive to fix the logic and the inherited choice of
> TRUELY_GIANT_DEFINE_NAMES_THAT_CAUSE_MUCH_WRAPPING before we worry about finer
> points of style.

TRULY.  (or is that Brit. vs. Amer.?)



How about someone addressing these printk format warnings (linux-next)?

drivers/staging/sep/sep_driver.c:115: warning: format '%08x' expects type 'unsigned int', but argument 4 has type 'size_t'
drivers/staging/sep/sep_driver.c:149: warning: format '%08x' expects type 'unsigned int', but argument 4 has type 'size_t'
drivers/staging/sep/sep_driver.c:170: warning: format '%08x' expects type 'unsigned int', but argument 4 has type 'size_t'
drivers/staging/sep/sep_driver.c:212: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'size_t'
drivers/staging/sep/sep_driver.c:3397: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'long unsigned int'
drivers/staging/sep/sep_driver.c:3399: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'long unsigned int'
drivers/staging/sep/sep_driver.c:3405: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'long unsigned int'
drivers/staging/sep/sep_driver.c:3407: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'long unsigned int'
drivers/staging/sep/sep_driver.c:3411: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'long unsigned int'
drivers/staging/sep/sep_driver.c:3413: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'long unsigned int'
drivers/staging/sep/sep_driver.c:3415: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'long unsigned int'
drivers/staging/sep/sep_driver.c:3738: warning: format '%x' expects type 'unsigned int', but argument 6 has type 'size_t'
drivers/staging/sep/sep_driver.c:3866: warning: format '%x' expects type 'unsigned int', but argument 6 has type 'size_t'



---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 00/12] SEP cleanups
  2010-11-24 20:18 ` [PATCH 00/12] SEP cleanups Randy Dunlap
@ 2010-11-24 22:19   ` Alan Cox
  0 siblings, 0 replies; 15+ messages in thread
From: Alan Cox @ 2010-11-24 22:19 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: greg, mark.a.allyn, linux-kernel

> TRULY.  (or is that Brit. vs. Amer.?)

English prefers 'truely'

> How about someone addressing these printk format warnings (linux-next)?

Its on the list if Mark doesn't get a moment to tackle them.



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2010-11-24 22:20 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-24 19:23 [PATCH 00/12] SEP cleanups Alan Cox
2010-11-24 19:33 ` [PATCH 01/12] sep: minimal fix for wrong include Alan Cox
2010-11-24 19:33 ` [PATCH 02/12] sep: handle the rar definition stuff in the header Alan Cox
2010-11-24 19:33 ` [PATCH 03/12] sep: handle the memrar stuff in the headers Alan Cox
2010-11-24 19:34 ` [PATCH 04/12] sep: netlink - what netlink Alan Cox
2010-11-24 19:34 ` [PATCH 05/12] sep: clean up caller_id function Alan Cox
2010-11-24 19:34 ` [PATCH 06/12] sep: Fix the kernel-doc in SEP Alan Cox
2010-11-24 19:38 ` [PATCH 07/12] sep: clean up some of the obvious sillies Alan Cox
2010-11-24 19:38 ` [PATCH 08/12] sep: Use kzalloc when needed Alan Cox
2010-11-24 19:38 ` [PATCH 09/12] sep: Make SEP consistent Alan Cox
2010-11-24 19:38 ` [PATCH 10/12] sep: cant is an angular inclination Alan Cox
2010-11-24 19:39 ` [PATCH 11/12] sep: clean up a couple of spots missed in pass one Alan Cox
2010-11-24 19:39 ` [PATCH 12/12] sep: Fix crash if a device is not found Alan Cox
2010-11-24 20:18 ` [PATCH 00/12] SEP cleanups Randy Dunlap
2010-11-24 22:19   ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).