All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Misc: pass miscdevice through file's private_data
@ 2014-12-04 21:08 Tom Van Braeckel
  2014-12-04 21:13 ` Greg KH
  0 siblings, 1 reply; 14+ messages in thread
From: Tom Van Braeckel @ 2014-12-04 21:08 UTC (permalink / raw)
  To: arnd, gregkh, linux-kernel; +Cc: Tom Van Braeckel

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


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

end of thread, other threads:[~2015-03-31 13:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-04 21:08 [PATCH] Misc: pass miscdevice through file's private_data Tom Van Braeckel
2014-12-04 21:13 ` Greg KH
2014-12-04 23:01   ` Tom Van Braeckel
2014-12-04 23:29     ` Greg KH
2014-12-05  4:37       ` [PATCH] misc: " Tom Van Braeckel
2015-01-09 23:02         ` Greg KH
2015-01-11 15:44           ` Tom Van Braeckel
2015-03-23 12:59             ` always assign miscdevice to file->private_data Martin Kepplinger
2015-03-23 12:59               ` [PATCH 1/4] char: misc: document behaviour of open() Martin Kepplinger
2015-03-23 12:59               ` [PATCH 2/4] fbdev: pxa3xx-gcu: remove redundant implementation " Martin Kepplinger
2015-03-23 12:59               ` [PATCH 3/4] fs: btrfs: set file->private data NULL after open() because we depend on it Martin Kepplinger
2015-03-23 12:59               ` [PATCH 4/4] lguest: explicitly set miscdevice's private_data NULL Martin Kepplinger
2015-03-31 13:08             ` [PATCH] misc: pass miscdevice through file's private_data Tom Van Braeckel
2015-03-31 13:19               ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.