3 * Copyright © 2010 - 2013 UNISYS CORPORATION
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT. See the GNU General Public License for more
21 #define MYDRVNAME "timskmodutils"
23 /** Callers to interfaces that set __GFP_NORETRY flag below
24 * must check for a NULL (error) result as we are telling the
25 * kernel interface that it is okay to fail.
28 void *kmalloc_kernel(size_t siz)
30 return kmalloc(siz, GFP_KERNEL | __GFP_NORETRY);
33 /* Use these handy-dandy seq_file_xxx functions if you want to call some
34 * functions that write stuff into a seq_file, but you actually just want
35 * to dump that output into a buffer. Use them as follows:
36 * - call visor_seq_file_new_buffer to create the seq_file (you supply the buf)
37 * - call whatever functions you want that take a seq_file as an argument
38 * (the buf you supplied will get the output data)
39 * - call visor_seq_file_done_buffer to dispose of your seq_file
41 struct seq_file *visor_seq_file_new_buffer(void *buf, size_t buf_size)
43 struct seq_file *rc = NULL;
44 struct seq_file *m = kmalloc_kernel(sizeof(struct seq_file));
50 memset(m, 0, sizeof(struct seq_file));
56 visor_seq_file_done_buffer(m);
61 EXPORT_SYMBOL_GPL(visor_seq_file_new_buffer);
65 void visor_seq_file_done_buffer(struct seq_file *m)
71 EXPORT_SYMBOL_GPL(visor_seq_file_done_buffer);