Commit 4c237820 authored by David Howells's avatar David Howells Committed by Al Viro

ppc: Clean up scanlog

Clean up the pseries scanlog driver's use of procfs:

 (1) Don't need to save the proc_dir_entry pointer as we have the filename to
     remove with.

 (2) Save the scan log buffer pointer in a static variable (there is only one
     of it) and don't save it in the PDE (which doesn't have a destructor).
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
cc: Paul Mackerras <paulus@samba.org>
cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent e8eeded3
...@@ -41,12 +41,12 @@ ...@@ -41,12 +41,12 @@
static unsigned int ibm_scan_log_dump; /* RTAS token */ static unsigned int ibm_scan_log_dump; /* RTAS token */
static struct proc_dir_entry *proc_ppc64_scan_log_dump; /* The proc file */ static unsigned int *scanlog_buffer; /* The data buffer */
static ssize_t scanlog_read(struct file *file, char __user *buf, static ssize_t scanlog_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
unsigned int *data = PDE_DATA(file_inode(file)); unsigned int *data = scanlog_buffer;
int status; int status;
unsigned long len, off; unsigned long len, off;
unsigned int wait_time; unsigned int wait_time;
...@@ -134,7 +134,7 @@ static ssize_t scanlog_write(struct file * file, const char __user * buf, ...@@ -134,7 +134,7 @@ static ssize_t scanlog_write(struct file * file, const char __user * buf,
static int scanlog_open(struct inode * inode, struct file * file) static int scanlog_open(struct inode * inode, struct file * file)
{ {
unsigned int *data = PDE_DATA(file_inode(file)); unsigned int *data = scanlog_buffer;
if (data[0] != 0) { if (data[0] != 0) {
/* This imperfect test stops a second copy of the /* This imperfect test stops a second copy of the
...@@ -150,10 +150,9 @@ static int scanlog_open(struct inode * inode, struct file * file) ...@@ -150,10 +150,9 @@ static int scanlog_open(struct inode * inode, struct file * file)
static int scanlog_release(struct inode * inode, struct file * file) static int scanlog_release(struct inode * inode, struct file * file)
{ {
unsigned int *data = PDE_DATA(file_inode(file)); unsigned int *data = scanlog_buffer;
data[0] = 0; data[0] = 0;
return 0; return 0;
} }
...@@ -169,7 +168,6 @@ const struct file_operations scanlog_fops = { ...@@ -169,7 +168,6 @@ const struct file_operations scanlog_fops = {
static int __init scanlog_init(void) static int __init scanlog_init(void)
{ {
struct proc_dir_entry *ent; struct proc_dir_entry *ent;
void *data;
int err = -ENOMEM; int err = -ENOMEM;
ibm_scan_log_dump = rtas_token("ibm,scan-log-dump"); ibm_scan_log_dump = rtas_token("ibm,scan-log-dump");
...@@ -177,29 +175,24 @@ static int __init scanlog_init(void) ...@@ -177,29 +175,24 @@ static int __init scanlog_init(void)
return -ENODEV; return -ENODEV;
/* Ideally we could allocate a buffer < 4G */ /* Ideally we could allocate a buffer < 4G */
data = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL); scanlog_buffer = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL);
if (!data) if (!scanlog_buffer)
goto err; goto err;
ent = proc_create_data("powerpc/rtas/scan-log-dump", S_IRUSR, NULL, ent = proc_create("powerpc/rtas/scan-log-dump", S_IRUSR, NULL,
&scanlog_fops, data); &scanlog_fops);
if (!ent) if (!ent)
goto err; goto err;
proc_ppc64_scan_log_dump = ent;
return 0; return 0;
err: err:
kfree(data); kfree(scanlog_buffer);
return err; return err;
} }
static void __exit scanlog_cleanup(void) static void __exit scanlog_cleanup(void)
{ {
if (proc_ppc64_scan_log_dump) { remove_proc_entry("powerpc/rtas/scan-log-dump", NULL);
kfree(proc_ppc64_scan_log_dump->data); kfree(scanlog_buffer);
remove_proc_entry("scan-log-dump", proc_ppc64_scan_log_dump->parent);
}
} }
module_init(scanlog_init); module_init(scanlog_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment