2 * Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include <linux/module.h>
21 /* Needed for procfs register functions */
22 #include <linux/proc_fs.h>
23 /* Needed for using the seq_file infrastructure */
24 #include <linux/seq_file.h>
26 MODULE_AUTHOR("Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>");
27 MODULE_LICENSE("GPL");
29 /* write our message to the sequential file */
30 static int hello_show(struct seq_file *file, void *data)
32 seq_puts(file, "Hello, world!\n");
36 /* use the single sequential file */
37 static int hello_procfs_open(struct inode *inode, struct file *file)
39 return single_open(file, hello_show, NULL);
42 /* our file operations use the seq_file stuff to make it an easy task */
43 static const struct file_operations hello_procfs_fops =
45 .open = hello_procfs_open,
48 .release = seq_release,
51 static int hello_procfs_init(void)
53 /* create the proc entry and set its fops: there is a potential race
55 struct proc_dir_entry *entry;
56 entry = create_proc_entry("hellop", 0666, NULL);
57 entry->proc_fops = &hello_procfs_fops;
61 static void hello_procfs_exit(void)
63 /* remove our proc entry */
64 remove_proc_entry("hellop", NULL);
67 module_init(hello_procfs_init);
68 module_exit(hello_procfs_exit);