be2net: return error status from be_mcc_notify()
[cascardo/linux.git] / fs / seq_file.c
index 555f821..1d9c1cb 100644 (file)
@@ -48,18 +48,21 @@ static void *seq_buf_alloc(unsigned long size)
  *     ERR_PTR(error).  In the end of sequence they return %NULL. ->show()
  *     returns 0 in case of success and negative number in case of error.
  *     Returning SEQ_SKIP means "discard this element and move on".
+ *     Note: seq_open() will allocate a struct seq_file and store its
+ *     pointer in @file->private_data. This pointer should not be modified.
  */
 int seq_open(struct file *file, const struct seq_operations *op)
 {
-       struct seq_file *p = file->private_data;
+       struct seq_file *p;
+
+       WARN_ON(file->private_data);
+
+       p = kzalloc(sizeof(*p), GFP_KERNEL);
+       if (!p)
+               return -ENOMEM;
+
+       file->private_data = p;
 
-       if (!p) {
-               p = kmalloc(sizeof(*p), GFP_KERNEL);
-               if (!p)
-                       return -ENOMEM;
-               file->private_data = p;
-       }
-       memset(p, 0, sizeof(*p));
        mutex_init(&p->lock);
        p->op = op;
 #ifdef CONFIG_USER_NS
@@ -538,6 +541,7 @@ int seq_dentry(struct seq_file *m, struct dentry *dentry, const char *esc)
 
        return res;
 }
+EXPORT_SYMBOL(seq_dentry);
 
 static void *single_start(struct seq_file *p, loff_t *pos)
 {