aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/platforms/pseries/scanlog.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/arch/powerpc/platforms/pseries/scanlog.c b/arch/powerpc/platforms/pseries/scanlog.c
index cc220d2061b2..b502ab61aafa 100644
--- a/arch/powerpc/platforms/pseries/scanlog.c
+++ b/arch/powerpc/platforms/pseries/scanlog.c
@@ -41,12 +41,12 @@
41 41
42 42
43static unsigned int ibm_scan_log_dump; /* RTAS token */ 43static unsigned int ibm_scan_log_dump; /* RTAS token */
44static struct proc_dir_entry *proc_ppc64_scan_log_dump; /* The proc file */ 44static unsigned int *scanlog_buffer; /* The data buffer */
45 45
46static ssize_t scanlog_read(struct file *file, char __user *buf, 46static ssize_t scanlog_read(struct file *file, char __user *buf,
47 size_t count, loff_t *ppos) 47 size_t count, loff_t *ppos)
48{ 48{
49 unsigned int *data = PDE_DATA(file_inode(file)); 49 unsigned int *data = scanlog_buffer;
50 int status; 50 int status;
51 unsigned long len, off; 51 unsigned long len, off;
52 unsigned int wait_time; 52 unsigned int wait_time;
@@ -134,7 +134,7 @@ static ssize_t scanlog_write(struct file * file, const char __user * buf,
134 134
135static int scanlog_open(struct inode * inode, struct file * file) 135static int scanlog_open(struct inode * inode, struct file * file)
136{ 136{
137 unsigned int *data = PDE_DATA(file_inode(file)); 137 unsigned int *data = scanlog_buffer;
138 138
139 if (data[0] != 0) { 139 if (data[0] != 0) {
140 /* This imperfect test stops a second copy of the 140 /* This imperfect test stops a second copy of the
@@ -150,10 +150,9 @@ static int scanlog_open(struct inode * inode, struct file * file)
150 150
151static int scanlog_release(struct inode * inode, struct file * file) 151static int scanlog_release(struct inode * inode, struct file * file)
152{ 152{
153 unsigned int *data = PDE_DATA(file_inode(file)); 153 unsigned int *data = scanlog_buffer;
154 154
155 data[0] = 0; 155 data[0] = 0;
156
157 return 0; 156 return 0;
158} 157}
159 158
@@ -169,7 +168,6 @@ const struct file_operations scanlog_fops = {
169static int __init scanlog_init(void) 168static int __init scanlog_init(void)
170{ 169{
171 struct proc_dir_entry *ent; 170 struct proc_dir_entry *ent;
172 void *data;
173 int err = -ENOMEM; 171 int err = -ENOMEM;
174 172
175 ibm_scan_log_dump = rtas_token("ibm,scan-log-dump"); 173 ibm_scan_log_dump = rtas_token("ibm,scan-log-dump");
@@ -177,29 +175,24 @@ static int __init scanlog_init(void)
177 return -ENODEV; 175 return -ENODEV;
178 176
179 /* Ideally we could allocate a buffer < 4G */ 177 /* Ideally we could allocate a buffer < 4G */
180 data = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL); 178 scanlog_buffer = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL);
181 if (!data) 179 if (!scanlog_buffer)
182 goto err; 180 goto err;
183 181
184 ent = proc_create_data("powerpc/rtas/scan-log-dump", S_IRUSR, NULL, 182 ent = proc_create("powerpc/rtas/scan-log-dump", S_IRUSR, NULL,
185 &scanlog_fops, data); 183 &scanlog_fops);
186 if (!ent) 184 if (!ent)
187 goto err; 185 goto err;
188
189 proc_ppc64_scan_log_dump = ent;
190
191 return 0; 186 return 0;
192err: 187err:
193 kfree(data); 188 kfree(scanlog_buffer);
194 return err; 189 return err;
195} 190}
196 191
197static void __exit scanlog_cleanup(void) 192static void __exit scanlog_cleanup(void)
198{ 193{
199 if (proc_ppc64_scan_log_dump) { 194 remove_proc_entry("powerpc/rtas/scan-log-dump", NULL);
200 kfree(proc_ppc64_scan_log_dump->data); 195 kfree(scanlog_buffer);
201 remove_proc_entry("scan-log-dump", proc_ppc64_scan_log_dump->parent);
202 }
203} 196}
204 197
205module_init(scanlog_init); 198module_init(scanlog_init);