mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Martin Kepplinger <martink@posteo.de>
To: rusty@rustcorp.com.au
Cc: lguest@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	tomvanbraeckel@gmail.com, Martin Kepplinger <martink@posteo.de>
Subject: [PATCH] lguest: explicitly set miscdevice's private_data NULL
Date: Mon, 23 Mar 2015 13:36:08 +0100	[thread overview]
Message-ID: <1427114168-32730-1-git-send-email-martink@posteo.de> (raw)

There is a proposed change to the miscdevice's behaviour on open(). Currently
file->private_data stays NULL, but only because we don't have an open-entry in
struct file_operations.

This may change so that private_data, more consistently, is always set to
struct miscdevice, not only *if* the driver has it's own open() routine and
fops-entry, see https://lkml.org/lkml/2014/12/4/939 and commit
94e4fe2cab3d43b3ba7c3f721743006a8c9d913a

In short: If we rely on file->private_data being NULL, we should ensure
it is NULL ourselves.

Signed-off-by: Martin Kepplinger <martink@posteo.de>
---
 drivers/lguest/lguest_user.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index c4c6113..30c6068 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -339,6 +339,13 @@ static ssize_t write(struct file *file, const char __user *in,
 	}
 }
 
+static int open(struct inode *inode, struct file *file)
+{
+	file->private_data = NULL;
+
+	return 0;
+}
+
 /*L:060
  * The final piece of interface code is the close() routine.  It reverses
  * everything done in initialize().  This is usually called because the
@@ -409,6 +416,7 @@ static int close(struct inode *inode, struct file *file)
  */
 static const struct file_operations lguest_fops = {
 	.owner	 = THIS_MODULE,
+	.open	 = open,
 	.release = close,
 	.write	 = write,
 	.read	 = read,
-- 
2.1.4


             reply	other threads:[~2015-03-23 12:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-23 12:36 Martin Kepplinger [this message]
2015-03-24  1:22 ` Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1427114168-32730-1-git-send-email-martink@posteo.de \
    --to=martink@posteo.de \
    --cc=lguest@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=tomvanbraeckel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®