* Initialize seq->private before seq_start()
@ 2002-11-01 23:12 Max Krasnyansky
0 siblings, 0 replies; only message in thread
From: Max Krasnyansky @ 2002-11-01 23:12 UTC (permalink / raw)
To: linux-kernel
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-11-01 23:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-01 23:12 Initialize seq->private before seq_start() Max Krasnyansky
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®