From: Max Krasnyansky <maxk@qualcomm.com>
To: linux-kernel@vger.kernel.org
Subject: Initialize seq->private before seq_start()
Date: Fri, 01 Nov 2002 15:12:47 -0800 [thread overview]
Message-ID: <5.1.0.14.2.20021101145232.0810d608@mail1.qualcomm.com> (raw)
Folks,
Currently seq_file API doesn't provide any way to initialize seq->private before
seq_start() is called. In most cases seq_start() uses global tables and
stuff and therefor doesn't need seq->private. However there are cases like
proc/something/0/table
...
proc/something/N/table
and seq_start() has to know where to look for table N.
So, how about something like:
#define seq_open(file, op) __seq_open(file, op, NULL)
int __seq_open(struct file *file, struct seq_operations *op, void *priv)
{
struct seq_file *p = kmalloc(sizeof(*p), GFP_KERNEL);
if (!p)
return -ENOMEM;
memset(p, 0, sizeof(*p));
sema_init(&p->sem, 1);
p->op = op;
p->private = priv;
file->private_data = p;
return 0;
}
Those who need seq->private in seq_start() (that'd be me :)) will use __seq_open().
Currently I have
static int hci_seq_open(struct file *file, struct seq_operations *op, void *priv)
{
struct seq_file *seq;
if (seq_open(file, op))
return -ENOMEM;
seq = file->private_data;
seq->private = priv;
return 0;
}
and it'd be nice if I could get rid of that function and use __seq_file instead.
Max
http://bluez.sf.net
http://vtun.sf.net
reply other threads:[~2002-11-01 23:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=5.1.0.14.2.20021101145232.0810d608@mail1.qualcomm.com \
--to=maxk@qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
/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®