aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/misc/hdpuftrs/hdpu_cpustate.c66
-rw-r--r--drivers/misc/hdpuftrs/hdpu_nexus.c52
2 files changed, 74 insertions, 44 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;
diff --git a/drivers/misc/hdpuftrs/hdpu_nexus.c b/drivers/misc/hdpuftrs/hdpu_nexus.c
index cc818532c7ec..2887b2147980 100644
--- a/drivers/misc/hdpuftrs/hdpu_nexus.c
+++ b/drivers/misc/hdpuftrs/hdpu_nexus.c
@@ -18,18 +18,38 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
20#include <linux/hdpu_features.h> 20#include <linux/hdpu_features.h>
21
22#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/seq_file.h>
23#include <asm/io.h> 23#include <asm/io.h>
24 24
25static int hdpu_nexus_probe(struct platform_device *pdev); 25static int hdpu_nexus_probe(struct platform_device *pdev);
26static int hdpu_nexus_remove(struct platform_device *pdev); 26static int hdpu_nexus_remove(struct platform_device *pdev);
27static int hdpu_slot_id_open(struct inode *inode, struct file *file);
28static int hdpu_slot_id_read(struct seq_file *seq, void *offset);
29static int hdpu_chassis_id_open(struct inode *inode, struct file *file);
30static int hdpu_chassis_id_read(struct seq_file *seq, void *offset);
27 31
28static struct proc_dir_entry *hdpu_slot_id; 32static struct proc_dir_entry *hdpu_slot_id;
29static struct proc_dir_entry *hdpu_chassis_id; 33static struct proc_dir_entry *hdpu_chassis_id;
30static int slot_id = -1; 34static int slot_id = -1;
31static int chassis_id = -1; 35static int chassis_id = -1;
32 36
37static const struct file_operations proc_slot_id = {
38 .open = hdpu_slot_id_open,
39 .read = seq_read,
40 .llseek = seq_lseek,
41 .release = single_release,
42 .owner = THIS_MODULE,
43};
44
45static const struct file_operations proc_chassis_id = {
46 .open = hdpu_chassis_id_open,
47 .read = seq_read,
48 .llseek = seq_lseek,
49 .release = single_release,
50 .owner = THIS_MODULE,
51};
52
33static struct platform_driver hdpu_nexus_driver = { 53static struct platform_driver hdpu_nexus_driver = {
34 .probe = hdpu_nexus_probe, 54 .probe = hdpu_nexus_probe,
35 .remove = hdpu_nexus_remove, 55 .remove = hdpu_nexus_remove,
@@ -38,22 +58,26 @@ static struct platform_driver hdpu_nexus_driver = {
38 }, 58 },
39}; 59};
40 60
41int hdpu_slot_id_read(char *buffer, char **buffer_location, off_t offset, 61static int hdpu_slot_id_open(struct inode *inode, struct file *file)
42 int buffer_length, int *zero, void *ptr)
43{ 62{
44 if (offset > 0) 63 return single_open(file, hdpu_slot_id_read, NULL);
45 return 0; 64}
46 65
47 return sprintf(buffer, "%d\n", slot_id); 66static int hdpu_slot_id_read(struct seq_file *seq, void *offset)
67{
68 seq_printf(seq, "%d\n", slot_id);
69 return 0;
48} 70}
49 71
50int hdpu_chassis_id_read(char *buffer, char **buffer_location, off_t offset, 72static int hdpu_chassis_id_open(struct inode *inode, struct file *file)
51 int buffer_length, int *zero, void *ptr)
52{ 73{
53 if (offset > 0) 74 return single_open(file, hdpu_chassis_id_read, NULL);
54 return 0; 75}
55 76
56 return sprintf(buffer, "%d\n", chassis_id); 77static int hdpu_chassis_id_read(struct seq_file *seq, void *offset)
78{
79 seq_printf(seq, "%d\n", chassis_id);
80 return 0;
57} 81}
58 82
59static int hdpu_nexus_probe(struct platform_device *pdev) 83static int hdpu_nexus_probe(struct platform_device *pdev)
@@ -82,7 +106,8 @@ static int hdpu_nexus_probe(struct platform_device *pdev)
82 printk(KERN_WARNING "sky_nexus: " 106 printk(KERN_WARNING "sky_nexus: "
83 "Unable to create proc dir entry: sky_slot_id\n"); 107 "Unable to create proc dir entry: sky_slot_id\n");
84 } else { 108 } else {
85 hdpu_slot_id->read_proc = hdpu_slot_id_read; 109 hdpu_slot_id->proc_fops = &proc_slot_id;
110 hdpu_slot_id->owner = THIS_MODULE;
86 } 111 }
87 112
88 hdpu_chassis_id = create_proc_entry("sky_chassis_id", 0666, &proc_root); 113 hdpu_chassis_id = create_proc_entry("sky_chassis_id", 0666, &proc_root);
@@ -90,7 +115,8 @@ static int hdpu_nexus_probe(struct platform_device *pdev)
90 printk(KERN_WARNING "sky_nexus: " 115 printk(KERN_WARNING "sky_nexus: "
91 "Unable to create proc dir entry: sky_chassis_id\n"); 116 "Unable to create proc dir entry: sky_chassis_id\n");
92 } else { 117 } else {
93 hdpu_chassis_id->read_proc = hdpu_chassis_id_read; 118 hdpu_chassis_id->proc_fops = &proc_chassis_id;
119 hdpu_chassis_id->owner = THIS_MODULE;
94 } 120 }
95 121
96 return 0; 122 return 0;