]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/seq_file.c
new helper: single_open_size()
[karo-tx-linux.git] / fs / seq_file.c
index 38bb59f3f2add2aad3ad19af5086f00911ce2f66..774c1eb7f1c926c73a7018ae47d9cfb03f75da76 100644 (file)
@@ -599,6 +599,24 @@ int single_open(struct file *file, int (*show)(struct seq_file *, void *),
 }
 EXPORT_SYMBOL(single_open);
 
+int single_open_size(struct file *file, int (*show)(struct seq_file *, void *),
+               void *data, size_t size)
+{
+       char *buf = kmalloc(size, GFP_KERNEL);
+       int ret;
+       if (!buf)
+               return -ENOMEM;
+       ret = single_open(file, show, data);
+       if (ret) {
+               kfree(buf);
+               return ret;
+       }
+       ((struct seq_file *)file->private_data)->buf = buf;
+       ((struct seq_file *)file->private_data)->size = size;
+       return 0;
+}
+EXPORT_SYMBOL(single_open_size);
+
 int single_release(struct inode *inode, struct file *file)
 {
        const struct seq_operations *op = ((struct seq_file *)file->private_data)->op;