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