aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/hdpuftrs/hdpu_cpustate.c
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2007-10-02 16:30:09 -0400
committerPaul Mackerras <paulus@samba.org>2007-10-02 22:02:44 -0400
commit3049ea7e04408abf35dc295014cb6f1eabcf9b8c (patch)
tree1c931e25037ecdf5c6a74acae1a247cadc3eafdd /drivers/misc/hdpuftrs/hdpu_cpustate.c
parent8b70da1a094fb781d49a811fd2368907adc92b8d (diff)
[POWERPC] Sky Cpu and Nexus: use seq_file/single_open on proc interface
This patch changes proc interface to be used with single_file/seq_open calls. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'drivers/misc/hdpuftrs/hdpu_cpustate.c')
-rw-r--r--drivers/misc/hdpuftrs/hdpu_cpustate.c66
1 files changed, 35 insertions, 31 deletions
diff --git a/drivers/misc/hdpuftrs/hdpu_cpustate.c b/drivers/misc/hdpuftrs/hdpu_cpustate.c
index 32f65a3e07ce..aa8ce7abe922 100644
--- a/drivers/misc/hdpuftrs/hdpu_cpustate.c
+++ b/drivers/misc/hdpuftrs/hdpu_cpustate.c
@@ -19,9 +19,10 @@
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
21#include <linux/proc_fs.h> 21#include <linux/proc_fs.h>
22#include <linux/hdpu_features.h>
22#include <linux/platform_device.h> 23#include <linux/platform_device.h>
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24#include <linux/hdpu_features.h> 25#include <linux/seq_file.h>
25#include <asm/io.h> 26#include <asm/io.h>
26 27
27#define SKY_CPUSTATE_VERSION "1.1" 28#define SKY_CPUSTATE_VERSION "1.1"
@@ -29,7 +30,30 @@
29static int hdpu_cpustate_probe(struct platform_device *pdev); 30static int hdpu_cpustate_probe(struct platform_device *pdev);
30static int hdpu_cpustate_remove(struct platform_device *pdev); 31static int hdpu_cpustate_remove(struct platform_device *pdev);
31 32
32struct cpustate_t cpustate; 33static unsigned char cpustate_get_state(void);
34static int cpustate_proc_open(struct inode *inode, struct file *file);
35static int cpustate_proc_read(struct seq_file *seq, void *offset);
36
37static struct cpustate_t cpustate;
38
39static const struct file_operations proc_cpustate = {
40 .open = cpustate_proc_open,
41 .read = seq_read,
42 .llseek = seq_lseek,
43 .release = single_release,
44 .owner = THIS_MODULE,
45};
46
47static int cpustate_proc_open(struct inode *inode, struct file *file)
48{
49 return single_open(file, cpustate_proc_read, NULL);
50}
51
52static int cpustate_proc_read(struct seq_file *seq, void *offset)
53{
54 seq_printf(seq, "CPU State: %04x\n", cpustate_get_state());
55 return 0;
56}
33 57
34static int cpustate_get_ref(int excl) 58static int cpustate_get_ref(int excl)
35{ 59{
@@ -67,13 +91,13 @@ static int cpustate_free_ref(void)
67 return 0; 91 return 0;
68} 92}
69 93
70unsigned char cpustate_get_state(void) 94static unsigned char cpustate_get_state(void)
71{ 95{
72 96
73 return cpustate.cached_val; 97 return cpustate.cached_val;
74} 98}
75 99
76void cpustate_set_state(unsigned char new_state) 100static void cpustate_set_state(unsigned char new_state)
77{ 101{
78 unsigned int state = (new_state << 21); 102 unsigned int state = (new_state << 21);
79 103
@@ -135,29 +159,6 @@ static int cpustate_release(struct inode *inode, struct file *file)
135 return cpustate_free_ref(); 159 return cpustate_free_ref();
136} 160}
137 161
138/*
139 * Info exported via "/proc/sky_cpustate".
140 */
141static int cpustate_read_proc(char *page, char **start, off_t off,
142 int count, int *eof, void *data)
143{
144 char *p = page;
145 int len = 0;
146
147 p += sprintf(p, "CPU State: %04x\n", cpustate_get_state());
148 len = p - page;
149
150 if (len <= off + count)
151 *eof = 1;
152 *start = page + off;
153 len -= off;
154 if (len > count)
155 len = count;
156 if (len < 0)
157 len = 0;
158 return len;
159}
160
161static struct platform_driver hdpu_cpustate_driver = { 162static struct platform_driver hdpu_cpustate_driver = {
162 .probe = hdpu_cpustate_probe, 163 .probe = hdpu_cpustate_probe,
163 .remove = hdpu_cpustate_remove, 164 .remove = hdpu_cpustate_remove,
@@ -208,11 +209,14 @@ static int hdpu_cpustate_probe(struct platform_device *pdev)
208 return ret; 209 return ret;
209 } 210 }
210 211
211 proc_de = create_proc_read_entry("sky_cpustate", 0, 0, 212 proc_de = create_proc_entry("sky_cpustate", 0666, &proc_root);
212 cpustate_read_proc, NULL); 213 if (!proc_de) {
213 if (proc_de == NULL)
214 printk(KERN_WARNING "sky_cpustate: " 214 printk(KERN_WARNING "sky_cpustate: "
215 "Unable to create proc dir entry\n"); 215 "Unable to create proc entry\n");
216 } else {
217 proc_de->proc_fops = &proc_cpustate;
218 proc_de->owner = THIS_MODULE;
219 }
216 220
217 printk(KERN_INFO "Sky CPU State Driver v" SKY_CPUSTATE_VERSION "\n"); 221 printk(KERN_INFO "Sky CPU State Driver v" SKY_CPUSTATE_VERSION "\n");
218 return 0; 222 return 0;