* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
ssize_t
lprocfs_fops_read(struct file *f, char __user *buf, size_t size, loff_t *ppos)
{
- struct proc_dir_entry *dp = PDE(f->f_dentry->d_inode);
- char *page, *start = NULL;
- int rc = 0, eof = 1, count;
+ struct inode *inode = f->f_dentry->d_inode;
+ struct proc_dir_entry *dp = PDE(inode);
+ char *page, *start = NULL;
+ int rc, eof = 1, count;
if (*ppos >= PAGE_CACHE_SIZE)
- return 0;
+ return 0;
- page = (char *)__get_free_page(GFP_KERNEL);
- if (page == NULL)
- return -ENOMEM;
+ page = (char *)__get_free_page(GFP_KERNEL);
+ if (page == NULL)
+ return -ENOMEM;
- if (LPROCFS_ENTRY_CHECK(dp)) {
- rc = -ENOENT;
- goto out;
- }
+ rc = LPROCFS_ENTRY_CHECK(inode);
+ if (rc < 0)
+ goto out;
- OBD_FAIL_TIMEOUT(OBD_FAIL_LPROC_REMOVE, 10);
- if (dp->read_proc)
+ OBD_FAIL_TIMEOUT(OBD_FAIL_LPROC_REMOVE, 10);
+ if (dp->read_proc != NULL)
rc = dp->read_proc(page, &start, *ppos, PAGE_CACHE_SIZE,
- &eof, dp->data);
+ &eof, dp->data);
+ else
+ rc = 0;
+
if (rc <= 0)
goto out;
lprocfs_fops_write(struct file *f, const char __user *buf, size_t size,
loff_t *ppos)
{
- struct proc_dir_entry *dp = PDE(f->f_dentry->d_inode);
- int rc = -EIO;
+ struct inode *inode = f->f_dentry->d_inode;
+ struct proc_dir_entry *dp = PDE(inode);
+ int rc;
- if (LPROCFS_ENTRY_CHECK(dp))
- return -ENOENT;
- if (dp->write_proc)
- rc = dp->write_proc(f, buf, size, dp->data);
- return rc;
+ rc = LPROCFS_ENTRY_CHECK(inode);
+ if (rc < 0)
+ return rc;
+
+ if (dp->write_proc != NULL)
+ rc = dp->write_proc(f, buf, size, dp->data);
+ else
+ rc = -EIO;
+
+ return rc;
}
static struct file_operations lprocfs_generic_fops = {
EXPORT_SYMBOL(lprocfs_seq_add_vars);
#ifndef HAVE_ONLY_PROCFS_SEQ
-void lprocfs_remove_nolock(struct proc_dir_entry **proot)
+static void lprocfs_remove_nolock(struct proc_dir_entry **proot)
{
struct proc_dir_entry *root = *proot;
struct proc_dir_entry *temp = root;
return (rc < 0) ? rc : 0;
}
-struct seq_operations lprocfs_stats_seq_sops = {
+static const struct seq_operations lprocfs_stats_seq_sops = {
.start = lprocfs_stats_seq_start,
.stop = lprocfs_stats_seq_stop,
.next = lprocfs_stats_seq_next,
struct seq_file *seq;
int rc;
-#ifndef HAVE_ONLY_PROCFS_SEQ
- if (LPROCFS_ENTRY_CHECK(PDE(inode)))
- return -ENOENT;
-#endif
+ rc = LPROCFS_ENTRY_CHECK(inode);
+ if (rc < 0)
+ return rc;
+
rc = seq_open(file, &lprocfs_stats_seq_sops);
if (rc)
return rc;
return 0;
}
-struct file_operations lprocfs_stats_seq_fops = {
+static const struct file_operations lprocfs_stats_seq_fops = {
.owner = THIS_MODULE,
.open = lprocfs_stats_seq_open,
.read = seq_read,