[FE training-materials-updates] kernel labs: add Thomas' patch to the misc framework
Michael Opdenacker
michael.opdenacker at free-electrons.com
Fri Oct 4 13:55:36 CEST 2013
Repository : git://git.free-electrons.com/training-materials.git
On branch : master
Link : http://git.free-electrons.com/training-materials/commit/?id=890ccfae586e442ba610c67db371b79f006b7ecd
>---------------------------------------------------------------
commit 890ccfae586e442ba610c67db371b79f006b7ecd
Author: Michael Opdenacker <michael.opdenacker at free-electrons.com>
Date: Fri Oct 4 11:14:58 2013 +0200
kernel labs: add Thomas' patch to the misc framework
Signed-off-by: Michael Opdenacker <michael.opdenacker at free-electrons.com>
>---------------------------------------------------------------
890ccfae586e442ba610c67db371b79f006b7ecd
...isc-assign-file-private_data-in-all-cases.patch | 43 ++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/lab-data/linux/src/patches/0001-char-misc-assign-file-private_data-in-all-cases.patch b/lab-data/linux/src/patches/0001-char-misc-assign-file-private_data-in-all-cases.patch
new file mode 100644
index 0000000..5427e05
--- /dev/null
+++ b/lab-data/linux/src/patches/0001-char-misc-assign-file-private_data-in-all-cases.patch
@@ -0,0 +1,43 @@
+From 4547bfff95be09924d190351169dfd810489dcee Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
+Date: Fri, 21 Jun 2013 14:43:13 +0200
+Subject: [PATCH 1/6] char: misc: assign file->private_data in all cases
+
+In fa1f68db6ca ("drivers: misc: pass miscdevice pointer via file
+private data"), the misc driver infrastructure was changed to assigned
+file->private_data as a pointer to the 'struct miscdevice' that
+corresponds to the device being opened.
+
+However, this assignment was only done when the misc driver was
+declaring a driver-specific ->open() operation in its
+file_operations. This doesn't make sense, as the driver may not
+necessarily have a custom ->open() operation, and might still be
+interested in having file->private_data properly set for use in its
+->read() and write() operations.
+
+Therefore, we move the assignment of file->private_data outside of the
+condition that tests whether a driver-specific ->open() operation was
+defined.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
+---
+ drivers/char/misc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/char/misc.c b/drivers/char/misc.c
+index 190d442..fd504d3 100644
+--- a/drivers/char/misc.c
++++ b/drivers/char/misc.c
+@@ -143,8 +143,8 @@ static int misc_open(struct inode * inode, struct file * file)
+ err = 0;
+ old_fops = file->f_op;
+ file->f_op = new_fops;
++ file->private_data = c;
+ if (file->f_op->open) {
+- file->private_data = c;
+ err=file->f_op->open(inode,file);
+ if (err) {
+ fops_put(file->f_op);
+--
+1.8.1.2
+
More information about the training-materials-updates
mailing list