From: J Freyensee <[email protected]>

>From a previous Meego upstream review, it was asked to use
get_task_comm() for the needs of this driver.  Well, that
breaks kernel module compilation. The workaround is the
exact same code found in fs/exec.c was cut-and-pasted and
made a local static function,
as it was deemed bad to use the global variable 'current'
(which other drivers accepted in the kernel do).

Change-Id: I8290ec594c37801a588c2757a08c91e8f4e2b813

Signed-off-by: J Freyensee <[email protected]>
---
 drivers/misc/pti.c |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c
index f314110..3810127 100644
--- a/drivers/misc/pti.c
+++ b/drivers/misc/pti.c
@@ -148,6 +148,26 @@ static void pti_write_to_aperture(struct masterchannel 
*mc, u8 *buf, int len)
 }
 
 /**
+ * This function is found in fs/exec.c; however, it is needed
+ * here because there is a kernel bug in which a driver who
+ * uses this function will break compilation if it's configured
+ * as a module.  Despite other drivers already accepted in the
+ * kernel accessing the global 'current' variable freely,
+ * this has been deemed a bad practice, and it was
+ * suggested by upstream reviewers to use get_task_comm().
+ * Thus, the fs/exec.c function code has been copied and renamed
+ * here to suit this driver's needs.
+ */
+static char *pti_get_task_comm(char *buf, struct task_struct *tsk)
+{
+       /* buf must be at least sizeof(tsk->comm) in size */
+       task_lock(tsk);
+       strncpy(buf, tsk->comm, sizeof(tsk->comm));
+       task_unlock(tsk);
+       return buf;
+}
+
+/**
  *  pti_control_frame_built_and_sent() - control frame build and send function.
  *  @mc: The master / channel structure on which the function built a control
  *  frame.
@@ -159,7 +179,6 @@ static void pti_write_to_aperture(struct masterchannel *mc, 
u8 *buf, int len)
  *  The overhead is only 32 bytes since the driver only writes to HW
  *  in 32 byte chunks.
  */
-
 static void pti_control_frame_built_and_sent(struct masterchannel *mc)
 {
        struct masterchannel mccontrol = {.master = CONTROL_ID, .channel = 0};
@@ -169,10 +188,10 @@ static void pti_control_frame_built_and_sent(struct 
masterchannel *mc)
        u8 control_frame[CONTROL_FRAME_LEN];
 
        if (!in_interrupt())
-               get_task_comm(comm, current);
+               pti_get_task_comm(comm, current);
        else
                strcpy(comm, "Interrupt");
-               
+
        /* Ensure our buffer is zero terminated */
        comm[sizeof(current->comm)] = 0;
 
-- 
1.6.6.1

_______________________________________________
Meego-kernel mailing list
[email protected]
http://lists.meego.com/listinfo/meego-kernel

Reply via email to