From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753493AbbCXCBx (ORCPT ); Mon, 23 Mar 2015 22:01:53 -0400 Received: from ozlabs.org ([103.22.144.67]:46106 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752855AbbCXCBq (ORCPT ); Mon, 23 Mar 2015 22:01:46 -0400 From: Rusty Russell To: Martin Kepplinger Cc: lguest@lists.ozlabs.org, linux-kernel@vger.kernel.org, tomvanbraeckel@gmail.com, Martin Kepplinger Subject: Re: [PATCH] lguest: explicitly set miscdevice's private_data NULL In-Reply-To: <1427114168-32730-1-git-send-email-martink@posteo.de> References: <1427114168-32730-1-git-send-email-martink@posteo.de> User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Tue, 24 Mar 2015 11:52:19 +1030 Message-ID: <87iodri3zo.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Martin Kepplinger writes: > 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 OK, applied. Thanks, Rusty. > --- > 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 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/