Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sn_proc_fs.c
Go to the documentation of this file.
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License. See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 2000-2005 Silicon Graphics, Inc. All rights reserved.
7  */
8 
9 #ifdef CONFIG_PROC_FS
10 #include <linux/proc_fs.h>
11 #include <linux/seq_file.h>
12 #include <asm/uaccess.h>
13 #include <asm/sn/sn_sal.h>
14 
15 static int partition_id_show(struct seq_file *s, void *p)
16 {
17  seq_printf(s, "%d\n", sn_partition_id);
18  return 0;
19 }
20 
21 static int partition_id_open(struct inode *inode, struct file *file)
22 {
23  return single_open(file, partition_id_show, NULL);
24 }
25 
26 static int system_serial_number_show(struct seq_file *s, void *p)
27 {
28  seq_printf(s, "%s\n", sn_system_serial_number());
29  return 0;
30 }
31 
32 static int system_serial_number_open(struct inode *inode, struct file *file)
33 {
34  return single_open(file, system_serial_number_show, NULL);
35 }
36 
37 static int licenseID_show(struct seq_file *s, void *p)
38 {
39  seq_printf(s, "0x%llx\n", sn_partition_serial_number_val());
40  return 0;
41 }
42 
43 static int licenseID_open(struct inode *inode, struct file *file)
44 {
45  return single_open(file, licenseID_show, NULL);
46 }
47 
48 static int coherence_id_show(struct seq_file *s, void *p)
49 {
50  seq_printf(s, "%d\n", partition_coherence_id());
51 
52  return 0;
53 }
54 
55 static int coherence_id_open(struct inode *inode, struct file *file)
56 {
57  return single_open(file, coherence_id_show, NULL);
58 }
59 
60 /* /proc/sgi_sn/sn_topology uses seq_file, see sn_hwperf.c */
61 extern int sn_topology_open(struct inode *, struct file *);
62 extern int sn_topology_release(struct inode *, struct file *);
63 
64 static const struct file_operations proc_partition_id_fops = {
65  .open = partition_id_open,
66  .read = seq_read,
67  .llseek = seq_lseek,
68  .release = single_release,
69 };
70 
71 static const struct file_operations proc_system_sn_fops = {
72  .open = system_serial_number_open,
73  .read = seq_read,
74  .llseek = seq_lseek,
75  .release = single_release,
76 };
77 
78 static const struct file_operations proc_license_id_fops = {
79  .open = licenseID_open,
80  .read = seq_read,
81  .llseek = seq_lseek,
82  .release = single_release,
83 };
84 
85 static const struct file_operations proc_coherence_id_fops = {
86  .open = coherence_id_open,
87  .read = seq_read,
88  .llseek = seq_lseek,
89  .release = single_release,
90 };
91 
92 static const struct file_operations proc_sn_topo_fops = {
94  .read = seq_read,
95  .llseek = seq_lseek,
96  .release = sn_topology_release,
97 };
98 
99 void register_sn_procfs(void)
100 {
101  static struct proc_dir_entry *sgi_proc_dir = NULL;
102 
103  BUG_ON(sgi_proc_dir != NULL);
104  if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL)))
105  return;
106 
107  proc_create("partition_id", 0444, sgi_proc_dir,
108  &proc_partition_id_fops);
109  proc_create("system_serial_number", 0444, sgi_proc_dir,
110  &proc_system_sn_fops);
111  proc_create("licenseID", 0444, sgi_proc_dir, &proc_license_id_fops);
112  proc_create("coherence_id", 0444, sgi_proc_dir,
113  &proc_coherence_id_fops);
114  proc_create("sn_topology", 0444, sgi_proc_dir, &proc_sn_topo_fops);
115 }
116 
117 #endif /* CONFIG_PROC_FS */