lkml.org 
[lkml]   [2014]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] Misc: pass miscdevice through file's private_data
Date
Place the miscdevice in the file's private_data to be used by the file operations.

Previously, this was done only when an open() operation had been registered.
But it is also useful in the other file operations, so we pass it on unconditionally.

Signed-off-by: Tom Van Braeckel <tomvanbraeckel@gmail.com>
---
drivers/char/misc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index ffa97d2..c3681fb 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -140,10 +140,16 @@ static int misc_open(struct inode * inode, struct file * file)
goto fail;
}

+ /*
+ * Place the miscdevice in the file's
+ * private_data so it can be used by the
+ * file operations, including f_op->open below
+ */
+ file->private_data = c;
+
err = 0;
replace_fops(file, new_fops);
if (file->f_op->open) {
- file->private_data = c;
err = file->f_op->open(inode,file);
}
fail:
--
1.9.1


\
 
 \ /
  Last update: 2014-12-04 22:41    [W:0.986 / U:1.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site